nginx_utils 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,22 +2,20 @@
2
2
 
3
3
  require "spec_helper"
4
4
 
5
- describe NginxUtils do
6
- describe "Status" do
7
- describe ".get" do
8
- it "should get status" do
9
- body = "Active connections: 1 \nserver accepts handled requests\n 4 5 51 \nReading: 1 Writing: 3 Waiting: 2 \n"
10
- status = {active_connections: 1, accepts: 4, handled: 5, requests: 51, reading: 1, writing: 3, waiting: 2}
11
- response = double("http response mock", body: body)
12
- Net::HTTP.should_receive(:start).and_return(response)
13
- expect(NginxUtils::Status.get).to eq(status)
14
- end
5
+ describe "NginxUtils::Status" do
6
+ describe ".get" do
7
+ it "should get status" do
8
+ body = "Active connections: 1 \nserver accepts handled requests\n 4 5 51 \nReading: 1 Writing: 3 Waiting: 2 \n"
9
+ status = {active_connections: 1, accepts: 4, handled: 5, requests: 51, reading: 1, writing: 3, waiting: 2}
10
+ response = double("http response mock", body: body)
11
+ Net::HTTP.should_receive(:start).and_return(response)
12
+ expect(NginxUtils::Status.get).to eq(status)
13
+ end
15
14
 
16
- it "should generate an exception if status get fails" do
17
- response = double("http response mock", body: "invalid content")
18
- Net::HTTP.should_receive(:start).and_return(response)
19
- expect(proc{NginxUtils::Status.get}).to raise_error("Nginx status get failed")
20
- end
15
+ it "should generate an exception if status get fails" do
16
+ response = double("http response mock", body: "invalid content")
17
+ Net::HTTP.should_receive(:start).and_return(response)
18
+ expect(proc{NginxUtils::Status.get}).to raise_error("Nginx status get failed")
21
19
  end
22
20
  end
23
21
  end
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1 @@
1
- require "fakefs/spec_helpers"
2
1
  require "nginx_utils"
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.5
4
+ version: 0.0.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,42 +9,42 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-05-21 00:00:00.000000000 Z
12
+ date: 2013-05-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: bundler
15
+ name: thor
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ~>
19
+ - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '1.3'
22
- type: :development
21
+ version: '0'
22
+ type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
25
25
  none: false
26
26
  requirements:
27
- - - ~>
27
+ - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '1.3'
29
+ version: '0'
30
30
  - !ruby/object:Gem::Dependency
31
- name: rake
31
+ name: bundler
32
32
  requirement: !ruby/object:Gem::Requirement
33
33
  none: false
34
34
  requirements:
35
- - - ! '>='
35
+ - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: '0'
37
+ version: '1.3'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  none: false
42
42
  requirements:
43
- - - ! '>='
43
+ - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: '0'
45
+ version: '1.3'
46
46
  - !ruby/object:Gem::Dependency
47
- name: rspec
47
+ name: rake
48
48
  requirement: !ruby/object:Gem::Requirement
49
49
  none: false
50
50
  requirements:
@@ -60,7 +60,7 @@ dependencies:
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
62
  - !ruby/object:Gem::Dependency
63
- name: fakefs
63
+ name: rspec
64
64
  requirement: !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
@@ -79,8 +79,7 @@ description: The various utilities on nginx
79
79
  email:
80
80
  - i2bskn@gmail.com
81
81
  executables:
82
- - nginx_logrotate
83
- - nginx_status
82
+ - nginx_utils
84
83
  extensions: []
85
84
  extra_rdoc_files: []
86
85
  files:
@@ -90,14 +89,15 @@ files:
90
89
  - LICENSE.txt
91
90
  - README.md
92
91
  - Rakefile
93
- - bin/nginx_logrotate
94
- - bin/nginx_status
92
+ - bin/nginx_utils
95
93
  - lib/nginx_utils.rb
94
+ - lib/nginx_utils/cli.rb
96
95
  - lib/nginx_utils/logreader.rb
97
96
  - lib/nginx_utils/logrotate.rb
98
97
  - lib/nginx_utils/status.rb
99
98
  - lib/nginx_utils/version.rb
100
99
  - nginx_utils.gemspec
100
+ - spec/nginx_utils/cli_spec.rb
101
101
  - spec/nginx_utils/logreader_spec.rb
102
102
  - spec/nginx_utils/logrotate_spec.rb
103
103
  - spec/nginx_utils/status_spec.rb
@@ -117,7 +117,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
117
117
  version: '0'
118
118
  segments:
119
119
  - 0
120
- hash: -837549919504176739
120
+ hash: -2092966652116304776
121
121
  required_rubygems_version: !ruby/object:Gem::Requirement
122
122
  none: false
123
123
  requirements:
@@ -126,14 +126,15 @@ required_rubygems_version: !ruby/object:Gem::Requirement
126
126
  version: '0'
127
127
  segments:
128
128
  - 0
129
- hash: -837549919504176739
129
+ hash: -2092966652116304776
130
130
  requirements: []
131
131
  rubyforge_project:
132
- rubygems_version: 1.8.25
132
+ rubygems_version: 1.8.23
133
133
  signing_key:
134
134
  specification_version: 3
135
135
  summary: Nginx utilities
136
136
  test_files:
137
+ - spec/nginx_utils/cli_spec.rb
137
138
  - spec/nginx_utils/logreader_spec.rb
138
139
  - spec/nginx_utils/logrotate_spec.rb
139
140
  - spec/nginx_utils/status_spec.rb
data/bin/nginx_logrotate DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "optparse"
5
-
6
- begin
7
- require "nginx_utils"
8
- rescue LoadError => e
9
- puts e
10
- exit 1
11
- end
12
-
13
- # Option parse
14
- options = {}
15
-
16
- opt = OptionParser.new
17
- Version = "0.0.1"
18
- opt.on("-d", "--[no-]debug", "Debug mode. Run only log output to STDOUT.") {|v| options[:debug] = v}
19
- opt.on("--script_log=VAL", "Log file for script.") {|v| options[:script_log] = v}
20
- opt.on("--log_level=VAL", "Log level of script log.") {|v| options[:log_level] = v.to_sym}
21
- opt.on("--root_dir=VAL", "Root directory of Nginx.") {|v| options[:root_dir] = v}
22
- opt.on("--target_logs=VAL", "Specify logs of target.") {|v| options[:target_logs] = v}
23
- opt.on("--retention=VAL", "Specify in days the retention period of log.") {|v| options[:retention] = v.to_i}
24
- opt.on("--pid_file=VAL", "PID file of Nginx") {|v| options[:pid_file] = v}
25
-
26
- opt.parse! ARGV
27
-
28
- rotate = NginxUtils::Logrotate.new(options)
29
- rotate.execute
data/bin/nginx_status DELETED
@@ -1,35 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # coding: utf-8
3
-
4
- require "optparse"
5
-
6
- begin
7
- require "nginx_utils"
8
- rescue LoadError => e
9
- puts e
10
- exit 1
11
- end
12
-
13
- # Option parse
14
- options = {}
15
-
16
- opt = OptionParser.new
17
- Version = "0.0.1"
18
- opt.on("--only-value", "The output only the value.") {|v| options[:only_value] = v}
19
-
20
- opt.parse! ARGV
21
-
22
- if ARGV.size > 0
23
- host = ARGV.shift
24
- result = NginxUtils::Status.get host: host
25
- else
26
- result = NginxUtils::Status.get
27
- end
28
-
29
- if options[:only_value]
30
- puts result.values.join("\t")
31
- else
32
- puts "Active Connections: #{result[:active_connection]}"
33
- puts "Accepts: #{result[:accepts]} Handled: #{result[:handled]} Requests: #{result[:requests]}"
34
- puts "Reading: #{result[:reading]} Writing: #{result[:writing]} Waiting: #{result[:waiting]}"
35
- end