spring 1.0.0 → 1.3.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/.gitignore +1 -0
- data/.travis.yml +6 -1
- data/CHANGELOG.md +81 -0
- data/CONTRIBUTING.md +52 -0
- data/Gemfile +0 -2
- data/README.md +137 -54
- data/Rakefile +1 -1
- data/bin/spring +17 -0
- data/lib/spring/application/boot.rb +18 -0
- data/lib/spring/application.rb +183 -76
- data/lib/spring/application_manager.rb +54 -40
- data/lib/spring/binstub.rb +13 -0
- data/lib/spring/boot.rb +8 -0
- data/lib/spring/client/binstub.rb +150 -39
- data/lib/spring/client/help.rb +4 -12
- data/lib/spring/client/rails.rb +2 -3
- data/lib/spring/client/run.rb +69 -11
- data/lib/spring/client/status.rb +2 -2
- data/lib/spring/client/stop.rb +6 -21
- data/lib/spring/client/version.rb +11 -0
- data/lib/spring/client.rb +8 -5
- data/lib/spring/command_wrapper.rb +82 -0
- data/lib/spring/commands/rails.rb +44 -13
- data/lib/spring/commands/rake.rb +0 -4
- data/lib/spring/commands.rb +14 -4
- data/lib/spring/configuration.rb +11 -2
- data/lib/spring/env.rb +36 -10
- data/lib/spring/server.rb +9 -35
- data/lib/spring/sid.rb +1 -1
- data/lib/spring/test/acceptance_test.rb +346 -0
- data/lib/spring/test/application.rb +217 -0
- data/lib/spring/test/application_generator.rb +121 -0
- data/lib/spring/test/rails_version.rb +40 -0
- data/lib/spring/test/watcher_test.rb +167 -0
- data/lib/spring/test.rb +18 -0
- data/lib/spring/version.rb +1 -1
- data/lib/spring/watcher/abstract.rb +7 -8
- data/lib/spring/watcher/polling.rb +2 -0
- data/lib/spring/watcher.rb +4 -8
- data/spring.gemspec +2 -2
- data/test/acceptance_test.rb +4 -0
- data/test/helper.rb +2 -2
- data/test/unit/client/version_test.rb +14 -0
- data/test/unit/commands_test.rb +23 -1
- data/test/unit/watcher_test.rb +2 -184
- metadata +30 -17
- data/lib/spring/watcher/listen.rb +0 -52
- data/test/acceptance/app_test.rb +0 -511
data/test/unit/commands_test.rb
CHANGED
|
@@ -7,7 +7,17 @@ class CommandsTest < ActiveSupport::TestCase
|
|
|
7
7
|
assert_equal 'test', command.env(['test'])
|
|
8
8
|
end
|
|
9
9
|
|
|
10
|
-
test 'console command
|
|
10
|
+
test 'console command sets rails environment from -e option' do
|
|
11
|
+
command = Spring::Commands::RailsConsole.new
|
|
12
|
+
assert_equal 'test', command.env(['-e', 'test'])
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
test 'console command sets rails environment from --environment option' do
|
|
16
|
+
command = Spring::Commands::RailsConsole.new
|
|
17
|
+
assert_equal 'test', command.env(['--environment=test'])
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
test 'console command ignores first argument if it is a flag except -e and --environment' do
|
|
11
21
|
command = Spring::Commands::RailsConsole.new
|
|
12
22
|
assert_nil command.env(['--sandbox'])
|
|
13
23
|
end
|
|
@@ -27,6 +37,18 @@ class CommandsTest < ActiveSupport::TestCase
|
|
|
27
37
|
assert_nil command.env(['puts 1+1'])
|
|
28
38
|
end
|
|
29
39
|
|
|
40
|
+
test 'RailsRunner#extract_environment removes -e <env>' do
|
|
41
|
+
command = Spring::Commands::RailsRunner.new
|
|
42
|
+
args = ['-b', '-a', '-e', 'test', '-r']
|
|
43
|
+
assert_equal [['-b', '-a', '-r'], 'test'], command.extract_environment(args)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
test 'RailsRunner#extract_environment removes --environment=<env>' do
|
|
47
|
+
command = Spring::Commands::RailsRunner.new
|
|
48
|
+
args = ['-b', '--environment=test', '-a', '-r']
|
|
49
|
+
assert_equal [['-b', '-a', '-r'], 'test'], command.extract_environment(args)
|
|
50
|
+
end
|
|
51
|
+
|
|
30
52
|
test "rake command has configurable environments" do
|
|
31
53
|
command = Spring::Commands::Rake.new
|
|
32
54
|
assert_nil command.env(["foo"])
|
data/test/unit/watcher_test.rb
CHANGED
|
@@ -1,190 +1,8 @@
|
|
|
1
1
|
require "helper"
|
|
2
|
-
require "
|
|
3
|
-
require "fileutils"
|
|
4
|
-
require "active_support/core_ext/numeric/time"
|
|
5
|
-
require "spring/watcher"
|
|
2
|
+
require "spring/test/watcher_test"
|
|
6
3
|
require "spring/watcher/polling"
|
|
7
|
-
require "spring/watcher/listen"
|
|
8
|
-
|
|
9
|
-
module WatcherTests
|
|
10
|
-
LATENCY = 0.001
|
|
11
|
-
TIMEOUT = 1
|
|
12
|
-
|
|
13
|
-
attr_accessor :dir
|
|
14
|
-
|
|
15
|
-
def watcher
|
|
16
|
-
@watcher ||= watcher_class.new(dir, LATENCY)
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def setup
|
|
20
|
-
@dir = File.realpath(Dir.mktmpdir)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def teardown
|
|
24
|
-
FileUtils.remove_entry_secure @dir
|
|
25
|
-
watcher.stop
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
def touch(file, mtime = nil)
|
|
29
|
-
options = {}
|
|
30
|
-
options[:mtime] = mtime if mtime
|
|
31
|
-
FileUtils.touch(file, options)
|
|
32
|
-
end
|
|
33
|
-
|
|
34
|
-
def assert_stale
|
|
35
|
-
timeout = Time.now + TIMEOUT
|
|
36
|
-
sleep LATENCY until watcher.stale? || Time.now > timeout
|
|
37
|
-
assert watcher.stale?
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
def assert_not_stale
|
|
41
|
-
sleep LATENCY * 10
|
|
42
|
-
assert !watcher.stale?
|
|
43
|
-
end
|
|
44
|
-
|
|
45
|
-
def test_starting_with_no_file
|
|
46
|
-
file = "#{@dir}/omg"
|
|
47
|
-
touch file, Time.now - 2.seconds
|
|
48
|
-
|
|
49
|
-
watcher.start
|
|
50
|
-
watcher.add file
|
|
51
|
-
|
|
52
|
-
assert_not_stale
|
|
53
|
-
touch file, Time.now
|
|
54
|
-
assert_stale
|
|
55
|
-
end
|
|
56
|
-
|
|
57
|
-
def test_is_stale_when_a_watched_file_is_updated
|
|
58
|
-
file = "#{@dir}/omg"
|
|
59
|
-
touch file, Time.now - 2.seconds
|
|
60
|
-
|
|
61
|
-
watcher.add file
|
|
62
|
-
watcher.start
|
|
63
|
-
|
|
64
|
-
assert_not_stale
|
|
65
|
-
touch file, Time.now
|
|
66
|
-
assert_stale
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
def test_is_stale_when_removing_files
|
|
70
|
-
file = "#{@dir}/omg"
|
|
71
|
-
touch file, Time.now
|
|
72
|
-
|
|
73
|
-
watcher.add file
|
|
74
|
-
watcher.start
|
|
75
|
-
|
|
76
|
-
assert_not_stale
|
|
77
|
-
FileUtils.rm(file)
|
|
78
|
-
assert_stale
|
|
79
|
-
end
|
|
80
|
-
|
|
81
|
-
def test_is_stale_when_files_are_added_to_a_watched_directory
|
|
82
|
-
subdir = "#{@dir}/subdir"
|
|
83
|
-
FileUtils.mkdir(subdir)
|
|
84
|
-
|
|
85
|
-
watcher.add subdir
|
|
86
|
-
watcher.start
|
|
87
|
-
|
|
88
|
-
assert_not_stale
|
|
89
|
-
touch "#{subdir}/foo", Time.now - 1.minute
|
|
90
|
-
assert_stale
|
|
91
|
-
end
|
|
92
|
-
|
|
93
|
-
def test_is_stale_when_a_file_is_changed_in_a_watched_directory
|
|
94
|
-
subdir = "#{@dir}/subdir"
|
|
95
|
-
FileUtils.mkdir(subdir)
|
|
96
|
-
touch "#{subdir}/foo", Time.now - 1.minute
|
|
97
|
-
|
|
98
|
-
watcher.add subdir
|
|
99
|
-
watcher.start
|
|
100
|
-
|
|
101
|
-
assert_not_stale
|
|
102
|
-
touch "#{subdir}/foo", Time.now
|
|
103
|
-
assert_stale
|
|
104
|
-
end
|
|
105
|
-
|
|
106
|
-
def test_adding_doesnt_wipe_stale_state
|
|
107
|
-
file = "#{@dir}/omg"
|
|
108
|
-
file2 = "#{@dir}/foo"
|
|
109
|
-
touch file, Time.now - 2.seconds
|
|
110
|
-
touch file2, Time.now - 2.seconds
|
|
111
|
-
|
|
112
|
-
watcher.add file
|
|
113
|
-
watcher.start
|
|
114
|
-
|
|
115
|
-
assert_not_stale
|
|
116
|
-
|
|
117
|
-
touch file, Time.now
|
|
118
|
-
watcher.add file2
|
|
119
|
-
|
|
120
|
-
assert_stale
|
|
121
|
-
end
|
|
122
|
-
|
|
123
|
-
def test_can_io_select
|
|
124
|
-
file = "#{@dir}/omg"
|
|
125
|
-
touch file, Time.now - 2.seconds
|
|
126
|
-
|
|
127
|
-
watcher.add file
|
|
128
|
-
watcher.start
|
|
129
|
-
|
|
130
|
-
io = watcher.to_io
|
|
131
|
-
|
|
132
|
-
Thread.new {
|
|
133
|
-
sleep LATENCY * 3
|
|
134
|
-
touch file, Time.now
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
assert IO.select([io], [], [], 1), "IO.select timed out before watcher was readable"
|
|
138
|
-
assert watcher.stale?
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
def test_add_relative_path
|
|
142
|
-
File.write("#{dir}/foo", "foo")
|
|
143
|
-
watcher.add "foo"
|
|
144
|
-
assert_equal ["#{dir}/foo"], watcher.files.to_a
|
|
145
|
-
end
|
|
146
|
-
|
|
147
|
-
def test_add_dot_relative_path
|
|
148
|
-
File.write("#{dir}/foo", "foo")
|
|
149
|
-
watcher.add "./foo"
|
|
150
|
-
assert_equal ["#{dir}/foo"], watcher.files.to_a
|
|
151
|
-
end
|
|
152
|
-
|
|
153
|
-
def test_add_non_existant_file
|
|
154
|
-
watcher.add './foobar'
|
|
155
|
-
assert watcher.files.empty?
|
|
156
|
-
end
|
|
157
|
-
end
|
|
158
|
-
|
|
159
|
-
class ListenWatcherTest < ActiveSupport::TestCase
|
|
160
|
-
include WatcherTests
|
|
161
|
-
|
|
162
|
-
def watcher_class
|
|
163
|
-
Spring::Watcher::Listen
|
|
164
|
-
end
|
|
165
|
-
|
|
166
|
-
test "root directories" do
|
|
167
|
-
begin
|
|
168
|
-
other_dir_1 = File.realpath(Dir.mktmpdir)
|
|
169
|
-
other_dir_2 = File.realpath(Dir.mktmpdir)
|
|
170
|
-
File.write("#{other_dir_1}/foo", "foo")
|
|
171
|
-
File.write("#{dir}/foo", "foo")
|
|
172
|
-
|
|
173
|
-
watcher.add "#{other_dir_1}/foo"
|
|
174
|
-
watcher.add other_dir_2
|
|
175
|
-
watcher.add "#{dir}/foo"
|
|
176
|
-
|
|
177
|
-
assert_equal [dir, other_dir_1, other_dir_2].sort, watcher.base_directories.sort
|
|
178
|
-
ensure
|
|
179
|
-
FileUtils.rmdir other_dir_1
|
|
180
|
-
FileUtils.rmdir other_dir_2
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
end
|
|
184
|
-
|
|
185
|
-
class PollingWatcherTest < ActiveSupport::TestCase
|
|
186
|
-
include WatcherTests
|
|
187
4
|
|
|
5
|
+
class PollingWatcherTest < Spring::Test::WatcherTest
|
|
188
6
|
def watcher_class
|
|
189
7
|
Spring::Watcher::Polling
|
|
190
8
|
end
|
metadata
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: spring
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 1.
|
|
4
|
+
version: 1.3.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:
|
|
11
|
+
date: 2015-02-07 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:
|
|
19
|
+
version: 4.2.0
|
|
20
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:
|
|
26
|
+
version: 4.2.0
|
|
27
27
|
- !ruby/object:Gem::Dependency
|
|
28
28
|
name: rake
|
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
|
30
30
|
requirements:
|
|
31
|
-
- -
|
|
31
|
+
- - ">="
|
|
32
32
|
- !ruby/object:Gem::Version
|
|
33
33
|
version: '0'
|
|
34
34
|
type: :development
|
|
35
35
|
prerelease: false
|
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
|
37
37
|
requirements:
|
|
38
|
-
- -
|
|
38
|
+
- - ">="
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '0'
|
|
41
41
|
description: Rails application preloader
|
|
@@ -46,16 +46,20 @@ executables:
|
|
|
46
46
|
extensions: []
|
|
47
47
|
extra_rdoc_files: []
|
|
48
48
|
files:
|
|
49
|
-
- .gitignore
|
|
50
|
-
- .travis.yml
|
|
49
|
+
- ".gitignore"
|
|
50
|
+
- ".travis.yml"
|
|
51
51
|
- CHANGELOG.md
|
|
52
|
+
- CONTRIBUTING.md
|
|
52
53
|
- Gemfile
|
|
53
54
|
- LICENSE.txt
|
|
54
55
|
- README.md
|
|
55
56
|
- Rakefile
|
|
56
57
|
- bin/spring
|
|
57
58
|
- lib/spring/application.rb
|
|
59
|
+
- lib/spring/application/boot.rb
|
|
58
60
|
- lib/spring/application_manager.rb
|
|
61
|
+
- lib/spring/binstub.rb
|
|
62
|
+
- lib/spring/boot.rb
|
|
59
63
|
- lib/spring/client.rb
|
|
60
64
|
- lib/spring/client/binstub.rb
|
|
61
65
|
- lib/spring/client/command.rb
|
|
@@ -64,6 +68,8 @@ files:
|
|
|
64
68
|
- lib/spring/client/run.rb
|
|
65
69
|
- lib/spring/client/status.rb
|
|
66
70
|
- lib/spring/client/stop.rb
|
|
71
|
+
- lib/spring/client/version.rb
|
|
72
|
+
- lib/spring/command_wrapper.rb
|
|
67
73
|
- lib/spring/commands.rb
|
|
68
74
|
- lib/spring/commands/rails.rb
|
|
69
75
|
- lib/spring/commands/rake.rb
|
|
@@ -74,20 +80,26 @@ files:
|
|
|
74
80
|
- lib/spring/process_title_updater.rb
|
|
75
81
|
- lib/spring/server.rb
|
|
76
82
|
- lib/spring/sid.rb
|
|
83
|
+
- lib/spring/test.rb
|
|
84
|
+
- lib/spring/test/acceptance_test.rb
|
|
85
|
+
- lib/spring/test/application.rb
|
|
86
|
+
- lib/spring/test/application_generator.rb
|
|
87
|
+
- lib/spring/test/rails_version.rb
|
|
88
|
+
- lib/spring/test/watcher_test.rb
|
|
77
89
|
- lib/spring/version.rb
|
|
78
90
|
- lib/spring/watcher.rb
|
|
79
91
|
- lib/spring/watcher/abstract.rb
|
|
80
|
-
- lib/spring/watcher/listen.rb
|
|
81
92
|
- lib/spring/watcher/polling.rb
|
|
82
93
|
- spring.gemspec
|
|
83
|
-
- test/
|
|
94
|
+
- test/acceptance_test.rb
|
|
84
95
|
- test/apps/.gitignore
|
|
85
96
|
- test/helper.rb
|
|
86
97
|
- test/unit/client/help_test.rb
|
|
98
|
+
- test/unit/client/version_test.rb
|
|
87
99
|
- test/unit/commands_test.rb
|
|
88
100
|
- test/unit/process_title_updater_test.rb
|
|
89
101
|
- test/unit/watcher_test.rb
|
|
90
|
-
homepage: http://github.com/
|
|
102
|
+
homepage: http://github.com/rails/spring
|
|
91
103
|
licenses:
|
|
92
104
|
- MIT
|
|
93
105
|
metadata: {}
|
|
@@ -97,25 +109,26 @@ require_paths:
|
|
|
97
109
|
- lib
|
|
98
110
|
required_ruby_version: !ruby/object:Gem::Requirement
|
|
99
111
|
requirements:
|
|
100
|
-
- -
|
|
112
|
+
- - ">="
|
|
101
113
|
- !ruby/object:Gem::Version
|
|
102
114
|
version: '0'
|
|
103
115
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
104
116
|
requirements:
|
|
105
|
-
- -
|
|
117
|
+
- - ">="
|
|
106
118
|
- !ruby/object:Gem::Version
|
|
107
119
|
version: '0'
|
|
108
120
|
requirements: []
|
|
109
121
|
rubyforge_project:
|
|
110
|
-
rubygems_version: 2.
|
|
122
|
+
rubygems_version: 2.4.5
|
|
111
123
|
signing_key:
|
|
112
124
|
specification_version: 4
|
|
113
125
|
summary: Rails application preloader
|
|
114
126
|
test_files:
|
|
115
|
-
- test/
|
|
127
|
+
- test/acceptance_test.rb
|
|
116
128
|
- test/apps/.gitignore
|
|
117
129
|
- test/helper.rb
|
|
118
130
|
- test/unit/client/help_test.rb
|
|
131
|
+
- test/unit/client/version_test.rb
|
|
119
132
|
- test/unit/commands_test.rb
|
|
120
133
|
- test/unit/process_title_updater_test.rb
|
|
121
134
|
- test/unit/watcher_test.rb
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
gem "listen", "~> 1.0"
|
|
2
|
-
require "listen"
|
|
3
|
-
require "listen/version"
|
|
4
|
-
|
|
5
|
-
module Spring
|
|
6
|
-
module Watcher
|
|
7
|
-
class Listen < Abstract
|
|
8
|
-
attr_reader :listener
|
|
9
|
-
|
|
10
|
-
def start
|
|
11
|
-
unless @listener
|
|
12
|
-
@listener = ::Listen.to(*base_directories, relative_paths: false)
|
|
13
|
-
@listener.latency(latency)
|
|
14
|
-
@listener.change(&method(:changed))
|
|
15
|
-
@listener.start
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
def stop
|
|
20
|
-
if @listener
|
|
21
|
-
@listener.stop
|
|
22
|
-
@listener = nil
|
|
23
|
-
end
|
|
24
|
-
end
|
|
25
|
-
|
|
26
|
-
def subjects_changed
|
|
27
|
-
if @listener && @listener.directories.sort != base_directories.sort
|
|
28
|
-
restart
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def watching?(file)
|
|
33
|
-
files.include?(file) || file.start_with?(*directories)
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def changed(modified, added, removed)
|
|
37
|
-
synchronize do
|
|
38
|
-
if (modified + added + removed).any? { |f| watching? f }
|
|
39
|
-
mark_stale
|
|
40
|
-
end
|
|
41
|
-
end
|
|
42
|
-
end
|
|
43
|
-
|
|
44
|
-
def base_directories
|
|
45
|
-
([root] +
|
|
46
|
-
files.reject { |f| f.start_with? root }.map { |f| File.expand_path("#{f}/..") } +
|
|
47
|
-
directories.reject { |d| d.start_with? root }
|
|
48
|
-
).uniq
|
|
49
|
-
end
|
|
50
|
-
end
|
|
51
|
-
end
|
|
52
|
-
end
|