spring 2.0.2 → 2.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 42ad763baaed56f6c7dd36b05566eec2e008481b
4
- data.tar.gz: 6f228d8ea63046f99353e83e732a72ef1900b0fd
2
+ SHA256:
3
+ metadata.gz: 239b79db86842dc2c1d0e6a82ac63a28425da6bdb199a09be37e3e6dfcb47fed
4
+ data.tar.gz: f1e458e7a273425bd93d12f7ab023b91164777b9051eb1da5be13d188d048399
5
5
  SHA512:
6
- metadata.gz: b049078c55028bbba601d2ca065fff5e3904cfd27b4ab6b719b7488e1bd044247cb88716126d46e5f26abb6296818d606b717ae4c0ad4c9c04726ff43e22c50e
7
- data.tar.gz: 12560b678ff15621efb6b479a443048330088f40ad328b920525785d59aa64064895565f96db5bb14801ce6c516106f3296ec8966a83b55142e915fa0df7bf74
6
+ metadata.gz: d79805cb44ca16a90556ffeb726b05323d719db51165b2279d269f0fc43292c9ae6510c766e02f7f86d509b3556bdfaa36985c363d64827ad092091923299a43
7
+ data.tar.gz: b8acb6feab70ddd8dbb337b9d8540e01a4f285fecee7ebeb15ce4fb43f666ce35376cad6286c1d91723f7f1c6e60055ce9c3bbac04174e8322452a120b894418
data/README.md CHANGED
@@ -16,8 +16,8 @@ boot it every time you run a test, rake task or migration.
16
16
 
17
17
  ## Compatibility
18
18
 
19
- * Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1, MRI 2.2
20
- * Rails versions: 4.2, 5.0 (Spring is installed by default when you do
19
+ * Ruby versions: MRI 2.4, MRI 2.5, MRI 2.6
20
+ * Rails versions: 4.2, 5.0, 5.1, 5.2, 6.0 (Spring is installed by default when you do
21
21
  `rails new` to generate your application)
22
22
 
23
23
  Spring makes extensive use of `Process.fork`, so won't be able to
@@ -27,14 +27,14 @@ provide a speed up on platforms which don't support forking (Windows, JRuby).
27
27
 
28
28
  ### Setup
29
29
 
30
- Add spring to your Gemfile:
30
+ Add Spring to your Gemfile:
31
31
 
32
32
  ``` ruby
33
33
  gem "spring", group: :development
34
34
  ```
35
35
 
36
36
  (Note: using `gem "spring", git: "..."` *won't* work and is not a
37
- supported way of using spring.)
37
+ supported way of using Spring.)
38
38
 
39
39
  It's recommended to 'springify' the executables in your `bin/`
40
40
  directory:
@@ -54,13 +54,13 @@ rescue LoadError
54
54
  end
55
55
  ```
56
56
 
57
- On platforms where spring is installed and supported, this snippet
58
- hooks spring into the execution of commands. In other cases, the snippet
57
+ On platforms where Spring is installed and supported, this snippet
58
+ hooks Spring into the execution of commands. In other cases, the snippet
59
59
  will just be silently ignored and the lines after it will be executed as
60
60
  normal.
61
61
 
62
62
  If you don't want to prefix every command you type with `bin/`, you
63
- can [use direnv](https://github.com/zimbatm/direnv#the-stdlib) to
63
+ can [use direnv](https://github.com/direnv/direnv#the-stdlib) to
64
64
  automatically add `./bin` to your `PATH` when you `cd` into your application.
65
65
  Simply create an `.envrc` file with the command `PATH_add bin` in your
66
66
  Rails directory.
@@ -90,7 +90,7 @@ user 0m0.281s
90
90
  sys 0m0.066s
91
91
  ```
92
92
 
93
- That wasn't particularly fast because it was the first run, so spring
93
+ That wasn't particularly fast because it was the first run, so Spring
94
94
  had to boot the application. It's now running:
95
95
 
96
96
  ```
@@ -167,7 +167,7 @@ Spring is running:
167
167
  26707 spring app | spring-demo-app | started 2 secs ago | development mode
168
168
  ```
169
169
 
170
- There's no need to "shut down" spring. This will happen automatically
170
+ There's no need to "shut down" Spring. This will happen automatically
171
171
  when you close your terminal. However if you do want to do a manual shut
172
172
  down, use the `stop` command:
173
173
 
@@ -176,9 +176,11 @@ $ bin/spring stop
176
176
  Spring stopped.
177
177
  ```
178
178
 
179
+ From within your code, you can check whether Spring is active with `if defined?(Spring)`.
180
+
179
181
  ### Removal
180
182
 
181
- To remove spring:
183
+ To remove Spring:
182
184
 
183
185
  * 'Unspring' your bin/ executables: `bin/spring binstub --remove --all`
184
186
  * Remove spring from your Gemfile
@@ -216,7 +218,7 @@ Spring::Commands::Rake.environment_matchers[:default] = "development"
216
218
  ### `rails console`, `rails generate`, `rails runner`
217
219
 
218
220
  These execute the rails command you already know and love. If you run
219
- a different sub command (e.g. `rails server`) then spring will automatically
221
+ a different sub command (e.g. `rails server`) then Spring will automatically
220
222
  pass it through to the underlying `rails` executable (without the
221
223
  speed-up).
222
224
 
@@ -233,15 +235,17 @@ You can add these to your Gemfile for additional commands:
233
235
  * [spring-commands-teaspoon](https://github.com/alejandrobabio/spring-commands-teaspoon.git)
234
236
  * [spring-commands-m](https://github.com/gabrieljoelc/spring-commands-m.git)
235
237
  * [spring-commands-rubocop](https://github.com/p0deje/spring-commands-rubocop)
238
+ * [spring-commands-rackup](https://github.com/wintersolutions/spring-commands-rackup)
239
+ * [spring-commands-rack-console](https://github.com/wintersolutions/spring-commands-rack-console)
236
240
 
237
241
  ## Use without adding to bundle
238
242
 
239
- If you don't want spring-related code checked into your source
240
- repository, it's possible to use spring without adding to your Gemfile.
241
- However, using spring binstubs without adding spring to the Gemfile is not
243
+ If you don't want Spring-related code checked into your source
244
+ repository, it's possible to use Spring without adding to your Gemfile.
245
+ However, using Spring binstubs without adding Spring to the Gemfile is not
242
246
  supported.
243
247
 
244
- To use spring like this, do a `gem install spring` and then prefix
248
+ To use Spring like this, do a `gem install spring` and then prefix
245
249
  commands with `spring`. For example, rather than running `bin/rake -T`,
246
250
  you'd run `spring rake -T`.
247
251
 
@@ -397,14 +401,14 @@ The following environment variables are used by Spring:
397
401
  the long-running Spring server process. By default this is related to
398
402
  the socket path; if the socket path is `/foo/bar/spring.sock` the
399
403
  pidfile will be `/foo/bar/spring.pid`.
400
- * `SPRING_SERVER_COMMAND` - The command to run to start up the spring
404
+ * `SPRING_SERVER_COMMAND` - The command to run to start up the Spring
401
405
  server when it is not already running. Defaults to `spring _[version]_
402
406
  server --background`.
403
407
 
404
408
  ## Troubleshooting
405
409
 
406
- If you want to get more information about what spring is doing, you can
407
- run spring explicitly in a separate terminal:
410
+ If you want to get more information about what Spring is doing, you can
411
+ run Spring explicitly in a separate terminal:
408
412
 
409
413
  ```
410
414
  $ spring server
@@ -91,6 +91,10 @@ module Spring
91
91
 
92
92
  require Spring.application_root_path.join("config", "application")
93
93
 
94
+ unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('4.2.0')
95
+ raise "Spring only supports Rails >= 4.2.0"
96
+ end
97
+
94
98
  # config/environments/test.rb will have config.cache_classes = true. However
95
99
  # we want it to be false so that we can reload files. This is a hack to
96
100
  # override the effect of config.cache_classes = true. We can then actually
@@ -147,7 +151,7 @@ module Spring
147
151
  log "got client"
148
152
  manager.puts
149
153
 
150
- stdout, stderr, stdin = streams = 3.times.map { client.recv_io }
154
+ _stdout, stderr, _stdin = streams = 3.times.map { client.recv_io }
151
155
  [STDOUT, STDERR, STDIN].zip(streams).each { |a, b| a.reopen(b) }
152
156
 
153
157
  preload unless preloaded?
@@ -173,15 +177,25 @@ module Spring
173
177
  IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
174
178
  trap("TERM", "DEFAULT")
175
179
 
176
- STDERR.puts "Running via Spring preloader in process #{Process.pid}" unless Spring.quiet
180
+ unless Spring.quiet
181
+ STDERR.puts "Running via Spring preloader in process #{Process.pid}"
182
+
183
+ if Rails.env.production?
184
+ STDERR.puts "WARNING: Spring is running in production. To fix " \
185
+ "this make sure the spring gem is only present " \
186
+ "in `development` and `test` groups in your Gemfile " \
187
+ "and make sure you always use " \
188
+ "`bundle install --without development test` in production"
189
+ end
190
+ end
177
191
 
178
192
  ARGV.replace(args)
179
193
  $0 = command.exec_name
180
194
 
181
- # Delete all env vars which are unchanged from before spring started
195
+ # Delete all env vars which are unchanged from before Spring started
182
196
  original_env.each { |k, v| ENV.delete k if ENV[k] == v }
183
197
 
184
- # Load in the current env vars, except those which *were* changed when spring started
198
+ # Load in the current env vars, except those which *were* changed when Spring started
185
199
  env.each { |k, v| ENV[k] ||= v }
186
200
 
187
201
  # requiring is faster, so if config.cache_classes was true in
@@ -7,6 +7,7 @@ module Spring
7
7
  @spring_env = spring_env
8
8
  @mutex = Mutex.new
9
9
  @state = :running
10
+ @pid = nil
10
11
  end
11
12
 
12
13
  def log(message)
@@ -92,7 +93,7 @@ module Spring
92
93
  def start_child(preload = false)
93
94
  @child, child_socket = UNIXSocket.pair
94
95
 
95
- Bundler.with_clean_env do
96
+ Bundler.with_original_env do
96
97
  @pid = Process.spawn(
97
98
  {
98
99
  "RAILS_ENV" => app_env,
@@ -1,26 +1,6 @@
1
1
  command = File.basename($0)
2
2
  bin_path = File.expand_path("../../../bin/spring", __FILE__)
3
3
 
4
- # When we run a command which does not go through Spring (e.g. DISABLE_SPRING
5
- # is used, or we just call 'rails' or something) then we get this warning from
6
- # Rubygems:
7
- #
8
- # WARN: Unresolved specs during Gem::Specification.reset: activesupport (<= 5.1, >= 4.2)
9
- # WARN: Clearing out unresolved specs.
10
- # Please report a bug if this causes problems.
11
- #
12
- # This happens due to our dependency on activesupport, when Bundler.setup gets
13
- # called. We don't actually *use* the dependency; it is purely there to
14
- # restrict the Rails version that we're compatible with.
15
- #
16
- # When the warning is shown, Rubygems just does the below.
17
- # Therefore, by doing it ourselves here, we can avoid the warning.
18
- if Gem::Specification.respond_to?(:unresolved_deps)
19
- Gem::Specification.unresolved_deps.clear
20
- else
21
- Gem.unresolved_deps.clear
22
- end
23
-
24
4
  if command == "spring"
25
5
  load bin_path
26
6
  else
@@ -3,11 +3,11 @@ require 'set'
3
3
  module Spring
4
4
  module Client
5
5
  class Binstub < Command
6
- SHEBANG = /\#\!.*\n/
6
+ SHEBANG = /\#\!.*\n(\#.*\n)*/
7
7
 
8
- # If loading the bin/spring file works, it'll run spring which will
8
+ # If loading the bin/spring file works, it'll run Spring which will
9
9
  # eventually call Kernel.exit. This means that in the client process
10
- # we will never execute the lines after this block. But if the spring
10
+ # we will never execute the lines after this block. But if the Spring
11
11
  # client is not invoked for whatever reason, then the Kernel.exit won't
12
12
  # happen, and so we'll fall back to the lines after this block, which
13
13
  # should cause the "unsprung" version of the command to run.
@@ -26,7 +26,7 @@ CODE
26
26
  SPRING = <<'CODE'
27
27
  #!/usr/bin/env ruby
28
28
 
29
- # This file loads spring without using Bundler, in order to be fast.
29
+ # This file loads Spring without using Bundler, in order to be fast.
30
30
  # It gets overwritten when you run the `spring binstub` command.
31
31
 
32
32
  unless defined?(Spring)
@@ -34,7 +34,7 @@ unless defined?(Spring)
34
34
  require 'bundler'
35
35
 
36
36
  lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
37
- spring = lockfile.specs.detect { |spec| spec.name == "spring" }
37
+ spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
38
38
  if spring
39
39
  Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
40
40
  gem 'spring', spring.version
@@ -46,11 +46,10 @@ CODE
46
46
  OLD_BINSTUB = %{if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?}
47
47
 
48
48
  BINSTUB_VARIATIONS = Regexp.union [
49
- %{begin\n load File.expand_path("../spring", __FILE__)\nrescue LoadError\nend\n},
50
49
  %{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError\nend\n},
51
50
  %{begin\n spring_bin_path = File.expand_path('../spring', __FILE__)\n load spring_bin_path\nrescue LoadError => e\n raise unless e.message.end_with? spring_bin_path, 'spring/binstub'\nend\n},
52
51
  LOADER
53
- ]
52
+ ].map { |binstub| /#{Regexp.escape(binstub).gsub("'", "['\"]")}/ }
54
53
 
55
54
  class Item
56
55
  attr_reader :command, :existing
@@ -79,7 +78,7 @@ CODE
79
78
  generate(fallback)
80
79
  status "upgraded"
81
80
  elsif existing.include?(LOADER)
82
- status "spring already present"
81
+ status "Spring already present"
83
82
  elsif existing =~ BINSTUB_VARIATIONS
84
83
  upgraded = existing.sub(BINSTUB_VARIATIONS, LOADER)
85
84
  File.write(command.binstub, upgraded)
@@ -94,15 +93,15 @@ CODE
94
93
  end
95
94
 
96
95
  File.write(command.binstub, "#{head}#{shebang}#{LOADER}#{tail}")
97
- status "spring inserted"
96
+ status "Spring inserted"
98
97
  else
99
- status "doesn't appear to be ruby, so cannot use spring", $stderr
98
+ status "doesn't appear to be ruby, so cannot use Spring", $stderr
100
99
  exit 1
101
100
  end
102
101
  end
103
102
  else
104
103
  generate
105
- status "generated with spring"
104
+ status "generated with Spring"
106
105
  end
107
106
  end
108
107
 
@@ -119,7 +118,7 @@ CODE
119
118
  def remove
120
119
  if existing
121
120
  File.write(command.binstub, existing.sub(BINSTUB_VARIATIONS, ""))
122
- status "spring removed"
121
+ status "Spring removed"
123
122
  end
124
123
  end
125
124
  end
@@ -127,7 +126,7 @@ CODE
127
126
  attr_reader :bindir, :items
128
127
 
129
128
  def self.description
130
- "Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert."
129
+ "Generate Spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert."
131
130
  end
132
131
 
133
132
  def self.rails_command
@@ -32,7 +32,7 @@ module Spring
32
32
  def formatted_help
33
33
  ["Version: #{env.version}\n",
34
34
  "Usage: spring COMMAND [ARGS]\n",
35
- *command_help("spring itself", spring_commands),
35
+ *command_help("Spring itself", spring_commands),
36
36
  '',
37
37
  *command_help("your application", application_commands)].join("\n")
38
38
  end
@@ -14,7 +14,7 @@ module Spring
14
14
  }
15
15
 
16
16
  def self.description
17
- "Run a rails command. The following sub commands will use spring: #{COMMANDS.to_a.join ', '}."
17
+ "Run a rails command. The following sub commands will use Spring: #{COMMANDS.to_a.join ', '}."
18
18
  end
19
19
 
20
20
  def call
@@ -44,7 +44,7 @@ module Spring
44
44
  require "spring/commands"
45
45
 
46
46
  if Spring.command?(args.first)
47
- # Command installed since spring started
47
+ # Command installed since Spring started
48
48
  stop_server
49
49
  cold_run
50
50
  else
@@ -116,7 +116,7 @@ module Spring
116
116
  def verify_server_version
117
117
  server_version = server.gets.chomp
118
118
  if server_version != env.version
119
- $stderr.puts "There is a version mismatch between the spring client " \
119
+ $stderr.puts "There is a version mismatch between the Spring client " \
120
120
  "(#{env.version}) and the server (#{server_version})."
121
121
 
122
122
  if server_booted?
@@ -161,6 +161,8 @@ module Spring
161
161
  if pid && !pid.empty?
162
162
  log "got pid: #{pid}"
163
163
 
164
+ suspend_resume_on_tstp_cont(pid)
165
+
164
166
  forward_signals(application)
165
167
  status = application.read.to_i
166
168
 
@@ -181,6 +183,18 @@ module Spring
181
183
  end
182
184
  end
183
185
 
186
+ def suspend_resume_on_tstp_cont(pid)
187
+ trap("TSTP") {
188
+ log "suspended"
189
+ Process.kill("STOP", pid.to_i)
190
+ Process.kill("STOP", Process.pid)
191
+ }
192
+ trap("CONT") {
193
+ log "resumed"
194
+ Process.kill("CONT", pid.to_i)
195
+ }
196
+ end
197
+
184
198
  def forward_signals(application)
185
199
  @signal_queue.each { |sig| kill sig, application }
186
200
 
@@ -4,7 +4,7 @@ module Spring
4
4
  module Client
5
5
  class Stop < Command
6
6
  def self.description
7
- "Stop all spring processes for this project."
7
+ "Stop all Spring processes for this project."
8
8
  end
9
9
 
10
10
  def call
@@ -32,7 +32,7 @@ module Spring
32
32
  # then we need to be under bundler.
33
33
  require "bundler/setup"
34
34
 
35
- # Auto-require any spring extensions which are in the Gemfile
35
+ # Auto-require any Spring extensions which are in the Gemfile
36
36
  Gem::Specification.map(&:name).grep(/^spring-/).each do |command|
37
37
  begin
38
38
  require command
@@ -24,7 +24,7 @@ module Spring
24
24
 
25
25
  def message
26
26
  "Spring was unable to find your config/application.rb file. " \
27
- "Your project root was detected at #{project_root}, so spring " \
27
+ "Your project root was detected at #{project_root}, so Spring " \
28
28
  "looked for #{project_root}/config/application.rb but it doesn't exist. You can " \
29
29
  "configure the root of your application by setting Spring.application_root in " \
30
30
  "config/spring.rb."
@@ -1,6 +1,6 @@
1
1
  module Spring
2
2
  # Yes, I know this reimplements a bunch of stuff in Active Support, but
3
- # I don't want the spring client to depend on AS, in order to keep its
3
+ # I don't want the Spring client to depend on AS, in order to keep its
4
4
  # load time down.
5
5
  class ProcessTitleUpdater
6
6
  SECOND = 1
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "2.0.2"
2
+ VERSION = "2.1.0"
3
3
  end
metadata CHANGED
@@ -1,31 +1,31 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spring
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 2.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Leighton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-05-21 00:00:00.000000000 Z
11
+ date: 2019-06-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: activesupport
14
+ name: rake
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.2'
20
- type: :runtime
19
+ version: '0'
20
+ type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - ">="
25
25
  - !ruby/object:Gem::Version
26
- version: '4.2'
26
+ version: '0'
27
27
  - !ruby/object:Gem::Dependency
28
- name: rake
28
+ name: bump
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
31
  - - ">="
@@ -39,7 +39,7 @@ dependencies:
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0'
41
41
  - !ruby/object:Gem::Dependency
42
- name: bump
42
+ name: activesupport
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
45
  - - ">="
@@ -91,12 +91,6 @@ files:
91
91
  - lib/spring/process_title_updater.rb
92
92
  - lib/spring/server.rb
93
93
  - lib/spring/sid.rb
94
- - lib/spring/test.rb
95
- - lib/spring/test/acceptance_test.rb
96
- - lib/spring/test/application.rb
97
- - lib/spring/test/application_generator.rb
98
- - lib/spring/test/rails_version.rb
99
- - lib/spring/test/watcher_test.rb
100
94
  - lib/spring/version.rb
101
95
  - lib/spring/watcher.rb
102
96
  - lib/spring/watcher/abstract.rb
@@ -113,15 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
113
107
  requirements:
114
108
  - - ">="
115
109
  - !ruby/object:Gem::Version
116
- version: '0'
110
+ version: 2.4.0
117
111
  required_rubygems_version: !ruby/object:Gem::Requirement
118
112
  requirements:
119
113
  - - ">="
120
114
  - !ruby/object:Gem::Version
121
115
  version: '0'
122
116
  requirements: []
123
- rubyforge_project:
124
- rubygems_version: 2.6.8
117
+ rubygems_version: 3.0.1
125
118
  signing_key:
126
119
  specification_version: 4
127
120
  summary: Rails application preloader