spring 4.5.0 → 4.6.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 56e90e978202520c21d08823b1c539949f413ea8694868caec30042ede704533
4
- data.tar.gz: 34d0bf24260d460621ba8dfbb5be7f3750a3c3b0e4c20092878f38aa66aee1a4
3
+ metadata.gz: f386aff68c6b8feab1d79a933df930e6c47bf8d2f5f3610c7c483954e1b97cff
4
+ data.tar.gz: fb1ef130a243970266279570dad57c259ecd828cfab6b1043482ed429234e363
5
5
  SHA512:
6
- metadata.gz: b367e099835ce1cca3769b616905ac31a3d2a3ae7271b93031ebeb5cb95711735db2f3bc952541e0609197f0dc98fe3c03b0df36210fa6645ae5ff28a83c90a6
7
- data.tar.gz: 9c428924ba4c30c0cc5ee22e21da828b237ab686fee3d134519b16198127c3829288147b4eb056f3596c05efa46db2b7c3693f4e9a1a9c7bb362b7c020b34610
6
+ metadata.gz: da2a3fbbb088ca721ed27128e0a60be6b8946b519ae4580fb7c99cc76f3052063b24bbacce932db0212a9308094e1e392e7a7c6937526dc19d940c896c4c4a1d
7
+ data.tar.gz: d712161465b1217b783046ec10ad2694c65bf7897ab78cc7e97d1b6c33ae0a124dc949f9dd056755d5aaf40890c502ee617e3ad2338cbe8551731ae8c29b1774
data/README.md CHANGED
@@ -79,6 +79,31 @@ Spring manages. That setting is typically configured in
79
79
  Note: in versions of Rails before 7.1, the setting is called `cache_classes`,
80
80
  and it needs to be `false` for Spring to work.
81
81
 
82
+ #### Running Spring with reloading disabled (advanced, risky)
83
+
84
+ If you know what you are doing, and if every reloadable resource is configured
85
+ to materialize *lazily in the forked child*, not in the Spring server process,
86
+ then you can decide to run Spring without Rail's in-process reloaders.
87
+
88
+ To opt into this, set in `config/spring.rb`:
89
+
90
+ ```ruby
91
+ Spring.dangerously_allow_disabling_reloading = true
92
+ ```
93
+
94
+ If you set this, you should make sure that you are NOT pre-loading reloadable
95
+ resource in the Spring server. One approach is to add boot-time assertions at
96
+ the end of `Spring.after_environment_load`, e.g.:
97
+
98
+ ```ruby
99
+ Spring.after_environment_load do
100
+ raise "routes were drawn at boot" if Rails.application.routes_reloader.loaded
101
+ raise "i18n locales where loaded at boot" unless I18n.backend.instance_variable_get(:@translations).nil?
102
+ end
103
+ ```
104
+
105
+ When unsure, leave this disabled.
106
+
82
107
  ### Usage
83
108
 
84
109
  For this walkthrough I've generated a new Rails application, and run
@@ -101,6 +101,8 @@ module Spring
101
101
  end
102
102
 
103
103
  Rails::Application.initializer :ensure_reloading_is_enabled, group: :all do
104
+ next if Spring.dangerously_allow_disabling_reloading
105
+
104
106
  if Rails.application.config.cache_classes
105
107
  config_name, set_to = if Rails.application.config.respond_to?(:enable_reloading=)
106
108
  ["enable_reloading", "true"]
@@ -110,6 +112,8 @@ module Spring
110
112
  raise <<-MSG.strip_heredoc
111
113
  Spring reloads, and therefore needs the application to have reloading enabled.
112
114
  Please, set config.#{config_name} to #{set_to} in config/environments/#{Rails.env}.rb.
115
+ (If you understand the trade-offs and want to disable Rails' reloader anyway,
116
+ set `Spring.dangerously_allow_disabling_reloading = true` in config/spring.rb.)
113
117
  MSG
114
118
  end
115
119
  end
@@ -3,11 +3,17 @@ require "spring/errors"
3
3
  module Spring
4
4
  @connect_timeout = 5
5
5
  @boot_timeout = 20
6
+ @dangerously_allow_disabling_reloading = false
6
7
 
7
8
  class << self
8
9
  attr_accessor :application_root, :connect_timeout, :boot_timeout
9
10
  attr_writer :quiet
10
11
 
12
+ # Opt-in: skip the `:ensure_reloading_is_enabled` initializer so Spring
13
+ # boots with `config.enable_reloading = false`. Default `false`. See
14
+ # README "Running Spring with reloading disabled" for what this gives up.
15
+ attr_accessor :dangerously_allow_disabling_reloading
16
+
11
17
  def gemfile
12
18
  require "bundler"
13
19
 
@@ -1,3 +1,3 @@
1
1
  module Spring
2
- VERSION = "4.5.0"
2
+ VERSION = "4.6.0"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spring
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.5.0
4
+ version: 4.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jon Leighton