bard-rails 0.4.1 → 0.4.2

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: 05c85885d68647a443684097db9512e3a44c83a1bcf25e9372c742b9fc466d98
4
- data.tar.gz: 2ab2adf0fb3a1d694afad5ffc9a432d93e1869ada77564d921ff1eb86140ab3f
3
+ metadata.gz: cd074739d617f0b5e094353e74f41b98ed81a760dceb6415a541d262164bd965
4
+ data.tar.gz: 6e3ffaab8cfbf714c45d76b42da27033132416deaa737bcd02b90b8a07b82eef
5
5
  SHA512:
6
- metadata.gz: 7ae0dd778aebb60f92ce0b56276f3ac40cda49dcb41501bc8da1abfd388c2bb59a9cbc1094904464b124172b128164d6b7de0e66ebc449bf58b9d9412290a44f
7
- data.tar.gz: d2606ca53d8575df74de8704483327c26e532298e1f4fa22c2217444d6620c2f817c2911331b55336c7133a2e8ee6fe0028ab69787a4ab173d6acb2223eb4da5
6
+ metadata.gz: c1dec730738e040b21073ce5f2a2151229329c21bc743a1eecc98c16d68eff310c9af3f2f2d26f599008e11b0ca202ca4bd7b5359346a10bbb75162529c81544
7
+ data.tar.gz: b3d78c5fc479ddb1875a94da43eaa626bbe6949c882e76940843af8f883e6498255f417a8069aa52ed1d47051ea619635ec5da1d0cf3ce590f5c6b34e60eb05e
data/.rspec ADDED
@@ -0,0 +1 @@
1
+ --require spec_helper
data/Gemfile CHANGED
@@ -6,3 +6,5 @@ source "https://rubygems.org"
6
6
  gemspec
7
7
 
8
8
  gem "rake", "~> 13.0"
9
+ gem "rspec", "~> 3.0"
10
+ gem "puma"
data/README.md CHANGED
@@ -12,6 +12,25 @@
12
12
  * labelled_form: some nice label shortcuts for the Rails form builder
13
13
  * rack-disable_css_animations: automatically remove CSS animations in the test environment, for more reliable tests
14
14
 
15
+ ## Choosing how to restart Puma on deploy
16
+
17
+ A phased restart (USR1) has no user impact, but it keeps the Puma master, so it can't pick up a new Ruby, a new Puma, a changed `config/puma.rb`, or a new version of any gem the master loaded. To let the master record what it booted with, add this to `config/puma.rb`:
18
+
19
+ ```ruby
20
+ extra_runtime_dependencies ["bard-rails"]
21
+ plugin :bard_rails
22
+ ```
23
+
24
+ Then ask which restart the deploy needs:
25
+
26
+ ```ruby
27
+ case Bard::RailsGem::PumaManifest.restart_kind
28
+ when :full then sh "systemctl --user restart app.target" # new Ruby, or no manifest yet
29
+ when :hot then sh "bin/server restart" # the master holds something that changed
30
+ when :phased then sh "systemctl --user reload app.target"
31
+ end
32
+ ```
33
+
15
34
  ## Installation
16
35
 
17
36
  Add this line to your application's Gemfile:
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
4
5
 
5
- task default: :build
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: %i[spec build]
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "version"
4
+
5
+ module Bard
6
+ module RailsGem
7
+ # Written inside puma's pruned master, so it may only use what that master has already loaded.
8
+ module PumaManifest
9
+ MANIFEST = "tmp/pids/puma.manifest"
10
+ BOOTED_CONFIG = "tmp/pids/puma.rb.booted"
11
+ CONFIG = "config/puma.rb"
12
+ private_constant :MANIFEST, :BOOTED_CONFIG, :CONFIG
13
+
14
+ def self.write
15
+ held = Gem.loaded_specs.to_h { |name, spec| [name, spec.version.to_s] }
16
+ held["puma"] = Puma::Const::PUMA_VERSION
17
+ held["nio4r"] = NIO::VERSION if defined?(NIO::VERSION)
18
+ held["bard-rails"] = VERSION
19
+ held["ruby"] = RUBY_VERSION
20
+ File.write MANIFEST, held.map { |name, version| "#{name} #{version}\n" }.join
21
+ File.write BOOTED_CONFIG, File.read(CONFIG)
22
+ end
23
+
24
+ def self.restart_kind(locked: Bundler.locked_gems.specs.to_h { |spec| [spec.name, spec.version.to_s] }, ruby: RUBY_VERSION)
25
+ return :full unless File.exist?(MANIFEST) && File.exist?(BOOTED_CONFIG)
26
+
27
+ held = File.readlines(MANIFEST, chomp: true).to_h(&:split)
28
+ return :full if held.fetch("ruby") != ruby
29
+ return :hot if File.read(BOOTED_CONFIG) != File.read(CONFIG)
30
+ return :hot if held.any? { |name, version| locked.fetch(name, version) != version }
31
+
32
+ :phased
33
+ end
34
+ end
35
+ end
36
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Bard
4
4
  module RailsGem # avoid messing with the "Rails" module name
5
- VERSION = "0.4.1"
5
+ VERSION = "0.4.2"
6
6
  end
7
7
  end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "puma/plugin"
4
+ require_relative "../../bard/rails/puma_manifest"
5
+
6
+ Puma::Plugin.create do
7
+ def config(dsl)
8
+ dsl.before_fork { Bard::RailsGem::PumaManifest.write }
9
+ end
10
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bard-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.1
4
+ version: 0.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Micah Geisel
@@ -183,6 +183,7 @@ executables: []
183
183
  extensions: []
184
184
  extra_rdoc_files: []
185
185
  files:
186
+ - ".rspec"
186
187
  - Gemfile
187
188
  - LICENSE.txt
188
189
  - README.md
@@ -192,9 +193,11 @@ files:
192
193
  - bin/setup
193
194
  - lib/bard-rails.rb
194
195
  - lib/bard/rails.rb
196
+ - lib/bard/rails/puma_manifest.rb
195
197
  - lib/bard/rails/railtie.rb
196
198
  - lib/bard/rails/test_storage.rb
197
199
  - lib/bard/rails/version.rb
200
+ - lib/puma/plugin/bard_rails.rb
198
201
  homepage: https://github.com/botandrose/bard-rails
199
202
  licenses:
200
203
  - MIT