spring 1.4.0 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +4 -2
- data/lib/spring/client/binstub.rb +22 -10
- data/lib/spring/client/run.rb +1 -1
- data/lib/spring/env.rb +1 -1
- data/lib/spring/test/acceptance_test.rb +112 -2
- data/lib/spring/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 43523a4bc5efeee2b0627838cdad0f7792e878e1
|
|
4
|
+
data.tar.gz: d3c21eda879429eb8ff6765afba0dad6bc57046b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f18b77496d51c0612c180251f050b90591a5fd931e026ae11fef78dcc42ff11bdb460af2f7c3eeb365c1f91aa1e295e569f67a9037dbdb4df48fa87faaa7574d
|
|
7
|
+
data.tar.gz: 5cc676a8f1c2f1f2afd0c478cc5a541dbf9160df50a78903e67345ebfecd6521327b233cac349686f21e2bb124a9465509f57db51aa6b3dcf7adeee136e84c82
|
data/README.md
CHANGED
|
@@ -48,7 +48,7 @@ code into relevant existing executables. The snippet looks like this:
|
|
|
48
48
|
|
|
49
49
|
``` ruby
|
|
50
50
|
begin
|
|
51
|
-
load File.expand_path(
|
|
51
|
+
load File.expand_path('../spring', __FILE__)
|
|
52
52
|
rescue LoadError
|
|
53
53
|
end
|
|
54
54
|
```
|
|
@@ -227,6 +227,8 @@ You can add these to your Gemfile for additional commands:
|
|
|
227
227
|
running `Test::Unit` tests on Rails 3, since only Rails 4 allows you
|
|
228
228
|
to use `rake test path/to/test` to run a particular test/directory.
|
|
229
229
|
* [spring-commands-teaspoon](https://github.com/alejandrobabio/spring-commands-teaspoon.git)
|
|
230
|
+
* [spring-commands-m](https://github.com/gabrieljoelc/spring-commands-m.git)
|
|
231
|
+
* [spring-commands-rubocop](https://github.com/p0deje/spring-commands-rubocop)
|
|
230
232
|
|
|
231
233
|
## Use without adding to bundle
|
|
232
234
|
|
|
@@ -294,7 +296,7 @@ settings. Note that `~/.spring.rb` is loaded *before* bundler, but
|
|
|
294
296
|
projects without having to be added to the project's Gemfile, require
|
|
295
297
|
them in your `~/.spring.rb`.
|
|
296
298
|
|
|
297
|
-
`config/spring_client.rb` is also loaded before bundler and before a
|
|
299
|
+
`config/spring_client.rb` is also loaded before bundler and before a
|
|
298
300
|
server process is started, it can be used to add new top-level commands.
|
|
299
301
|
|
|
300
302
|
### Application root
|
|
@@ -13,8 +13,9 @@ module Spring
|
|
|
13
13
|
# should cause the "unsprung" version of the command to run.
|
|
14
14
|
LOADER = <<CODE
|
|
15
15
|
begin
|
|
16
|
-
load File.expand_path(
|
|
17
|
-
rescue LoadError
|
|
16
|
+
load File.expand_path('../spring', __FILE__)
|
|
17
|
+
rescue LoadError => e
|
|
18
|
+
raise unless e.message.include?('spring')
|
|
18
19
|
end
|
|
19
20
|
CODE
|
|
20
21
|
|
|
@@ -33,19 +34,26 @@ CODE
|
|
|
33
34
|
# It gets overwritten when you run the `spring binstub` command.
|
|
34
35
|
|
|
35
36
|
unless defined?(Spring)
|
|
36
|
-
require
|
|
37
|
-
require
|
|
37
|
+
require 'rubygems'
|
|
38
|
+
require 'bundler'
|
|
38
39
|
|
|
39
40
|
if (match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m))
|
|
40
|
-
Gem.paths = {
|
|
41
|
-
gem
|
|
42
|
-
require
|
|
41
|
+
Gem.paths = { 'GEM_PATH' => [Bundler.bundle_path.to_s, *Gem.path].uniq }
|
|
42
|
+
gem 'spring', match[1]
|
|
43
|
+
require 'spring/binstub'
|
|
43
44
|
end
|
|
44
45
|
end
|
|
45
46
|
CODE
|
|
46
47
|
|
|
47
48
|
OLD_BINSTUB = %{if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?}
|
|
48
49
|
|
|
50
|
+
BINSTUB_VARIATIONS = Regexp.union [
|
|
51
|
+
%{begin\n load File.expand_path("../spring", __FILE__)\nrescue LoadError\nend\n},
|
|
52
|
+
%{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError\nend\n},
|
|
53
|
+
%{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},
|
|
54
|
+
LOADER
|
|
55
|
+
]
|
|
56
|
+
|
|
49
57
|
class Item
|
|
50
58
|
attr_reader :command, :existing
|
|
51
59
|
|
|
@@ -72,8 +80,12 @@ CODE
|
|
|
72
80
|
fallback = nil if fallback.include?("exec")
|
|
73
81
|
generate(fallback)
|
|
74
82
|
status "upgraded"
|
|
75
|
-
elsif existing
|
|
83
|
+
elsif existing.include?(LOADER)
|
|
76
84
|
status "spring already present"
|
|
85
|
+
elsif existing =~ BINSTUB_VARIATIONS
|
|
86
|
+
upgraded = existing.sub(BINSTUB_VARIATIONS, LOADER)
|
|
87
|
+
File.write(command.binstub, upgraded)
|
|
88
|
+
status "upgraded"
|
|
77
89
|
else
|
|
78
90
|
head, shebang, tail = existing.partition(SHEBANG)
|
|
79
91
|
|
|
@@ -108,7 +120,7 @@ CODE
|
|
|
108
120
|
|
|
109
121
|
def remove
|
|
110
122
|
if existing
|
|
111
|
-
File.write(command.binstub, existing.sub(
|
|
123
|
+
File.write(command.binstub, existing.sub(BINSTUB_VARIATIONS, ""))
|
|
112
124
|
status "spring removed"
|
|
113
125
|
end
|
|
114
126
|
end
|
|
@@ -117,7 +129,7 @@ CODE
|
|
|
117
129
|
attr_reader :bindir, :items
|
|
118
130
|
|
|
119
131
|
def self.description
|
|
120
|
-
"Generate spring based binstubs. Use --all to generate a binstub for all known commands."
|
|
132
|
+
"Generate spring based binstubs. Use --all to generate a binstub for all known commands. Use --remove to revert."
|
|
121
133
|
end
|
|
122
134
|
|
|
123
135
|
def self.rails_command
|
data/lib/spring/client/run.rb
CHANGED
data/lib/spring/env.rb
CHANGED
|
@@ -33,7 +33,7 @@ module Spring
|
|
|
33
33
|
end
|
|
34
34
|
|
|
35
35
|
def tmp_path
|
|
36
|
-
path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring"))
|
|
36
|
+
path = Pathname.new(File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}"))
|
|
37
37
|
FileUtils.mkdir_p(path) unless path.exist?
|
|
38
38
|
path
|
|
39
39
|
end
|
|
@@ -208,14 +208,28 @@ module Spring
|
|
|
208
208
|
assert_success "bin/rake -T", stdout: "rake db:migrate"
|
|
209
209
|
end
|
|
210
210
|
|
|
211
|
-
test "binstub
|
|
211
|
+
test "binstub remove all" do
|
|
212
|
+
assert_success "bin/spring binstub --remove --all"
|
|
213
|
+
refute File.exist?(app.path("bin/spring"))
|
|
214
|
+
end
|
|
215
|
+
|
|
216
|
+
test "binstub when spring gem is missing" do
|
|
212
217
|
without_gem "spring-#{Spring::VERSION}" do
|
|
213
218
|
File.write(app.gemfile, app.gemfile.read.gsub(/gem 'spring.*/, ""))
|
|
214
219
|
assert_success "bin/rake -T", stdout: "rake db:migrate"
|
|
215
220
|
end
|
|
216
221
|
end
|
|
217
222
|
|
|
218
|
-
test "binstub
|
|
223
|
+
test "binstub when spring binary is missing" do
|
|
224
|
+
begin
|
|
225
|
+
File.rename(app.path("bin/spring"), app.path("bin/spring.bak"))
|
|
226
|
+
assert_success "bin/rake -T", stdout: "rake db:migrate"
|
|
227
|
+
ensure
|
|
228
|
+
File.rename(app.path("bin/spring.bak"), app.path("bin/spring"))
|
|
229
|
+
end
|
|
230
|
+
end
|
|
231
|
+
|
|
232
|
+
test "binstub upgrade with old binstub" do
|
|
219
233
|
File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
|
|
220
234
|
#!/usr/bin/env ruby
|
|
221
235
|
|
|
@@ -260,6 +274,102 @@ module Spring
|
|
|
260
274
|
assert_equal expected, app.path("bin/rails").read
|
|
261
275
|
end
|
|
262
276
|
|
|
277
|
+
test "binstub upgrade with new binstub variations" do
|
|
278
|
+
expected = <<-RUBY.gsub(/^ /, "")
|
|
279
|
+
#!/usr/bin/env ruby
|
|
280
|
+
#{Spring::Client::Binstub::LOADER.strip}
|
|
281
|
+
require 'bundler/setup'
|
|
282
|
+
load Gem.bin_path('rake', 'rake')
|
|
283
|
+
RUBY
|
|
284
|
+
|
|
285
|
+
# older variation with double quotes
|
|
286
|
+
File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
|
|
287
|
+
#!/usr/bin/env ruby
|
|
288
|
+
begin
|
|
289
|
+
load File.expand_path("../spring", __FILE__)
|
|
290
|
+
rescue LoadError
|
|
291
|
+
end
|
|
292
|
+
require 'bundler/setup'
|
|
293
|
+
load Gem.bin_path('rake', 'rake')
|
|
294
|
+
RUBY
|
|
295
|
+
|
|
296
|
+
assert_success "bin/spring binstub rake", stdout: "bin/rake: upgraded"
|
|
297
|
+
assert_equal expected, app.path("bin/rake").read
|
|
298
|
+
|
|
299
|
+
# newer variation with single quotes
|
|
300
|
+
File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
|
|
301
|
+
#!/usr/bin/env ruby
|
|
302
|
+
begin
|
|
303
|
+
load File.expand_path('../spring', __FILE__)
|
|
304
|
+
rescue LoadError
|
|
305
|
+
end
|
|
306
|
+
require 'bundler/setup'
|
|
307
|
+
load Gem.bin_path('rake', 'rake')
|
|
308
|
+
RUBY
|
|
309
|
+
|
|
310
|
+
assert_success "bin/spring binstub rake", stdout: "bin/rake: upgraded"
|
|
311
|
+
assert_equal expected, app.path("bin/rake").read
|
|
312
|
+
|
|
313
|
+
# newer variation which checks end of exception message
|
|
314
|
+
File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
|
|
315
|
+
#!/usr/bin/env ruby
|
|
316
|
+
begin
|
|
317
|
+
spring_bin_path = File.expand_path('../spring', __FILE__)
|
|
318
|
+
load spring_bin_path
|
|
319
|
+
rescue LoadError => e
|
|
320
|
+
raise unless e.message.end_with? spring_bin_path, 'spring/binstub'
|
|
321
|
+
end
|
|
322
|
+
require 'bundler/setup'
|
|
323
|
+
load Gem.bin_path('rake', 'rake')
|
|
324
|
+
RUBY
|
|
325
|
+
|
|
326
|
+
assert_success "bin/spring binstub rake", stdout: "bin/rake: upgraded"
|
|
327
|
+
assert_equal expected, app.path("bin/rake").read
|
|
328
|
+
end
|
|
329
|
+
|
|
330
|
+
test "binstub remove with new binstub variations" do
|
|
331
|
+
# older variation with double quotes
|
|
332
|
+
File.write(app.path("bin/rake"), <<-RUBY.strip_heredoc)
|
|
333
|
+
#!/usr/bin/env ruby
|
|
334
|
+
begin
|
|
335
|
+
load File.expand_path("../spring", __FILE__)
|
|
336
|
+
rescue LoadError
|
|
337
|
+
end
|
|
338
|
+
require 'bundler/setup'
|
|
339
|
+
load Gem.bin_path('rake', 'rake')
|
|
340
|
+
RUBY
|
|
341
|
+
|
|
342
|
+
# newer variation with single quotes
|
|
343
|
+
File.write(app.path("bin/rails"), <<-RUBY.strip_heredoc)
|
|
344
|
+
#!/usr/bin/env ruby
|
|
345
|
+
begin
|
|
346
|
+
load File.expand_path('../spring', __FILE__)
|
|
347
|
+
rescue LoadError
|
|
348
|
+
end
|
|
349
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
350
|
+
require_relative '../config/boot'
|
|
351
|
+
require 'rails/commands'
|
|
352
|
+
RUBY
|
|
353
|
+
|
|
354
|
+
assert_success "bin/spring binstub --remove rake", stdout: "bin/rake: spring removed"
|
|
355
|
+
assert_success "bin/spring binstub --remove rails", stdout: "bin/rails: spring removed"
|
|
356
|
+
|
|
357
|
+
expected = <<-RUBY.strip_heredoc
|
|
358
|
+
#!/usr/bin/env ruby
|
|
359
|
+
require 'bundler/setup'
|
|
360
|
+
load Gem.bin_path('rake', 'rake')
|
|
361
|
+
RUBY
|
|
362
|
+
assert_equal expected, app.path("bin/rake").read
|
|
363
|
+
|
|
364
|
+
expected = <<-RUBY.strip_heredoc
|
|
365
|
+
#!/usr/bin/env ruby
|
|
366
|
+
APP_PATH = File.expand_path('../../config/application', __FILE__)
|
|
367
|
+
require_relative '../config/boot'
|
|
368
|
+
require 'rails/commands'
|
|
369
|
+
RUBY
|
|
370
|
+
assert_equal expected, app.path("bin/rails").read
|
|
371
|
+
end
|
|
372
|
+
|
|
263
373
|
test "after fork callback" do
|
|
264
374
|
File.write(app.spring_config, "Spring.after_fork { puts '!callback!' }")
|
|
265
375
|
assert_success "bin/rails runner 'puts 2'", stdout: "!callback!\n2"
|
data/lib/spring/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spring
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.5.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: 2015-
|
|
11
|
+
date: 2015-11-30 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: activesupport
|
|
@@ -119,7 +119,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
119
119
|
version: '0'
|
|
120
120
|
requirements: []
|
|
121
121
|
rubyforge_project:
|
|
122
|
-
rubygems_version: 2.
|
|
122
|
+
rubygems_version: 2.4.5.1
|
|
123
123
|
signing_key:
|
|
124
124
|
specification_version: 4
|
|
125
125
|
summary: Rails application preloader
|