puma-stats 1.0.2 → 1.0.3

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
  SHA1:
3
- metadata.gz: 6e2f11b40a93ab236070a96787e3a9b909addb2a
4
- data.tar.gz: df08c78e11651e9fc89f4f82e99af80cf0358570
3
+ metadata.gz: ef7fa50d902e1e9900d76b38a9e919edadf35e0d
4
+ data.tar.gz: 92e71ac20a28570fb41c735a531f5382684c53c5
5
5
  SHA512:
6
- metadata.gz: f6e15aeea9e7bcf4577a8ade84e1a33263be9a3ebf904782226e9c20dfba42baa3b7efbe3b152002f3682417fad0b6b3eca902d152caca74e0cc04dd7a8b3977
7
- data.tar.gz: 927c4d92836c138dbee212505ea4a8055afca49ba090f72ab7457f27d461f304f149c50e364335362837b0c9e012a2a1fce0c03adef4a957144e9e5e0ce86591
6
+ metadata.gz: 15765d516a6ba83f8deb42aad7bcd4aa04ec750be73523073f116866c886bb4d58939dc72fa819897f6cbb48adc308a706d47d4ac5a9029e4e63907fba2dd262
7
+ data.tar.gz: 22d21639ab1bafe316b34bbff6afaa86d41c25775cdc6bd7b5f2922f67bf15bb1c2d3ea53f4285daaae8337ab553dd62961d7e57ee6e861d3ae83b42468bba12
data/CHANGELOG.md CHANGED
@@ -1,5 +1,9 @@
1
1
  # Changelog
2
2
 
3
+ ## 1.0.3
4
+
5
+ Rubocop improvements.
6
+
3
7
  ## 1.0.2
4
8
 
5
9
  Do not redefine Puma::MiniSSL::ContextBuilder if already defined.
data/README.md CHANGED
@@ -27,17 +27,14 @@ Add following lines to your puma `config.rb` (see
27
27
  # config/puma.rb
28
28
 
29
29
  plugin 'stats'
30
-
31
- # Bind the stats server to "url". "tcp://" is the only accepted protocol.
32
- #
33
- # stats_url 'tcp://0.0.0.0:12345'
34
- # stats_token 'knockknock'
30
+ stats_url 'tcp://0.0.0.0:12345'
31
+ stats_token 'knockknock'
35
32
  ```
36
33
 
37
34
  ## Credits
38
35
 
39
36
  The gem is inspired by the following projects:
40
- * https://github.com/puma/puma-metrics
37
+ * https://github.com/harmjanblok/puma-metrics
41
38
 
42
39
  ## License
43
40
 
@@ -3,7 +3,6 @@
3
3
  require 'puma/stats/dsl'
4
4
 
5
5
  Puma::Plugin.create do
6
- # rubocop:disable Metrics/MethodLength, Metrics/AbcSize
7
6
  def start(launcher)
8
7
  str = launcher.options[:stats_url] || 'tcp://0.0.0.0:51209'
9
8
 
@@ -41,5 +40,4 @@ Puma::Plugin.create do
41
40
 
42
41
  stats.run
43
42
  end
44
- # rubocop:enable Metrics/MethodLength, Metrics/AbcSize
45
43
  end
@@ -11,19 +11,17 @@ module Puma
11
11
  end
12
12
 
13
13
  def call(env)
14
- unless authenticate(env)
15
- return rack_response(403, "Invalid stats auth token", 'text/plain')
16
- end
14
+ return rack_response(403, 'Invalid stats auth token', 'text/plain') unless authenticate(env)
17
15
 
18
16
  case env['PATH_INFO']
19
- when /\/puma-stats-gc$/
17
+ when %r{/puma-stats-gc$}
20
18
  rack_response(200, GC.stat.to_json)
21
19
 
22
- when /\/puma-stats$/
20
+ when %r{/puma-stats$}
23
21
  rack_response(200, @launcher.stats)
24
22
 
25
23
  else
26
- rack_response 404, "Unsupported request", 'text/plain'
24
+ rack_response 404, 'Unsupported request', 'text/plain'
27
25
  end
28
26
  end
29
27
 
@@ -31,12 +29,13 @@ module Puma
31
29
 
32
30
  def authenticate(env)
33
31
  return true unless @auth_token
32
+
34
33
  env['QUERY_STRING'].to_s.split(/&;/).include?("token=#{@auth_token}")
35
34
  end
36
35
 
37
- def rack_response(status, body, content_type='application/json')
36
+ def rack_response(status, body, content_type = 'application/json')
38
37
  headers = {
39
- 'Content-Type' => content_type,
38
+ 'Content-Type' => content_type,
40
39
  'Content-Length' => body.bytesize.to_s
41
40
  }
42
41
  [status, headers, [body]]
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Puma
4
4
  module Stats
5
- VERSION = '1.0.2'
5
+ VERSION = '1.0.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: puma-stats
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.2
4
+ version: 1.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tom Kishel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-12-03 00:00:00.000000000 Z
11
+ date: 2019-12-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: puma