puma_dynamic_tags 0.1.0 → 0.2.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: ee74951e2533774c1d0569c9a03c6fad6e9c27233381642dd606a1a6e4109452
4
- data.tar.gz: 541012449a729831dfcf61b852f9d7f1b8dc0953c407eca45e9a8d5fd2c87a52
3
+ metadata.gz: 896b5ec11fd097860d01664a585115609cd4e92ea51f1ceb2b75eeae54a71de2
4
+ data.tar.gz: ed002a412487ef4521aff2b19c5e5e56754239ed8d9aaedb5d64fa9efc82744e
5
5
  SHA512:
6
- metadata.gz: 84e983b29c92ed3f03d162530a3bdff84054b50569f3580e8446a9044589448a56b8e13106b4d8e70ee817f218548d17fd7e5ee7567a92df140126adae9b2d58
7
- data.tar.gz: 22791f612fd01e096db680f8a0ec2486b127d4313982e4f2a5ff657533b4b09632e548ba72a21e95c9cd8448d8d111f741b39e9141a79fda3b388ff750fc183e
6
+ metadata.gz: 69a2a369fd9deb6ce68e60810f66621e2b7abe91f4e8e625711273ed560b0b21cafca1fbe5c9100ba86012ecd69ff25b7a5c323be512d340955f299c3e1f52f2
7
+ data.tar.gz: 232ec0741d9dbd51335973446f523c5941710a9841744a10483f871f5104a49824a38664bc26cb96457a2c320ef8e1387733c88982aa9860cbcb82d97d3c2abd
data/.gitignore CHANGED
@@ -9,3 +9,4 @@
9
9
 
10
10
  # rspec failure tracking
11
11
  .rspec_status
12
+ *.gem
data/CHANGELOG.md CHANGED
@@ -1,6 +1,18 @@
1
1
  # Changelog
2
2
  All notable changes to this project will be documented in this file.
3
3
 
4
+ ## [0.2.0] - 2022-04-08
5
+
6
+ - Initial release
7
+
8
+ ## [0.1.2] - 2022-04-08
9
+
10
+ - Initial release
11
+
12
+ ## [0.1.1] - 2022-04-08
13
+
14
+ - Initial release
15
+
4
16
  ## [0.1.0] - 2022-04-08
5
17
 
6
18
  - Initial release
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- puma_dynamic_tags (0.1.0)
4
+ puma_dynamic_tags (0.2.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -87,7 +87,7 @@ PLATFORMS
87
87
  arm64-darwin-21
88
88
 
89
89
  DEPENDENCIES
90
- armitage-rubocop (>= 1.26.1.1)
90
+ armitage-rubocop (~> 1.26)
91
91
  bundler (~> 2.3)
92
92
  pry (~> 0.14)
93
93
  puma_dynamic_tags!
data/README.md CHANGED
@@ -19,20 +19,56 @@ bundle install
19
19
 
20
20
  ## Usage
21
21
 
22
+ Setup your puma application:
23
+
22
24
  ```ruby
23
- # in your gem requirements
24
- require "puma_dynamic_tags"
25
+ # config.ru
26
+
27
+ # (example)
28
+ require "sinatra"
29
+ run Sinatra::Application
25
30
  ```
26
31
 
32
+ Enable `dynamic_tags` plugin and configure dynamic `tag` option:
33
+
27
34
  ```ruby
28
35
  # config/puma.rb
29
- plugin :puma_dynamic_tags
36
+ plugin "dynamic_tags"
37
+
38
+ # and now you can use dynamic tags:
30
39
 
31
40
  tag do
32
- # your dynamic code
41
+ "some_dynamic_result: #{Time.now}" # your dynamic code
33
42
  end
34
43
  ```
35
44
 
45
+ and then:
46
+
47
+ ```shell
48
+ # run your puma in your favorite mode
49
+ bundle exec puma -t 8:32 -w 3
50
+ ```
51
+
52
+ and then (check your process names):
53
+
54
+ ```shell
55
+ puma 5.6.4 (tcp://0.0.0.0:9292) [some_dynamic_result: 2022-04-08 03:01:04 +0300] # <--- dynamic process name
56
+ puma: cluster worker 2: 38624 [some_dynamic_result: 2022-04-08 03:02:50 +0300] # <--- dynamic process name
57
+ puma: cluster worker 1: 38624 [some_dynamic_result: 2022-04-08 03:02:50 +0300] # <--- dynamic process name
58
+ puma: cluster worker 0: 38624 [some_dynamic_result: 2022-04-08 03:02:50 +0300] # <--- dynamic process name
59
+ ```
60
+
61
+ and then (run phase-restart and check recalculated process names with your dynamic tag):
62
+
63
+ ```shell
64
+ puma 5.6.4 (tcp://0.0.0.0:9292) [some_dynamic_result: 2022-04-08 03:01:04 +0300] # <--- each tag has been recalculated
65
+ puma: cluster worker 2: 38624 [some_dynamic_result: 2022-04-08 03:03:25 +0300] # <--- each tag has been recalculated
66
+ puma: cluster worker 1: 38624 [some_dynamic_result: 2022-04-08 03:03:25 +0300] # <--- each tag has been recalculated
67
+ puma: cluster worker 0: 38624 [some_dynamic_result: 2022-04-08 03:03:25 +0300] # <--- each tag has been recalculated
68
+ ````
69
+
70
+ *Profit!*
71
+
36
72
  ## Contributing
37
73
 
38
74
  - Fork it ( https://github.com/0exp/puma_dynamic_tags )
@@ -6,10 +6,16 @@ module Puma::Plugin::DuynamicTags
6
6
  return super unless key == :tag
7
7
 
8
8
  tag_option = super
9
- tag_option = tag_opt.call.to_s if tag_opt.is_a?(::Proc)
9
+ tag_option = tag_option.call.to_s if tag_option.is_a?(::Proc)
10
10
  tag_option
11
11
  end
12
12
  end
13
+
14
+ module DSLTagExtension
15
+ def tag(string = nil, &block)
16
+ @options[:tag] = block_given? ? block : string.to_s
17
+ end
18
+ end
13
19
  end
14
20
 
15
21
  Puma::Launcher.prepend(Module.new do
@@ -21,3 +27,5 @@ Puma::Launcher.prepend(Module.new do
21
27
  @options
22
28
  end
23
29
  end)
30
+
31
+ Puma::DSL.prepend(Puma::Plugin::DuynamicTags::DSLTagExtension)
@@ -0,0 +1,9 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Puma
4
+ class Plugin
5
+ module DuynamicTags
6
+ VERSION = '0.2.0'
7
+ end
8
+ end
9
+ end
@@ -1,3 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- Puma::Plugin.create { require_relative 'dynamic_tags/puma_patches' }
3
+ Puma::Plugin.create do
4
+ require_relative 'dynamic_tags/puma_patches'
5
+ require_relative 'dynamic_tags/version'
6
+ end
@@ -1,20 +1,22 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require_relative 'lib/puma/plugin/dynamic_tags/version'
4
+
3
5
  Gem::Specification.new do |spec|
4
6
  spec.required_ruby_version = '>= 2.6.0'
5
7
 
6
8
  spec.name = 'puma_dynamic_tags'
7
- spec.version = '0.1.0'
9
+ spec.version = Puma::Plugin::DuynamicTags::VERSION
8
10
  spec.authors = ['Rustam Ibragimov']
9
11
  spec.email = ['exfivedaiver@gmail.com']
10
12
  spec.homepage = 'https://github.com/0exp/puma_dynamic_tags'
11
13
  spec.license = 'MIT'
12
14
 
13
15
  spec.summary = <<~GEM_SUMMARY
14
- puma_dynamic_tags - allows you to use a dynamic tag option calculated by a proc.
16
+ puma_dynamic_tags - allows to use a dynamic tag puma's option calculated by a proc.
15
17
  GEM_SUMMARY
16
18
  spec.description = <<~GEM_DESCRIPTION
17
- puma_dynamic_tags - allows to use a dynamic tag option calculated by proc.
19
+ puma_dynamic_tags - allows to use a dynamic tag puma's option calculated by a proc.
18
20
  GEM_DESCRIPTION
19
21
 
20
22
  spec.metadata['homepage_uri'] = spec.homepage
@@ -29,7 +31,7 @@ Gem::Specification.new do |spec|
29
31
  spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
32
  spec.require_paths = ['lib']
31
33
 
32
- spec.add_development_dependency 'armitage-rubocop', '>= 1.26.1.1'
34
+ spec.add_development_dependency 'armitage-rubocop', '~> 1.26'
33
35
  spec.add_development_dependency 'bundler', '~> 2.3'
34
36
  spec.add_development_dependency 'rake', '~> 13.0'
35
37
  spec.add_development_dependency 'rspec', '~> 3.11'
metadata CHANGED
@@ -1,29 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma_dynamic_tags
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rustam Ibragimov
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2022-04-07 00:00:00.000000000 Z
11
+ date: 2022-04-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: armitage-rubocop
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 1.26.1.1
19
+ version: '1.26'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ">="
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 1.26.1.1
26
+ version: '1.26'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: bundler
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,8 +94,8 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0.14'
97
- description: 'puma_dynamic_tags - allows to use a dynamic tag option calculated by
98
- proc.
97
+ description: 'puma_dynamic_tags - allows to use a dynamic tag puma''s option calculated
98
+ by a proc.
99
99
 
100
100
  '
101
101
  email:
@@ -118,6 +118,7 @@ files:
118
118
  - bin/setup
119
119
  - lib/puma/plugin/dynamic_tags.rb
120
120
  - lib/puma/plugin/dynamic_tags/puma_patches.rb
121
+ - lib/puma/plugin/dynamic_tags/version.rb
121
122
  - puma_dynamic_tags.gemspec
122
123
  homepage: https://github.com/0exp/puma_dynamic_tags
123
124
  licenses:
@@ -144,6 +145,6 @@ requirements: []
144
145
  rubygems_version: 3.3.10
145
146
  signing_key:
146
147
  specification_version: 4
147
- summary: puma_dynamic_tags - allows you to use a dynamic tag option calculated by
148
- a proc.
148
+ summary: puma_dynamic_tags - allows to use a dynamic tag puma's option calculated
149
+ by a proc.
149
150
  test_files: []