Created
August 25, 2010 13:44
-
-
Save rkh/549533 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use Rack::Config do |env| | |
# Store mtimes to track changes | |
@mtimes ||= Hash.new { |map, file| map[file] = File.mtime(file) } | |
# Check all loaded files for changes | |
$LOADED_FEATURES.each do |feature| | |
file = nil | |
# Let's see if we can find the file. 1.8 stores the string we | |
# pass to require plus the file extension. 1.9 actually stores | |
# the expanded paths. But if that's the case, the first entry | |
# to $LOAD_PATH satisfy the condition. | |
next unless $LOAD_PATH.any? { |dir| | |
File.exist?(file = File.expand_path(feature, path)) } | |
# Check if file changed | |
if @mtimes[file] != File.mtime(file) | |
# Store the new mtime, so we don't reload it next time | |
@mtimes[file] = File.mtime | |
# Reload | |
load file | |
end | |
end | |
end | |
require 'application' | |
run Application |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment