Module: Spring

Defined in:
lib/spring/json.rb,
lib/spring/env.rb,
lib/spring/json.rb,
lib/spring/client.rb,
lib/spring/errors.rb,
lib/spring/server.rb,
lib/spring/server.rb,
lib/spring/version.rb,
lib/spring/watcher.rb,
lib/spring/commands.rb,
lib/spring/client/run.rb,
lib/spring/application.rb,
lib/spring/client/help.rb,
lib/spring/client/stop.rb,
lib/spring/client/rails.rb,
lib/spring/client/server.rb,
lib/spring/client/status.rb,
lib/spring/commands/rake.rb,
lib/spring/configuration.rb,
lib/spring/client/binstub.rb,
lib/spring/client/command.rb,
lib/spring/client/version.rb,
lib/spring/commands/rails.rb,
lib/spring/command_wrapper.rb,
lib/spring/failsafe_thread.rb,
lib/spring/watcher/polling.rb,
lib/spring/watcher/abstract.rb,
lib/spring/application_manager.rb,
lib/spring/process_title_updater.rb

Overview

Defined Under Namespace

Modules: Client, Commands, JSON, OkJson, Watcher Classes: Application, ApplicationManager, ClientError, CommandNotFound, CommandWrapper, Env, MissingApplication, ProcessTitleUpdater, Server, UnknownProject

Constant Summary collapse

IGNORE_SIGNALS =
%w(INT QUIT)
STOP_TIMEOUT =

seconds

2
ORIGINAL_ENV =
ENV.to_hash
VERSION =
"4.2.1"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.application_rootObject

Returns the value of attribute application_root.



8
9
10
# File 'lib/spring/configuration.rb', line 8

def application_root
  @application_root
end

.boot_timeoutObject

Returns the value of attribute boot_timeout.



8
9
10
# File 'lib/spring/configuration.rb', line 8

def boot_timeout
  @boot_timeout
end

.commandsObject (readonly)

Returns the value of attribute commands.



8
9
10
# File 'lib/spring/commands.rb', line 8

def commands
  @commands
end

.connect_timeoutObject

Returns the value of attribute connect_timeout.



8
9
10
# File 'lib/spring/configuration.rb', line 8

def connect_timeout
  @connect_timeout
end

.quietObject



67
68
69
# File 'lib/spring/configuration.rb', line 67

def quiet
  @quiet || ENV.key?('SPRING_QUIET')
end

.watch_intervalObject

Returns the value of attribute watch_interval.



6
7
8
# File 'lib/spring/watcher.rb', line 6

def watch_interval
  @watch_interval
end

.watch_methodObject

Returns the value of attribute watch_method.



8
9
10
# File 'lib/spring/watcher.rb', line 8

def watch_method
  @watch_method
end

.watcherObject



23
24
25
# File 'lib/spring/watcher.rb', line 23

def self.watcher
  @watcher ||= watch_method.new(Spring.application_root_path, watch_interval)
end

Class Method Details

.after_fork(&block) ⇒ Object



34
35
36
# File 'lib/spring/configuration.rb', line 34

def after_fork(&block)
  after_fork_callbacks << block
end

.after_fork_callbacksObject



30
31
32
# File 'lib/spring/configuration.rb', line 30

def after_fork_callbacks
  @after_fork_callbacks ||= []
end

.application_root_pathObject



50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/spring/configuration.rb', line 50

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

.command(name) ⇒ Object



19
20
21
# File 'lib/spring/commands.rb', line 19

def self.command(name)
  commands.fetch name
end

.command?(name) ⇒ Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/spring/commands.rb', line 15

def self.command?(name)
  commands.include? name
end

.failsafe_threadObject



5
6
7
8
9
10
11
12
# File 'lib/spring/failsafe_thread.rb', line 5

def failsafe_thread
  Thread.new {
    begin
      yield
    rescue
    end
  }
end

.gemfileObject



11
12
13
14
15
16
17
18
19
# File 'lib/spring/configuration.rb', line 11

def gemfile
  require "bundler"

  if /\s1.9.[0-9]/ ===  Bundler.ruby_scope.gsub(/[\/\s]+/,'')
    Pathname.new(ENV["BUNDLE_GEMFILE"] || "Gemfile").expand_path
  else
    Bundler.default_gemfile
  end
end

.gemfile_lockObject



21
22
23
24
25
26
27
28
# File 'lib/spring/configuration.rb', line 21

def gemfile_lock
  case gemfile.to_s
  when /\bgems\.rb\z/
    gemfile.sub_ext('.locked')
  else
    gemfile.sub_ext('.lock')
  end
end

.project_root_pathObject



63
64
65
# File 'lib/spring/configuration.rb', line 63

def project_root_path
  @project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd)))
end

.register_command(name, command = nil) ⇒ Object



11
12
13
# File 'lib/spring/commands.rb', line 11

def self.register_command(name, command = nil)
  commands[name] = CommandWrapper.new(name, command)
end

.reset_on_envObject



42
43
44
# File 'lib/spring/configuration.rb', line 42

def reset_on_env
  @reset_on_env ||= []
end

.spawn_on_envObject



38
39
40
# File 'lib/spring/configuration.rb', line 38

def spawn_on_env
  @spawn_on_env ||= []
end

.verify_environmentObject



46
47
48
# File 'lib/spring/configuration.rb', line 46

def verify_environment
  application_root_path
end

.watch(*items) ⇒ Object



27
28
29
# File 'lib/spring/watcher.rb', line 27

def self.watch(*items)
  watcher.add(*items)
end