yabeda-puma-plugin 0.2.0 → 0.2.1

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: 12d2eced94a7f0365f65189ef0002ae70d555e5c9fa02a5c3a9692f6b8a8ae65
4
- data.tar.gz: 232a6e796501204873651b557439cc6ecdd525b2688b7fbf77059e7b41431a8a
3
+ metadata.gz: d0254def10fec3276511c89a605d243a7876631ab06ffc4131adc135e4011939
4
+ data.tar.gz: f059a562c744164c2549b8e826ea793803eff702565d564df1599669695ffa9b
5
5
  SHA512:
6
- metadata.gz: 6f7d371011d50c329ccdd0e16da01291b07cff94da8825ea9b378c98d1d103a3a2c162b22bdff8e412c5b693b056b4d04b8c245b2b73b0e7fffeac174668ee6d
7
- data.tar.gz: 519e7962f993e9f64d4d58a3db2c9c4bf377802c286216700d8d5b6508689afc21622e3a75ebd44ace6ae534dc1b59a0f8f465dbbabf324a191c6248b6a0a412
6
+ metadata.gz: 65fda3c0f40ef45b97c30463ec976735c134773b3da2177bf38e392867551ea1e3c057d710281fdb91e9effa1dc74d958e1d391464670100996c698e6f49aaf3
7
+ data.tar.gz: 439624ba8ec4c869a96781370d17be8ec22441d66b31b51b6b3bc42af0ba6ca0b27cb65e2496ba6b2b91bb55a2ef4d40547fce0b99a4b6bde4bbbf7dc0f425e7
@@ -9,24 +9,27 @@ module Yabeda
9
9
  def self.call
10
10
  control_url = Yabeda::Puma::Plugin.control_url
11
11
 
12
- if control_url.start_with? "unix://"
12
+ body = if control_url.start_with? "unix://"
13
13
  path = control_url.gsub("unix://", '')
14
- sock = Socket.unix(path)
14
+ Socket.unix(path, &socket_block)
15
15
  elsif control_url.start_with? "tcp://"
16
16
  host, port = control_url.match(/^tcp:\/\/([a-z0-9\-._~%]+):([0-9]+)/).captures
17
-
18
- sock = Socket.tcp(host, port)
17
+ Socket.tcp(host, port, &socket_block)
19
18
  else
20
- raise ArgumentError("Unknown puma control url type #{control_url}")
21
- end
22
-
23
- body = sock do |socket|
24
- socket << "GET /stats?token=#{Yabeda::Puma::Plugin.control_auth_token} HTTP/1.0\r\n\r\n"
25
- socket.read
19
+ raise ArgumentError.new("Unknown puma control url type #{control_url}")
26
20
  end
27
21
 
28
22
  JSON.parse(body.split("\n").last)
29
23
  end
24
+
25
+ private
26
+
27
+ def self.socket_block
28
+ Proc.new do |s|
29
+ s << "GET /stats?token=#{Yabeda::Puma::Plugin.control_auth_token} HTTP/1.0\r\n\r\n"
30
+ s.read
31
+ end
32
+ end
30
33
  end
31
34
  end
32
35
  end
@@ -1,7 +1,7 @@
1
1
  module Yabeda
2
2
  module Puma
3
3
  module Plugin
4
- VERSION = "0.2.0"
4
+ VERSION = "0.2.1"
5
5
  end
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: yabeda-puma-plugin
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Salahutdinov Dmitry
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-12-12 00:00:00.000000000 Z
11
+ date: 2019-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: yabeda