spring 2.1.1 → 3.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 +16 -8
- data/lib/spring/application.rb +10 -32
- data/lib/spring/env.rb +2 -2
- data/lib/spring/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b33b73bbbedd5ed08ff1c6de6d040faaf347cfae0b6cc41c5378a834f0cefc87
|
4
|
+
data.tar.gz: 6e9c1f79634653bbf9875e6786a5e5d1df38d13d2f0b47fff129ff7a804a663c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1e7c861899e73bec7b1dd623d0c486b66efdb257bc388caf10034dd11095f2feffa2695e09008d1669931f4e1c8d805c70ca7e403ea76431315f583d43664e37
|
7
|
+
data.tar.gz: 49587a245923eee35343818174edf141d2b687fb4b09cd9eeefe31c867848b03400cee41e98f2d5b35130d1b313c3f9b3433a557bfb5c5a20fc6fe4ae0822f7a
|
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 2.
|
20
|
-
* Rails versions:
|
19
|
+
* Ruby versions: MRI 2.5, MRI 2.6
|
20
|
+
* Rails versions: 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
|
@@ -65,6 +65,16 @@ 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.
|
67
67
|
|
68
|
+
### Enable reloading
|
69
|
+
|
70
|
+
Spring reloads application code, and therefore needs the application to have
|
71
|
+
reloading enabled.
|
72
|
+
|
73
|
+
Please, make sure `config.cache_classes` is `false` in the environments that
|
74
|
+
Spring manages. That setting is typically configured in
|
75
|
+
`config/environments/*.rb`. In particular, make sure it is `false` for the
|
76
|
+
`test` environment.
|
77
|
+
|
68
78
|
### Usage
|
69
79
|
|
70
80
|
For this walkthrough I've generated a new Rails application, and run
|
@@ -257,12 +267,10 @@ run through Spring, set the `DISABLE_SPRING` environment variable.
|
|
257
267
|
|
258
268
|
## Class reloading
|
259
269
|
|
260
|
-
Spring uses Rails' class reloading mechanism
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
have used this mechanism with your `test` environment before, and this
|
265
|
-
can cause problems.
|
270
|
+
Spring uses Rails' class reloading mechanism to keep your code up to date
|
271
|
+
between test runs. This is the same mechanism which allows you to see changes
|
272
|
+
during development when you refresh the page. However, you may never have used
|
273
|
+
this mechanism with your `test` environment before, and this can cause problems.
|
266
274
|
|
267
275
|
It's important to realise that code reloading means that the constants
|
268
276
|
in your application are *different objects* after files have changed:
|
data/lib/spring/application.rb
CHANGED
@@ -91,23 +91,21 @@ 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('
|
95
|
-
raise "Spring only supports Rails >=
|
94
|
+
unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('5.2.0')
|
95
|
+
raise "Spring only supports Rails >= 5.2.0"
|
96
96
|
end
|
97
97
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
|
99
|
+
if Rails.application.config.cache_classes
|
100
|
+
raise <<-MSG.strip_heredoc
|
101
|
+
Spring reloads, and therefore needs the application to have reloading enabled.
|
102
|
+
Please, set config.cache_classes to false in config/environments/#{Rails.env}.rb.
|
103
|
+
MSG
|
104
|
+
end
|
104
105
|
end
|
105
106
|
|
106
107
|
require Spring.application_root_path.join("config", "environment")
|
107
108
|
|
108
|
-
@original_cache_classes = Rails.application.config.cache_classes
|
109
|
-
Rails.application.config.cache_classes = false
|
110
|
-
|
111
109
|
disconnect_database
|
112
110
|
|
113
111
|
@preloaded = :success
|
@@ -163,20 +161,9 @@ module Spring
|
|
163
161
|
setup command
|
164
162
|
|
165
163
|
if Rails.application.reloaders.any?(&:updated?)
|
166
|
-
|
167
|
-
if defined? ActiveSupport::Reloader
|
168
|
-
Rails.application.reloader.reload!
|
169
|
-
else
|
170
|
-
ActionDispatch::Reloader.cleanup!
|
171
|
-
ActionDispatch::Reloader.prepare!
|
172
|
-
end
|
164
|
+
Rails.application.reloader.reload!
|
173
165
|
end
|
174
166
|
|
175
|
-
# Ensure we boot the process in the directory the command was called from,
|
176
|
-
# not from the directory Spring started in
|
177
|
-
original_dir = Dir.pwd
|
178
|
-
Dir.chdir(env['PWD'] || original_dir)
|
179
|
-
|
180
167
|
pid = fork {
|
181
168
|
Process.setsid
|
182
169
|
IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
|
@@ -203,14 +190,6 @@ module Spring
|
|
203
190
|
# Load in the current env vars, except those which *were* changed when Spring started
|
204
191
|
env.each { |k, v| ENV[k] ||= v }
|
205
192
|
|
206
|
-
# requiring is faster, so if config.cache_classes was true in
|
207
|
-
# the environment's config file, then we can respect that from
|
208
|
-
# here on as we no longer need constant reloading.
|
209
|
-
if @original_cache_classes
|
210
|
-
ActiveSupport::Dependencies.mechanism = :require
|
211
|
-
Rails.application.config.cache_classes = true
|
212
|
-
end
|
213
|
-
|
214
193
|
connect_database
|
215
194
|
srand
|
216
195
|
|
@@ -242,7 +221,6 @@ module Spring
|
|
242
221
|
# (i.e. to prevent `spring rake -T | grep db` from hanging forever),
|
243
222
|
# even when exception is raised before forking (i.e. preloading).
|
244
223
|
reset_streams
|
245
|
-
Dir.chdir(original_dir)
|
246
224
|
end
|
247
225
|
|
248
226
|
def terminate
|
data/lib/spring/env.rb
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
require "pathname"
|
2
|
-
require "fileutils"
|
3
2
|
require "digest/md5"
|
4
|
-
require "tmpdir"
|
5
3
|
|
6
4
|
require "spring/version"
|
7
5
|
require "spring/sid"
|
@@ -33,10 +31,12 @@ module Spring
|
|
33
31
|
end
|
34
32
|
|
35
33
|
def tmp_path
|
34
|
+
require "tmpdir"
|
36
35
|
path = Pathname.new(
|
37
36
|
ENV["SPRING_TMP_PATH"] ||
|
38
37
|
File.join(ENV['XDG_RUNTIME_DIR'] || Dir.tmpdir, "spring-#{Process.uid}")
|
39
38
|
)
|
39
|
+
require "fileutils"
|
40
40
|
FileUtils.mkdir_p(path) unless path.exist?
|
41
41
|
path
|
42
42
|
end
|
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:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jon Leighton
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-09-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -99,7 +99,7 @@ homepage: https://github.com/rails/spring
|
|
99
99
|
licenses:
|
100
100
|
- MIT
|
101
101
|
metadata: {}
|
102
|
-
post_install_message:
|
102
|
+
post_install_message:
|
103
103
|
rdoc_options: []
|
104
104
|
require_paths:
|
105
105
|
- lib
|
@@ -107,15 +107,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
107
107
|
requirements:
|
108
108
|
- - ">="
|
109
109
|
- !ruby/object:Gem::Version
|
110
|
-
version: 2.
|
110
|
+
version: 2.5.0
|
111
111
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
112
112
|
requirements:
|
113
113
|
- - ">="
|
114
114
|
- !ruby/object:Gem::Version
|
115
115
|
version: '0'
|
116
116
|
requirements: []
|
117
|
-
rubygems_version: 3.
|
118
|
-
signing_key:
|
117
|
+
rubygems_version: 3.2.22
|
118
|
+
signing_key:
|
119
119
|
specification_version: 4
|
120
120
|
summary: Rails application preloader
|
121
121
|
test_files: []
|