Permalink
Browse files

Use the less basic reload.

  • Loading branch information...
1 parent a6f753d commit d9d558313feff13ef39c3d6f7d4e512d2b9e2c90 Darrick Wiebe committed Mar 31, 2011
Showing with 24 additions and 4 deletions.
  1. +24 −4 lib/pacer-agent.rb
View
28 lib/pacer-agent.rb
@@ -5,10 +5,8 @@ module PacerAgent
unless const_defined? :VERSION
PATH = File.expand_path(File.join(File.dirname(__FILE__), '..'))
VERSION = File.read(PATH + '/VERSION').chomp
- end
-
- def self.reload!
- load __FILE__
+ START_TIME = Time.now
+ $:.unshift File.join(PATH, 'lib')
end
end
@@ -39,3 +37,25 @@ def channel(opts = {})
end
end
+
+module PacerAgent
+ def self.reload_time
+ @reload_time || START_TIME
+ end
+
+ # Reload all Ruby modified files in the Pacer library. Useful for debugging
+ # in the console. Does not do any of the fancy stuff that Rails reloading
+ # does. Certain types of changes will still require restarting the
+ # session.
+ def self.reload!
+ require 'pathname'
+ Pathname.new(File.expand_path(__FILE__)).parent.find do |path|
+ if path.extname == '.rb' and path.mtime > reload_time
+ puts path.to_s
+ load path.to_s
+ end
+ end
+ @reload_time = Time.now
+ end
+end
+

0 comments on commit d9d5583

Please sign in to comment.