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.1.0"

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.application_rootObject

Returns the value of attribute application_root.


5
6
7
# File 'lib/spring/configuration.rb', line 5

def application_root
  @application_root
end

.commandsObject (readonly)

Returns the value of attribute commands.


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

def commands
  @commands
end

.quietObject


56
57
58
# File 'lib/spring/configuration.rb', line 56

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


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

def after_fork(&block)
  after_fork_callbacks << block
end

.after_fork_callbacksObject


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

def after_fork_callbacks
  @after_fork_callbacks ||= []
end

.application_root_pathObject


39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/spring/configuration.rb', line 39

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


8
9
10
11
12
13
14
15
16
# File 'lib/spring/configuration.rb', line 8

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


18
19
20
21
22
23
24
25
# File 'lib/spring/configuration.rb', line 18

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


52
53
54
# File 'lib/spring/configuration.rb', line 52

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

.verify_environmentObject


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

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