module Spring
def self.command(name)
def self.command(name) commands.fetch name end
def self.command?(name)
def self.command?(name) commands.include? name end
def self.register_command(name, command = nil)
def self.register_command(name, command = nil) commands[name] = CommandWrapper.new(name, command) end
def self.watch(*items)
def self.watch(*items) watcher.add *items end
def self.watch_method=(method)
def self.watch_method=(method) case method when :polling require_relative "watcher/polling" @watch_method = Watcher::Polling when :listen require_relative "watcher/listen" @watch_method = Watcher::Listen else @watch_method = method end end
def self.watcher
def self.watcher @watcher ||= watch_method.new(Spring.application_root_path, watch_interval) end
def after_fork(&block)
def after_fork(&block) after_fork_callbacks << block end
def after_fork_callbacks
def after_fork_callbacks @after_fork_callbacks ||= [] end
def application_root_path
def application_root_path @application_root_path ||= begin if application_root path = Pathname.new(File.expand_path(application_root)) else path = project_root_path end raise MissingApplication.new(path) unless path.join("config/application.rb").exist? path end end
def find_project_root(current_dir)
def find_project_root(current_dir) if current_dir.join(gemfile).exist? current_dir elsif current_dir.root? raise UnknownProject.new(Dir.pwd) else find_project_root(current_dir.parent) end end
def gemfile
def gemfile ENV['BUNDLE_GEMFILE'] || "Gemfile" end
def project_root_path
def project_root_path @project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd))) end
def verify_environment
def verify_environment application_root_path end