spring 3.1.1 → 4.0.0

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: 1f2e2dd87b67447e8ec1404be4f904fe1339e536dabddde397662313a7bb116d
4
- data.tar.gz: 467c115d0fff87ded2aa4a7d761419f74ce9b45798f12568e21d97e1b261599f
3
+ metadata.gz: 9f13e2a4d08faffc1b15c2f1dfe801a3b0b6a12b80d7a66a39601e74ccf3feff
4
+ data.tar.gz: 60c63476055ff6050668abfc79489f7c6fbbfc9a7b3a11ea998cb5b2ab86ef9a
5
5
  SHA512:
6
- metadata.gz: 3cc3b61d71972b7150fdbf7331ce1e55d447fabecbc4ba55914ce2621a9221fbb913efa31b715f80f77ff807dba06b3f89e26454ef623d8d2bc26af6b6f442a3
7
- data.tar.gz: b459527ad5f9301dd75b1e2f5c9d6e6418e7c019c3a0073a4c6e905b9118db5193bcad051bba88fd5f55cbf124037332ed6a940cd857e4c59d67127d02dbb951
6
+ metadata.gz: 9c467ea15cea498f05ec7e5211bb014163e37a75557d9694e03cc4d6d6e94d4b62c6edcede752e61c4ff51accf472939150c7fc01901aab94cd60d4d06c8a8b1
7
+ data.tar.gz: 6d363498591c949b3a49885c38d8694db924d9a2b24c2cc8499236d67739f4cb863eff5db114385bba8cb02bf996af48acd892cbf5e2edebe495bf3bdfffca93
data/README.md CHANGED
@@ -16,9 +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.5, MRI 2.6
20
- * Rails versions: 5.2, 6.0 (Spring is installed by default when you do
21
- `rails new` to generate your application)
19
+ * Ruby versions: MRI 2.7, MRI 3.0, MRI 3.1
20
+ * Rails versions: 6.0, 6.1, 7.0
22
21
 
23
22
  Spring makes extensive use of `Process.fork`, so won't be able to
24
23
  provide a speed up on platforms which don't support forking (Windows, JRuby).
@@ -11,8 +11,8 @@ module Spring
11
11
  @original_env = original_env
12
12
  @spring_env = spring_env
13
13
  @mutex = Mutex.new
14
- @waiting = Set.new
15
- @clients = Set.new
14
+ @waiting = {}
15
+ @clients = {}
16
16
  @preloaded = false
17
17
  @state = :initialized
18
18
  @interrupt = IO.pipe
@@ -92,8 +92,8 @@ module Spring
92
92
 
93
93
  require Spring.application_root_path.join("config", "application")
94
94
 
95
- unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('5.2.0')
96
- raise "Spring only supports Rails >= 5.2.0"
95
+ unless Rails.respond_to?(:gem_version) && Rails.gem_version >= Gem::Version.new('6.0.0')
96
+ raise "Spring only supports Rails >= 6.0.0"
97
97
  end
98
98
 
99
99
  Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
@@ -150,7 +150,7 @@ module Spring
150
150
  log "got client"
151
151
  manager.puts
152
152
 
153
- @clients << client
153
+ @clients[client] = true
154
154
 
155
155
  _stdout, stderr, _stdin = streams = 3.times.map { client.recv_io }
156
156
  [STDOUT, STDERR, STDIN].zip(streams).each { |a, b| a.reopen(b) }
@@ -181,7 +181,7 @@ module Spring
181
181
  pid = fork {
182
182
  # Make sure to close other clients otherwise their graceful termination
183
183
  # will be impossible due to reference from this fork.
184
- @clients.select { |c| c != client }.each(&:close)
184
+ @clients.each_key { |c| c.close if c != client }
185
185
 
186
186
  Process.setsid
187
187
  IGNORE_SIGNALS.each { |sig| trap(sig, "DEFAULT") }
@@ -245,7 +245,7 @@ module Spring
245
245
  if exiting?
246
246
  # Ensure that we do not ignore subsequent termination attempts
247
247
  log "forced exit"
248
- @waiting.each { |pid| Process.kill("TERM", pid) }
248
+ @waiting.each_key { |pid| Process.kill("TERM", pid) }
249
249
  Kernel.exit
250
250
  else
251
251
  state! :terminating
@@ -337,7 +337,7 @@ module Spring
337
337
  end
338
338
 
339
339
  def wait(pid, streams, client)
340
- @mutex.synchronize { @waiting << pid }
340
+ @mutex.synchronize { @waiting[pid] = true }
341
341
 
342
342
  # Wait in a separate thread so we can run multiple commands at once
343
343
  Spring.failsafe_thread {
@@ -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_original_env do
96
+ Bundler.with_unbundled_env do
97
97
  bundler_dir = File.expand_path("../..", $LOADED_FEATURES.grep(/bundler\/setup\.rb$/).first)
98
98
  @pid = Process.spawn(
99
99
  {
@@ -11,41 +11,36 @@ module Spring
11
11
  # client is not invoked for whatever reason, then the Kernel.exit won't
12
12
  # happen, and so we'll fall back to the lines after this block, which
13
13
  # should cause the "unsprung" version of the command to run.
14
- LOADER = <<CODE
15
- begin
16
- load File.expand_path('../spring', __FILE__)
17
- rescue LoadError => e
18
- raise unless e.message.include?('spring')
19
- end
20
- CODE
14
+ LOADER = <<~CODE
15
+ load File.expand_path("spring", __dir__)
16
+ CODE
21
17
 
22
18
  # The defined? check ensures these lines don't execute when we load the
23
19
  # binstub from the application process. Which means that in the application
24
20
  # process we'll execute the lines which come after the LOADER block, which
25
21
  # is what we want.
26
- SPRING = <<'CODE'
27
- #!/usr/bin/env ruby
28
-
29
- # This file loads Spring without using Bundler, in order to be fast.
30
- # It gets overwritten when you run the `spring binstub` command.
31
-
32
- unless defined?(Spring)
33
- require 'rubygems'
34
- require 'bundler'
35
-
36
- lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
37
- spring = lockfile.specs.detect { |spec| spec.name == 'spring' }
38
- if spring
39
- Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
40
- gem 'spring', spring.version
41
- require 'spring/binstub'
42
- end
43
- end
44
- CODE
22
+ SPRING = <<~CODE
23
+ #!/usr/bin/env ruby
24
+
25
+ # This file loads Spring without using loading other gems in the Gemfile, in order to be fast.
26
+ # It gets overwritten when you run the `spring binstub` command.
27
+
28
+ if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
29
+ require "bundler"
30
+
31
+ Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
32
+ Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
33
+ gem "spring", spring.version
34
+ require "spring/binstub"
35
+ end
36
+ end
37
+ CODE
45
38
 
46
39
  OLD_BINSTUB = %{if !Process.respond_to?(:fork) || Gem::Specification.find_all_by_name("spring").empty?}
47
40
 
48
41
  BINSTUB_VARIATIONS = Regexp.union [
42
+ %{load File.expand_path("spring", __dir__)\n},
43
+ %{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError => e\n raise unless e.message.include?('spring')\nend\n},
49
44
  %{begin\n load File.expand_path('../spring', __FILE__)\nrescue LoadError\nend\n},
50
45
  %{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},
51
46
  LOADER
@@ -146,7 +141,7 @@ CODE
146
141
  @mode = :add
147
142
  @items = args.drop(1)
148
143
  .map { |name| find_commands name }
149
- .inject(Set.new, :|)
144
+ .flatten.uniq
150
145
  .map { |command| Item.new(command) }
151
146
  end
152
147
 
@@ -3,7 +3,7 @@ require "set"
3
3
  module Spring
4
4
  module Client
5
5
  class Rails < Command
6
- COMMANDS = Set.new %w(console runner generate destroy test)
6
+ COMMANDS = %w(console runner generate destroy test)
7
7
 
8
8
  ALIASES = {
9
9
  "c" => "console",
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "3.1.1"
2
+ VERSION = "4.0.0"
3
3
  end
@@ -19,8 +19,8 @@ module Spring
19
19
 
20
20
  @root = File.realpath(root)
21
21
  @latency = latency
22
- @files = Set.new
23
- @directories = Set.new
22
+ @files = {}
23
+ @directories = {}
24
24
  @stale = false
25
25
  @listeners = []
26
26
 
@@ -63,10 +63,10 @@ module Spring
63
63
  synchronize {
64
64
  items.each do |item|
65
65
  if item.directory?
66
- directories << item.realpath.to_s
66
+ directories[item.realpath.to_s] = true
67
67
  else
68
68
  begin
69
- files << item.realpath.to_s
69
+ files[item.realpath.to_s] = true
70
70
  rescue Errno::ENOENT
71
71
  # Race condition. Ignore symlinks whose target was removed
72
72
  # since the check above, or are deeply chained.
@@ -91,7 +91,7 @@ module Spring
91
91
  end
92
92
 
93
93
  def expanded_files
94
- files + Dir["{#{directories.map { |d| "#{d}/**/*" }.join(",")}}"]
94
+ (files.keys + Dir["{#{directories.keys.map { |d| "#{d}/**/*" }.join(",")}}"]).uniq
95
95
  end
96
96
  end
97
97
  end
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: 3.1.1
4
+ version: 4.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: 2021-11-25 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -97,7 +97,8 @@ files:
97
97
  homepage: https://github.com/rails/spring
98
98
  licenses:
99
99
  - MIT
100
- metadata: {}
100
+ metadata:
101
+ rubygems_mfa_required: 'true'
101
102
  post_install_message:
102
103
  rdoc_options: []
103
104
  require_paths:
@@ -106,14 +107,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
106
107
  requirements:
107
108
  - - ">="
108
109
  - !ruby/object:Gem::Version
109
- version: 2.5.0
110
+ version: 2.7.0
110
111
  required_rubygems_version: !ruby/object:Gem::Requirement
111
112
  requirements:
112
113
  - - ">="
113
114
  - !ruby/object:Gem::Version
114
115
  version: '0'
115
116
  requirements: []
116
- rubygems_version: 3.2.22
117
+ rubygems_version: 3.2.32
117
118
  signing_key:
118
119
  specification_version: 4
119
120
  summary: Rails application preloader