Reload changed sources #1

nightscape opened this Issue Jun 9, 2009 · 1 comment


None yet
1 participant

Hi Michael,

I'm trying to develop an application for which Wee seems very well suited.
One thing that slows down development quite a lot is that when I change the Ruby code of a component, the component does not get reloaded.
Rails and Ramaze both do this and its very useful!
To achieve this, you can reuse Ramaze's source reloader which is a Rack app:
require 'rack/handler/webrick'
require 'ramaze'

app = do
  use Ramaze::Reloader
  Wee::JQuery.install('/jquery', self)
  map '/' do
    run {
end, :Port => 2000)

This correctly reloads the changed files.
The only problem is that the server is not shut down before the reload and blocking the port.
You can redefine some methods in Ramaze::Reloader::Hooks in order to do this,
but I'm not proficient enough in Rack, WEBrick and Wee to do this.
Anyway, here is what I tried:
$server = nil, :Port => 2000) {|srvr| $server = srvr }
Ramaze::Reloader::Hooks.class_eval do
def before_cycle

It would be great if you could add the missing puzzle peaces.

Thanks a lot!

Ok, my fault... Of course you have to overwrite the method on the Reloader itself,
as the module has already been included before...

$server = nil, :Port => 2000) {|srvr| $server = srvr }
Ramaze::Reloader.class_eval do 
  def before_cycle

Now, the files are reloaded correctly and the server shows the changes.
The exception about the already used port is still raised, but that doesn't seem to influence the process.
Maybe you find a nicer solution without exception...

I hope to be able to contribute some nice Ajax components soon :)


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment