nginx_utils 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/nginx_utils/logrotate.rb +1 -0
- data/lib/nginx_utils/status.rb +15 -12
- data/lib/nginx_utils/version.rb +1 -1
- data/spec/nginx_utils/status_spec.rb +6 -6
- metadata +3 -3
data/lib/nginx_utils/status.rb
CHANGED
@@ -10,26 +10,29 @@ module NginxUtils
|
|
10
10
|
|
11
11
|
req = Net::HTTP::Get.new(path)
|
12
12
|
res = Net::HTTP.start(host, port){|http| http.request(req)}
|
13
|
-
parse res
|
13
|
+
parse res.body.split("\n").map{|l| l.split}
|
14
14
|
end
|
15
15
|
|
16
16
|
private
|
17
|
-
def parse(
|
18
|
-
|
19
|
-
|
17
|
+
def parse(spbody)
|
18
|
+
formexp([
|
19
|
+
spbody[0].last,
|
20
|
+
spbody[2],
|
21
|
+
spbody[3].select{|i| /^[0-9]*$/ =~ i}
|
22
|
+
].flatten.map{|i| i.to_i})
|
20
23
|
rescue
|
21
24
|
raise "Parse error"
|
22
25
|
end
|
23
26
|
|
24
|
-
def formexp(
|
27
|
+
def formexp(args)
|
25
28
|
{
|
26
|
-
active_connections:
|
27
|
-
accepts:
|
28
|
-
handled:
|
29
|
-
requests:
|
30
|
-
reading:
|
31
|
-
writing:
|
32
|
-
waiting:
|
29
|
+
active_connections: args[0],
|
30
|
+
accepts: args[1],
|
31
|
+
handled: args[2],
|
32
|
+
requests: args[3],
|
33
|
+
reading: args[4],
|
34
|
+
writing: args[5],
|
35
|
+
waiting: args[6]
|
33
36
|
}
|
34
37
|
end
|
35
38
|
end
|
data/lib/nginx_utils/version.rb
CHANGED
@@ -18,20 +18,20 @@ describe "NginxUtils::Status" do
|
|
18
18
|
|
19
19
|
describe ".parse" do
|
20
20
|
it "should return status hash" do
|
21
|
-
|
22
|
-
expect(NginxUtils::Status.send(:parse,
|
21
|
+
spbody = body.split("\n").map{|l| l.split}
|
22
|
+
expect(NginxUtils::Status.send(:parse, spbody)).to eq(status)
|
23
23
|
end
|
24
24
|
|
25
25
|
it "should generate an exception if parse failed" do
|
26
|
-
|
27
|
-
expect(proc{NginxUtils::Status.send(:parse,
|
26
|
+
spbody = "invalid content".split("\n").map{|l| l.split}
|
27
|
+
expect(proc{NginxUtils::Status.send(:parse, spbody)}).to raise_error(RuntimeError, "Parse error")
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
31
|
describe ".formexp" do
|
32
32
|
it "should return status hash with format" do
|
33
|
-
args =
|
34
|
-
expect(NginxUtils::Status.send(:formexp, args
|
33
|
+
args = [1, 4, 5, 51, 1, 3, 2]
|
34
|
+
expect(NginxUtils::Status.send(:formexp, args)).to eq(status)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nginx_utils
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -118,7 +118,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
118
118
|
version: '0'
|
119
119
|
segments:
|
120
120
|
- 0
|
121
|
-
hash: -
|
121
|
+
hash: -3985509799625259397
|
122
122
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
123
123
|
none: false
|
124
124
|
requirements:
|
@@ -127,7 +127,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: '0'
|
128
128
|
segments:
|
129
129
|
- 0
|
130
|
-
hash: -
|
130
|
+
hash: -3985509799625259397
|
131
131
|
requirements: []
|
132
132
|
rubyforge_project:
|
133
133
|
rubygems_version: 1.8.25
|