rails-nginx 1.0.5 → 1.1.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: bbaec8277f134da5669ffbddbb1ff2711bafefa63cf7127a01ac913615fec65b
4
- data.tar.gz: 327cefb2c793ec50601b204c1132a5298268b078a3878b70bd1369a367eb145d
3
+ metadata.gz: f8d5a194f3c4e13cf96afe0ff92032d147bdf1b1547eb2005b8179f5c416f9ae
4
+ data.tar.gz: 92f5b4f5c6e4a555c275168a2b2c26a66ac12b7e3ade54469fab424d202b0bd9
5
5
  SHA512:
6
- metadata.gz: 7b8cb5b4d4b6fefd6f2bee6bfe0563604bb32f5a827defc97bcdecf0d55ed31e65a1d37976bdb46019feb4488870fc3ef70b4f94a42f09cb00ff1716ecdbdef2
7
- data.tar.gz: 36c7dfec4ba7f55dd8d76a9c11e159c7498428a71fda31af1b16d68dfa83b838da2aac66a474734b8a971681ba4f7df9e5eeb563f19363d56ee300254295ed68
6
+ metadata.gz: cef88d4facf475fa212f1dbb16ed0011061b5eb541efa8cb9ece8400d644c9f235097142156471ad8f9fd1443e025c4cebb0436f439046d7cb866d4e031f38b6
7
+ data.tar.gz: 1f3d3669700f109d9e9ab0f5ef28a34a52b7bd808d06df4c5b435982f82cf6169f3a0f8af70959f4a45b2ddc1b60d00554f2e6deab5f0634d1c7ef087a7fd896
data/README.md CHANGED
@@ -180,6 +180,13 @@ Run the Standard Ruby linter, and RSpec test suite.
180
180
  bundle exec rake
181
181
  ```
182
182
 
183
+ **OR**
184
+
185
+ Run the rake task through [Appraisal](https://github.com/thoughtbot/appraisal) to test against many Puma versions.
186
+ ```
187
+ bundle exec appraisal rake
188
+ ```
189
+
183
190
  #### Generating a new Dummy server
184
191
 
185
192
  There's a built-in executable if you'd like to generate a new Dummy server to upgrade the regression tests to work with the latest version of Rails.
@@ -0,0 +1,41 @@
1
+ module HooksWrapper
2
+ def booted(config, &)
3
+ if new_hooks?
4
+ config.after_booted(&)
5
+ else
6
+ config.on_booted(&)
7
+ end
8
+ end
9
+
10
+ def restarted(config, &)
11
+ if new_hooks?
12
+ config.before_restart(&)
13
+ else
14
+ config.on_restart(&)
15
+ end
16
+ end
17
+
18
+ def stopped(config, &)
19
+ return unless stopped_hook?
20
+
21
+ if new_hooks?
22
+ config.after_stopped(&)
23
+ else
24
+ config.on_stopped(&)
25
+ end
26
+ end
27
+
28
+ private
29
+
30
+ PUMA_VERSION = Gem::Version.new(Puma::Const::PUMA_VERSION)
31
+
32
+ def new_hooks?
33
+ # Puma renamed their hooks in v7.
34
+ Gem::Version.new("7.0.0") <= PUMA_VERSION
35
+ end
36
+
37
+ def stopped_hook?
38
+ # Puma v6.5 added on_stopped.
39
+ Gem::Version.new("6.5.0") <= PUMA_VERSION
40
+ end
41
+ end
@@ -1,6 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "puma/plugin"
4
+ require_relative "hooks_wrapper"
4
5
  require_relative "../../rails/nginx"
5
6
 
6
7
  # The Puma team recommends this approach to extend the Puma DSL.
@@ -27,13 +28,15 @@ def rails_port!
27
28
  end
28
29
 
29
30
  Puma::Plugin.create do
31
+ include HooksWrapper
32
+
30
33
  def config(puma_config)
31
34
  rails_port!
32
35
 
33
36
  puma_config.clear_binds!
34
37
  puma_config.port Rails::Nginx.port
35
38
 
36
- puma_config.on_booted do
39
+ booted(puma_config) do
37
40
  if puma_config.rails_nginx_configs.empty?
38
41
  Rails::Nginx.start!
39
42
  else
@@ -43,7 +46,7 @@ Puma::Plugin.create do
43
46
  end
44
47
  end
45
48
 
46
- puma_config.on_restart do
49
+ restarted(puma_config) do
47
50
  if puma_config.rails_nginx_configs.empty?
48
51
  Rails::Nginx.stop!
49
52
  Rails::Nginx.start!
@@ -55,14 +58,12 @@ Puma::Plugin.create do
55
58
  end
56
59
  end
57
60
 
58
- if defined?(puma_config.on_stopped)
59
- puma_config.on_stopped do
60
- if puma_config.rails_nginx_configs.empty?
61
- Rails::Nginx.stop!
62
- else
63
- puma_config.rails_nginx_configs.each_value do |options|
64
- Rails::Nginx.stop!(options)
65
- end
61
+ stopped(puma_config) do
62
+ if puma_config.rails_nginx_configs.empty?
63
+ Rails::Nginx.stop!
64
+ else
65
+ puma_config.rails_nginx_configs.each_value do |options|
66
+ Rails::Nginx.stop!(options)
66
67
  end
67
68
  end
68
69
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rails
4
4
  module Nginx
5
- VERSION = "1.0.5"
5
+ VERSION = "1.1.0"
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-nginx
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.5
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bert McCutchen
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-05-15 00:00:00.000000000 Z
11
+ date: 2025-10-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma
@@ -62,6 +62,7 @@ files:
62
62
  - CHANGELOG.md
63
63
  - LICENSE.txt
64
64
  - README.md
65
+ - lib/puma/plugin/hooks_wrapper.rb
65
66
  - lib/puma/plugin/rails_nginx.rb
66
67
  - lib/rails/nginx.rb
67
68
  - lib/rails/nginx/configuration.rb