spring 1.7.2 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +2 -1
- data/lib/spring/application.rb +10 -3
- data/lib/spring/binstub.rb +20 -0
- data/lib/spring/client/binstub.rb +4 -7
- data/lib/spring/test/acceptance_test.rb +14 -3
- data/lib/spring/test/application.rb +10 -3
- data/lib/spring/test/application_generator.rb +10 -10
- data/lib/spring/test/rails_version.rb +0 -17
- data/lib/spring/version.rb +1 -1
- data/lib/spring/watcher/polling.rb +2 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 492a555d7260fc775b233acca0a3fddfb2d20c88
|
4
|
+
data.tar.gz: ccfc69cc32e5105e3de6cb75ae19538d3958b44e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bb6d3f377d2004b10b01dcba207c2b1ec285f5e04d1721edc4ad436d6e50d99337d8ba584f08d5a99daf60ef06af853435a760edf467360a5a93919ec1d35ec
|
7
|
+
data.tar.gz: dea0ae70aa4e56ef9aeb525faa1350b711c1f90d87171ce1d530380469da3773b478285a50ab94b628cf6afb81e05237a8cc269cc09a1a3408275af59ff6db7c
|
data/README.md
CHANGED
@@ -17,7 +17,8 @@ boot it every time you run a test, rake task or migration.
|
|
17
17
|
## Compatibility
|
18
18
|
|
19
19
|
* Ruby versions: MRI 1.9.3, MRI 2.0, MRI 2.1, MRI 2.2
|
20
|
-
* Rails versions: 4.0
|
20
|
+
* Rails versions: 4.2, 5.0 (Spring is installed by default when you do
|
21
|
+
`rails new` to generate your application)
|
21
22
|
|
22
23
|
Spring makes extensive use of `Process.fork`, so won't be able to
|
23
24
|
provide a speed up on platforms which don't support forking (Windows, JRuby).
|
data/lib/spring/application.rb
CHANGED
@@ -192,7 +192,6 @@ module Spring
|
|
192
192
|
}
|
193
193
|
|
194
194
|
disconnect_database
|
195
|
-
reset_streams
|
196
195
|
|
197
196
|
log "forked #{pid}"
|
198
197
|
manager.puts pid
|
@@ -209,6 +208,11 @@ module Spring
|
|
209
208
|
|
210
209
|
client.puts(1) if pid
|
211
210
|
client.close
|
211
|
+
ensure
|
212
|
+
# Redirect STDOUT and STDERR to prevent from keeping the original FDs
|
213
|
+
# (i.e. to prevent `spring rake -T | grep db` from hanging forever),
|
214
|
+
# even when exception is raised before forking (i.e. preloading).
|
215
|
+
reset_streams
|
212
216
|
end
|
213
217
|
|
214
218
|
def terminate
|
@@ -292,8 +296,11 @@ module Spring
|
|
292
296
|
PTY.open do |master, slave|
|
293
297
|
[STDOUT, STDERR, STDIN].each { |s| s.reopen slave }
|
294
298
|
Thread.new { master.read }
|
295
|
-
|
296
|
-
|
299
|
+
begin
|
300
|
+
yield
|
301
|
+
ensure
|
302
|
+
reset_streams
|
303
|
+
end
|
297
304
|
end
|
298
305
|
end
|
299
306
|
|
data/lib/spring/binstub.rb
CHANGED
@@ -1,6 +1,26 @@
|
|
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
|
+
|
4
24
|
if command == "spring"
|
5
25
|
load bin_path
|
6
26
|
else
|
@@ -23,10 +23,6 @@ CODE
|
|
23
23
|
# binstub from the application process. Which means that in the application
|
24
24
|
# process we'll execute the lines which come after the LOADER block, which
|
25
25
|
# is what we want.
|
26
|
-
#
|
27
|
-
# Parsing the lockfile in this way is pretty nasty but reliable enough
|
28
|
-
# The regex ensures that the match must be between a GEM line and an empty
|
29
|
-
# line, so it won't go on to the next section.
|
30
26
|
SPRING = <<'CODE'
|
31
27
|
#!/usr/bin/env ruby
|
32
28
|
|
@@ -37,9 +33,10 @@ unless defined?(Spring)
|
|
37
33
|
require 'rubygems'
|
38
34
|
require 'bundler'
|
39
35
|
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
|
37
|
+
if spring = lockfile.specs.detect { |spec| spec.name == "spring" }
|
38
|
+
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
39
|
+
gem 'spring', spring.version
|
43
40
|
require 'spring/binstub'
|
44
41
|
end
|
45
42
|
end
|
@@ -12,7 +12,7 @@ module Spring
|
|
12
12
|
DEFAULT_SPEEDUP = 0.8
|
13
13
|
|
14
14
|
def rails_version
|
15
|
-
ENV['RAILS_VERSION'] || '~>
|
15
|
+
ENV['RAILS_VERSION'] || '~> 5.0.0'
|
16
16
|
end
|
17
17
|
|
18
18
|
# Extension point for spring-watchers-listen
|
@@ -121,7 +121,7 @@ module Spring
|
|
121
121
|
assert_speedup do
|
122
122
|
assert_success app.spring_test_command, stdout: "0 failures"
|
123
123
|
|
124
|
-
|
124
|
+
app.insert_into_test "raise 'omg'"
|
125
125
|
assert_failure app.spring_test_command, stdout: "RuntimeError: omg"
|
126
126
|
end
|
127
127
|
end
|
@@ -156,7 +156,7 @@ module Spring
|
|
156
156
|
end
|
157
157
|
end
|
158
158
|
RUBY
|
159
|
-
|
159
|
+
app.insert_into_test "Foo.omg"
|
160
160
|
|
161
161
|
app.await_reload
|
162
162
|
assert_failure app.spring_test_command, stdout: "RuntimeError: omg"
|
@@ -415,6 +415,12 @@ module Spring
|
|
415
415
|
assert_failure "bin/rake -T", stderr: "unable to find your config/application.rb"
|
416
416
|
end
|
417
417
|
|
418
|
+
test "piping with boot-level error" do
|
419
|
+
config = app.application_config.read
|
420
|
+
File.write(app.application_config, "#{config}\nomg")
|
421
|
+
assert_success "bin/rake -T | cat"
|
422
|
+
end
|
423
|
+
|
418
424
|
test "piping" do
|
419
425
|
assert_success "bin/rake -T | grep db", stdout: "rake db:migrate"
|
420
426
|
end
|
@@ -534,6 +540,11 @@ module Spring
|
|
534
540
|
|
535
541
|
assert_failure "bin/rails runner ''", stderr: "timed out"
|
536
542
|
end
|
543
|
+
|
544
|
+
test "no warnings are shown for unsprung commands" do
|
545
|
+
app.env["DISABLE_SPRING"] = "1"
|
546
|
+
refute_output_includes "bin/rails runner ''", stderr: "WARN"
|
547
|
+
end
|
537
548
|
end
|
538
549
|
end
|
539
550
|
end
|
@@ -65,7 +65,7 @@ module Spring
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def spring_test_command
|
68
|
-
"
|
68
|
+
"bin/rake test #{test}"
|
69
69
|
end
|
70
70
|
|
71
71
|
def stop_spring
|
@@ -74,7 +74,7 @@ module Spring
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def test
|
77
|
-
path "test
|
77
|
+
path "test/controllers/posts_controller_test.rb"
|
78
78
|
end
|
79
79
|
|
80
80
|
def controller
|
@@ -205,10 +205,17 @@ module Spring
|
|
205
205
|
end
|
206
206
|
|
207
207
|
def bundle
|
208
|
-
|
208
|
+
# Version restriction is a workaround for https://github.com/bundler/bundler/pull/4981
|
209
|
+
# The problem breaks our tests on Ruby 2.2
|
210
|
+
# We can remove once it's fixed
|
211
|
+
run! "(gem list bundler | grep bundler) || gem install bundler --version '~> 1.12.0'", timeout: nil, retry: 2
|
209
212
|
run! "bundle check || bundle update --retry=2", timeout: nil
|
210
213
|
end
|
211
214
|
|
215
|
+
def insert_into_test(code)
|
216
|
+
File.write(test, test.read.sub(/^\s*get .+$/, code))
|
217
|
+
end
|
218
|
+
|
212
219
|
private
|
213
220
|
|
214
221
|
def process_alive?(pid)
|
@@ -38,13 +38,17 @@ module Spring
|
|
38
38
|
|
39
39
|
# Sporadic SSL errors keep causing test failures so there are anti-SSL workarounds here
|
40
40
|
def generate_files
|
41
|
+
if RUBY_VERSION == "1.9.3"
|
42
|
+
system("gem list '^mime-types$' --installed --version '~> 2' || " \
|
43
|
+
"gem install mime-types --clear-sources --source http://rubygems.org --version '~> 2'")
|
44
|
+
end
|
45
|
+
|
41
46
|
system("gem list '^rails$' --installed --version '#{version_constraint}' || " \
|
42
47
|
"gem install rails --clear-sources --source http://rubygems.org --version '#{version_constraint}'")
|
43
48
|
|
44
49
|
@version = RailsVersion.new(`ruby -e 'puts Gem::Specification.find_by_name("rails", "#{version_constraint}").version'`.chomp)
|
45
50
|
|
46
|
-
skips = %w(--skip-bundle --skip-javascript --skip-sprockets)
|
47
|
-
skips << "--skip-spring" if version.bundles_spring?
|
51
|
+
skips = %w(--skip-bundle --skip-javascript --skip-sprockets --skip-spring)
|
48
52
|
|
49
53
|
system("rails _#{version}_ new #{application.root} #{skips.join(' ')}")
|
50
54
|
raise "application generation failed" unless application.exists?
|
@@ -55,14 +59,6 @@ module Spring
|
|
55
59
|
|
56
60
|
append_to_file(application.gemfile, "gem 'spring', '#{Spring::VERSION}'")
|
57
61
|
|
58
|
-
if version.needs_testunit?
|
59
|
-
append_to_file(application.gemfile, "gem 'spring-commands-testunit'")
|
60
|
-
end
|
61
|
-
|
62
|
-
if RUBY_VERSION == "1.9.3"
|
63
|
-
append_to_file(application.gemfile, "gem 'mime-types', '~> 2'")
|
64
|
-
end
|
65
|
-
|
66
62
|
rewrite_file(application.gemfile) do |c|
|
67
63
|
c.sub!("https://rubygems.org", "http://rubygems.org")
|
68
64
|
c.gsub!(/(gem '(byebug|web-console|sdoc|jbuilder)')/, "# \\1")
|
@@ -90,6 +86,10 @@ module Spring
|
|
90
86
|
def install_spring
|
91
87
|
return if @installed
|
92
88
|
|
89
|
+
if RUBY_VERSION < "2.2.2"
|
90
|
+
application.run! "gem install activesupport --version '#{version}'"
|
91
|
+
end
|
92
|
+
|
93
93
|
build_and_install_gems
|
94
94
|
|
95
95
|
application.bundle
|
@@ -7,23 +7,6 @@ module Spring
|
|
7
7
|
@version = Gem::Version.new(string)
|
8
8
|
end
|
9
9
|
|
10
|
-
def rails_3?
|
11
|
-
version < Gem::Version.new("4.0.0")
|
12
|
-
end
|
13
|
-
alias needs_testunit? rails_3?
|
14
|
-
|
15
|
-
def test_command
|
16
|
-
needs_testunit? ? 'bin/testunit' : 'bin/rake test'
|
17
|
-
end
|
18
|
-
|
19
|
-
def controller_tests_dir
|
20
|
-
rails_3? ? 'functional' : 'controllers'
|
21
|
-
end
|
22
|
-
|
23
|
-
def bundles_spring?
|
24
|
-
version.segments.take(2) == [4, 1] || version > Gem::Version.new("4.1")
|
25
|
-
end
|
26
|
-
|
27
10
|
def major
|
28
11
|
version.segments[0]
|
29
12
|
end
|
data/lib/spring/version.rb
CHANGED
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spring
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.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: 2016-
|
11
|
+
date: 2016-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.2
|
20
|
-
type: :
|
19
|
+
version: '4.2'
|
20
|
+
type: :runtime
|
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: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|