spring 4.0.0 → 4.1.1

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
2
  SHA256:
3
- metadata.gz: 9f13e2a4d08faffc1b15c2f1dfe801a3b0b6a12b80d7a66a39601e74ccf3feff
4
- data.tar.gz: 60c63476055ff6050668abfc79489f7c6fbbfc9a7b3a11ea998cb5b2ab86ef9a
3
+ metadata.gz: 557c3aebe1211983306061278ab800f1232e42d67a40bc4042c24560ff44409d
4
+ data.tar.gz: 6c1cdb2f00e1f7893d0fbf60b49d76d8841dd9c931dfa79c45387ddbec1bea5b
5
5
  SHA512:
6
- metadata.gz: 9c467ea15cea498f05ec7e5211bb014163e37a75557d9694e03cc4d6d6e94d4b62c6edcede752e61c4ff51accf472939150c7fc01901aab94cd60d4d06c8a8b1
7
- data.tar.gz: 6d363498591c949b3a49885c38d8694db924d9a2b24c2cc8499236d67739f4cb863eff5db114385bba8cb02bf996af48acd892cbf5e2edebe495bf3bdfffca93
6
+ metadata.gz: 1da8511a30a3802f6b96ce29b342e70bf136de411278624758a55b73140130902ad7e1afa488df1f48a06685b1980b0f5dd9b9185f27e36ec3d3ba43b9c27841
7
+ data.tar.gz: c05785038b3a2a048c2b6e9f95f0979561c292714029ec58da934f1cd5e139b3e66b3da9d917082717e83891ac922292f636b53183de580672325b52c58665a9
data/README.md CHANGED
@@ -18,6 +18,7 @@ boot it every time you run a test, rake task or migration.
18
18
 
19
19
  * Ruby versions: MRI 2.7, MRI 3.0, MRI 3.1
20
20
  * Rails versions: 6.0, 6.1, 7.0
21
+ * Bundler v2.1+
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).
@@ -70,11 +71,14 @@ Rails directory.
70
71
  Spring reloads application code, and therefore needs the application to have
71
72
  reloading enabled.
72
73
 
73
- Please, make sure `config.cache_classes` is `false` in the environments that
74
+ Ensure that `config.enable_reloading` is `true` in the environments that
74
75
  Spring manages. That setting is typically configured in
75
- `config/environments/*.rb`. In particular, make sure it is `false` for the
76
+ `config/environments/*.rb`. In particular, make sure it is `true` for the
76
77
  `test` environment.
77
78
 
79
+ Note: in versions of Rails before 7, the setting is called `cache_classes`,
80
+ and it needs to be `false` for Spring to work.
81
+
78
82
  ### Usage
79
83
 
80
84
  For this walkthrough I've generated a new Rails application, and run
@@ -388,6 +392,12 @@ a command runs:
388
392
  Spring.quiet = true
389
393
  ```
390
394
 
395
+ You can also set the initial state of the `quiet` configuration option to true
396
+ by setting the `SPRING_QUIET` environment variable before executing Spring.
397
+ This is useful if you want to set quiet mode when invoking the Spring executable
398
+ in a subprocess, and cannot or prefer not to set it programmatically
399
+ via the `Spring.quiet` option in `~/.spring.rb` or the app's `config/spring.rb`.
400
+
391
401
  ### Environment variables
392
402
 
393
403
  The following environment variables are used by Spring:
@@ -412,6 +422,8 @@ The following environment variables are used by Spring:
412
422
  the long-running Spring server process. By default, this is related to
413
423
  the socket path; if the socket path is `/foo/bar/spring.sock` the
414
424
  pidfile will be `/foo/bar/spring.pid`.
425
+ * `SPRING_QUIET` - If set, the initial state of the `Spring.quiet`
426
+ configuration option will default to `true`.
415
427
  * `SPRING_SERVER_COMMAND` - The command to run to start up the Spring
416
428
  server when it is not already running. Defaults to `spring _[version]_
417
429
  server --background`.
@@ -1,5 +1,4 @@
1
1
  require "spring/boot"
2
- require "set"
3
2
  require "pty"
4
3
 
5
4
  module Spring
@@ -128,7 +127,12 @@ module Spring
128
127
  end
129
128
 
130
129
  def eager_preload
131
- with_pty { preload }
130
+ with_pty do
131
+ # we can't see stderr and there could be issues when it's overflown
132
+ # see https://github.com/rails/spring/issues/396
133
+ STDERR.reopen("/dev/null")
134
+ preload
135
+ end
132
136
  end
133
137
 
134
138
  def run
@@ -298,9 +302,9 @@ module Spring
298
302
  Kernel.module_eval do
299
303
  old_raise = Kernel.method(:raise)
300
304
  remove_method :raise
301
- define_method :raise do |*args|
305
+ define_method :raise do |*args, **kwargs|
302
306
  begin
303
- old_raise.call(*args)
307
+ old_raise.call(*args, **kwargs)
304
308
  ensure
305
309
  if $!
306
310
  lib = File.expand_path("..", __FILE__)
@@ -93,7 +93,7 @@ module Spring
93
93
  def start_child(preload = false)
94
94
  @child, child_socket = UNIXSocket.pair
95
95
 
96
- Bundler.with_unbundled_env do
96
+ Bundler.with_original_env do
97
97
  bundler_dir = File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first)
98
98
  @pid = Process.spawn(
99
99
  {
@@ -1,5 +1,3 @@
1
- require 'set'
2
-
3
1
  module Spring
4
2
  module Client
5
3
  class Binstub < Command
@@ -1,5 +1,3 @@
1
- require "set"
2
-
3
1
  module Spring
4
2
  module Client
5
3
  class Rails < Command
@@ -22,7 +20,7 @@ module Spring
22
20
 
23
21
  if COMMANDS.include?(command_name)
24
22
  Run.call(["rails_#{command_name}", *args.drop(2)])
25
- elsif command_name.start_with?("db:")
23
+ elsif command_name&.start_with?("db:") && !command_name.start_with?("db:system")
26
24
  Run.call(["rake", *args.drop(1)])
27
25
  else
28
26
  require "spring/configuration"
@@ -28,9 +28,16 @@ module Spring
28
28
  config = File.expand_path("~/.spring.rb")
29
29
  require config if File.exist?(config)
30
30
 
31
- # If the config/spring.rb contains requires for commands from other gems,
32
- # then we need to be under bundler.
33
- require "bundler/setup"
31
+ # We force the TTY so bundler doesn't show a backtrace in case gems are missing.
32
+ old_env = ENV["BUNDLER_FORCE_TTY"]
33
+ ENV["BUNDLER_FORCE_TTY"] = "true"
34
+ begin
35
+ # If the config/spring.rb contains requires for commands from other gems,
36
+ # then we need to be under bundler.
37
+ require "bundler/setup"
38
+ ensure
39
+ ENV["BUNDLER_FORCE_TTY"] = old_env
40
+ end
34
41
 
35
42
  # Auto-require any Spring extensions which are in the Gemfile
36
43
  Gem::Specification.map(&:name).grep(/^spring-/).each do |command|
@@ -2,7 +2,8 @@ require "spring/errors"
2
2
 
3
3
  module Spring
4
4
  class << self
5
- attr_accessor :application_root, :quiet
5
+ attr_accessor :application_root
6
+ attr_writer :quiet
6
7
 
7
8
  def gemfile
8
9
  require "bundler"
@@ -52,6 +53,10 @@ module Spring
52
53
  @project_root_path ||= find_project_root(Pathname.new(File.expand_path(Dir.pwd)))
53
54
  end
54
55
 
56
+ def quiet
57
+ @quiet || ENV.key?('SPRING_QUIET')
58
+ end
59
+
55
60
  private
56
61
 
57
62
  def find_project_root(current_dir)
data/lib/spring/env.rb CHANGED
@@ -1,5 +1,4 @@
1
1
  require "pathname"
2
- require "digest/md5"
3
2
 
4
3
  require "spring/version"
5
4
  require "spring/configuration"
@@ -41,6 +40,7 @@ module Spring
41
40
  end
42
41
 
43
42
  def application_id
43
+ require "digest/md5"
44
44
  ENV["SPRING_APPLICATION_ID"] || Digest::MD5.hexdigest(RUBY_VERSION + project_root.to_s)
45
45
  end
46
46
 
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "4.0.0"
2
+ VERSION = "4.1.1"
3
3
  end
@@ -1,4 +1,3 @@
1
- require "set"
2
1
  require "pathname"
3
2
  require "mutex_m"
4
3
 
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.0.0
4
+ version: 4.1.1
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: 2021-12-10 00:00:00.000000000 Z
11
+ date: 2023-01-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -99,7 +99,7 @@ licenses:
99
99
  - MIT
100
100
  metadata:
101
101
  rubygems_mfa_required: 'true'
102
- post_install_message:
102
+ post_install_message:
103
103
  rdoc_options: []
104
104
  require_paths:
105
105
  - lib
@@ -114,8 +114,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  - !ruby/object:Gem::Version
115
115
  version: '0'
116
116
  requirements: []
117
- rubygems_version: 3.2.32
118
- signing_key:
117
+ rubygems_version: 3.1.2
118
+ signing_key:
119
119
  specification_version: 4
120
120
  summary: Rails application preloader
121
121
  test_files: []