module Spring
Some parts adapted from golang.org/src/pkg/json/decode.go and golang.org/src/pkg/utf8/utf8.go
Constants
- IGNORE_SIGNALS
- ORIGINAL_ENV
- VERSION
Attributes
application_root[RW]
commands[R]
watch_interval[RW]
watch_method[R]
watcher[W]
Public Class Methods
command(name)
click to toggle source
# File lib/spring/commands.rb, line 19 def self.command(name) commands.fetch name end
command?(name)
click to toggle source
# File lib/spring/commands.rb, line 15 def self.command?(name) commands.include? name end
register_command(name, command = nil)
click to toggle source
# File lib/spring/commands.rb, line 11 def self.register_command(name, command = nil) commands[name] = CommandWrapper.new(name, command) end
watch(*items)
click to toggle source
# File lib/spring/watcher.rb, line 31 def self.watch(*items) watcher.add *items end
watch_method=(method)
click to toggle source
# File lib/spring/watcher.rb, line 11 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
watcher()
click to toggle source
# File lib/spring/watcher.rb, line 27 def self.watcher @watcher ||= watch_method.new(Spring.application_root_path, watch_interval) end
Public Instance Methods
after_fork(&block)
click to toggle source
# File lib/spring/configuration.rb, line 15 def after_fork(&block) after_fork_callbacks << block end
after_fork_callbacks()
click to toggle source
# File lib/spring/configuration.rb, line 11 def after_fork_callbacks @after_fork_callbacks ||= [] end
application_root_path()
click to toggle source
# File lib/spring/configuration.rb, line 23 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
gemfile()
click to toggle source
# File lib/spring/configuration.rb, line 7 def gemfile ENV['BUNDLE_GEMFILE'] || "Gemfile" end
project_root_path()
click to toggle source
# File lib/spring/configuration.rb, line 36 def project_root_path @project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd))) end
verify_environment()
click to toggle source
# File lib/spring/configuration.rb, line 19 def verify_environment application_root_path end
Private Instance Methods
find_project_root(current_dir)
click to toggle source
# File lib/spring/configuration.rb, line 42 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