aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb
diff options
context:
space:
mode:
authorAditya Chadha <aditya@sublucid.com>2009-05-02 18:32:45 -0400
committerAditya Chadha <aditya@sublucid.com>2009-05-02 18:32:45 -0400
commit7a17ad3f2b89baea94450af8e63a640ace570938 (patch)
tree89cd60c05d4a812b3c8636373a05689b1df5bf75 /actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb
parent5469a0be1a517a0c2d8ee553b704df4e6f7df306 (diff)
parent1b32f882091ed7744654f74238f3f3b1ba6701ae (diff)
downloadrails-7a17ad3f2b89baea94450af8e63a640ace570938.tar.gz
rails-7a17ad3f2b89baea94450af8e63a640ace570938.tar.bz2
rails-7a17ad3f2b89baea94450af8e63a640ace570938.zip
Merge branch 'master' of git@github.com:lifo/docrails
Diffstat (limited to 'actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb')
-rw-r--r--actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb64
1 files changed, 0 insertions, 64 deletions
diff --git a/actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb b/actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb
deleted file mode 100644
index b17d8c0926..0000000000
--- a/actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb
+++ /dev/null
@@ -1,64 +0,0 @@
-require 'thread'
-
-module Rack
- # Rack::Reloader checks on every request, but at most every +secs+
- # seconds, if a file loaded changed, and reloads it, logging to
- # rack.errors.
- #
- # It is recommended you use ShowExceptions to catch SyntaxErrors etc.
-
- class Reloader
- def initialize(app, secs=10)
- @app = app
- @secs = secs # reload every @secs seconds max
- @last = Time.now
- end
-
- def call(env)
- if Time.now > @last + @secs
- Thread.exclusive {
- reload!(env['rack.errors'])
- @last = Time.now
- }
- end
-
- @app.call(env)
- end
-
- def reload!(stderr=$stderr)
- need_reload = $LOADED_FEATURES.find_all { |loaded|
- begin
- if loaded =~ /\A[.\/]/ # absolute filename or 1.9
- abs = loaded
- else
- abs = $LOAD_PATH.map { |path| ::File.join(path, loaded) }.
- find { |file| ::File.exist? file }
- end
-
- if abs
- ::File.mtime(abs) > @last - @secs rescue false
- else
- false
- end
- end
- }
-
- need_reload.each { |l|
- $LOADED_FEATURES.delete l
- }
-
- need_reload.each { |to_load|
- begin
- if require to_load
- stderr.puts "#{self.class}: reloaded `#{to_load}'"
- end
- rescue LoadError, SyntaxError => e
- raise e # Possibly ShowExceptions
- end
- }
-
- stderr.flush
- need_reload
- end
- end
-end