nginx_utils 0.0.9 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,15 @@
1
+ ---
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ N2ZmZDZjZjZkNWExMzkzNDViZjk5NTY3OTljYzYzOWIxZDJjZTgzYw==
5
+ data.tar.gz: !binary |-
6
+ NTgxZjJlNjUzODRjYTY2MjYyYTk4MjZiYzA0ZWQwNTNkMDk2YzI3OA==
7
+ !binary "U0hBNTEy":
8
+ metadata.gz: !binary |-
9
+ ZTAxOWRiZmYzYjRmMThiMzRjYzA1ZWVlYzJiY2I0N2Y2NWU2YTRhOGQxYTcx
10
+ Mzg5YjZiN2VlM2Q0N2E5ZmNkZmJkYTA1ZDMzM2QxMjBmZDkyMDU4MTJlMjNi
11
+ YzY0OTFlYWE1NDNiN2I0YWVkZWFkYjE2M2IxMjc0ZjFhODE1NGI=
12
+ data.tar.gz: !binary |-
13
+ ZmFjMGU4YTM3YTlhOWE0OWI5MTg2YzU3MDg1OGQyYjY0OTQ4NDAwNTZkNmQ2
14
+ ZTFhZjZjYTkzMjNmNTQ0OTdlNGRlNTA3ZjUxNjIwMmMwM2FjODA1OWFiNDlm
15
+ YmE4YjIyMDEyY2E4MWQ5MGIyMDkzMGI2NTkzZTUwYTMyN2E3MWM=
data/.coveralls.yml CHANGED
@@ -1 +1 @@
1
- repo_token: j5c7RRcpsMCwX1qif9oQyvF6qOfqKv0CV
1
+ repo_token: rsXl8kS7psAf83cjj6iqyRZ5vW4Okpuu3
data/.travis.yml CHANGED
@@ -4,7 +4,7 @@ rvm:
4
4
  - 2.0.0
5
5
  gemfile:
6
6
  - Gemfile
7
- script: bundle exec rspec
7
+ script: bundle exec rake spec
8
8
  branches:
9
9
  only:
10
10
  - master
data/Gemfile CHANGED
@@ -5,4 +5,5 @@ gemspec
5
5
 
6
6
  group :test do
7
7
  gem 'coveralls', require: false
8
+ gem 'simplecov', require: false
8
9
  end
data/README.md CHANGED
@@ -90,6 +90,14 @@ Options that can be specified:
90
90
  * `:retention` => `90`. Specify in days the retention period of log.
91
91
  * `:pid_file` => `"/path/to/nginx.pid"`. Use to restart Nginx.
92
92
 
93
+ for cron:
94
+
95
+ e.g.
96
+
97
+ ```
98
+ 3 19 * * * /usr/local/bin/nginx_utils logrotate
99
+ ```
100
+
93
101
  ### Status
94
102
 
95
103
  Require **HttpStubStatusModule**.
data/Rakefile CHANGED
@@ -1,9 +1,9 @@
1
1
  require "bundler/gem_tasks"
2
-
3
- Bundler.setup
4
- require 'rspec/core/rake_task'
2
+ require "rspec/core/rake_task"
5
3
 
6
4
  desc "Run all specs"
7
5
  RSpec::Core::RakeTask.new(:spec) do |t|
8
6
  t.rspec_opts = ["-c", "-fs"]
9
7
  end
8
+
9
+ task :default => :spec
@@ -1,3 +1,3 @@
1
1
  module NginxUtils
2
- VERSION = "0.0.9"
2
+ VERSION = "0.1.0"
3
3
  end
@@ -116,11 +116,36 @@ describe "NginxUtils::Logrotate" do
116
116
  expect(rotate.logger).to be_false
117
117
  end
118
118
 
119
- it "@logger.level should be a specified level" do
119
+ it "@logger.level should be a fatal" do
120
+ logger_mock.should_receive(:level=).with(Logger::FATAL)
121
+ NginxUtils::Logrotate.new(log_level: :fatal)
122
+ end
123
+
124
+ it "@logger.level should be a error" do
125
+ logger_mock.should_receive(:level=).with(Logger::ERROR)
126
+ NginxUtils::Logrotate.new(log_level: :error)
127
+ end
128
+
129
+ it "@logger.level should be a warn" do
120
130
  logger_mock.should_receive(:level=).with(Logger::WARN)
121
131
  NginxUtils::Logrotate.new(log_level: :warn)
122
132
  end
123
133
 
134
+ it "@logger.level should be a info" do
135
+ logger_mock.should_receive(:level=).with(Logger::INFO)
136
+ NginxUtils::Logrotate.new(log_level: :info)
137
+ end
138
+
139
+ it "@logger.level should be a debug" do
140
+ logger_mock.should_receive(:level=).with(Logger::DEBUG)
141
+ NginxUtils::Logrotate.new(log_level: :debug)
142
+ end
143
+
144
+ it "@logger.level should be a debug if invalid params" do
145
+ logger_mock.should_receive(:level=).with(Logger::DEBUG)
146
+ NginxUtils::Logrotate.new(log_level: :invalid)
147
+ end
148
+
124
149
  it "@params[:root_dir] should be a specified parameter" do
125
150
  root_dir = "/var/log/nginx"
126
151
  rotate = NginxUtils::Logrotate.new(root_dir: root_dir)
@@ -7,13 +7,37 @@ describe "NginxUtils::Status" do
7
7
  let(:status) {{active_connections: 1, accepts: 4, handled: 5, requests: 51, reading: 1, writing: 3, waiting: 2}}
8
8
 
9
9
  describe ".get" do
10
+ let(:response) {double("http response mock", body: body)}
10
11
  before {NginxUtils::Status.stub(:parse).and_return(nil)}
11
12
 
12
13
  it "should get status" do
13
- response = double("http response mock", body: body)
14
14
  Net::HTTP.should_receive(:start).and_return(response)
15
15
  expect(proc{NginxUtils::Status.get}).not_to raise_error
16
16
  end
17
+
18
+ it "should default params if not specified" do
19
+ req = Net::HTTP::Get.new("/nginx_status")
20
+ Net::HTTP::Get.should_receive(:new).with("/nginx_status").and_return(req)
21
+ Net::HTTP.should_receive(:start).with("localhost", 80).and_return(response)
22
+ expect(proc{NginxUtils::Status.get}).not_to raise_error
23
+ end
24
+
25
+ it "should specified host" do
26
+ Net::HTTP.should_receive(:start).with("example.com", 80).and_return(response)
27
+ expect(proc{NginxUtils::Status.get(host: "example.com")}).not_to raise_error
28
+ end
29
+
30
+ it "should specified port" do
31
+ Net::HTTP.should_receive(:start).with("localhost", 8080).and_return(response)
32
+ expect(proc{NginxUtils::Status.get(port: 8080)}).not_to raise_error
33
+ end
34
+
35
+ it "should specified path" do
36
+ req = Net::HTTP::Get.new("/nginx-status")
37
+ Net::HTTP::Get.should_receive(:new).with("/nginx-status").and_return(req)
38
+ Net::HTTP.should_receive(:start).and_return(response)
39
+ expect(proc{NginxUtils::Status.get(path: "/nginx-status")}).not_to raise_error
40
+ end
17
41
  end
18
42
 
19
43
  describe ".parse" do
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,9 @@
1
- require "nginx_utils"
2
-
1
+ require "simplecov"
3
2
  require "coveralls"
4
3
  Coveralls.wear!
4
+
5
+ SimpleCov.start do
6
+ add_filter "spec"
7
+ end
8
+
9
+ require "nginx_utils"
metadata CHANGED
@@ -1,20 +1,18 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nginx_utils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.9
5
- prerelease:
4
+ version: 0.1.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - i2bskn
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-05-29 00:00:00.000000000 Z
11
+ date: 2013-06-13 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: thor
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
17
  - - ! '>='
20
18
  - !ruby/object:Gem::Version
@@ -22,7 +20,6 @@ dependencies:
22
20
  type: :runtime
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
24
  - - ! '>='
28
25
  - !ruby/object:Gem::Version
@@ -30,7 +27,6 @@ dependencies:
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: bundler
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
31
  - - ~>
36
32
  - !ruby/object:Gem::Version
@@ -38,7 +34,6 @@ dependencies:
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
38
  - - ~>
44
39
  - !ruby/object:Gem::Version
@@ -46,7 +41,6 @@ dependencies:
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: rake
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
45
  - - ! '>='
52
46
  - !ruby/object:Gem::Version
@@ -54,7 +48,6 @@ dependencies:
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
52
  - - ! '>='
60
53
  - !ruby/object:Gem::Version
@@ -62,7 +55,6 @@ dependencies:
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: rspec
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
59
  - - ! '>='
68
60
  - !ruby/object:Gem::Version
@@ -70,7 +62,6 @@ dependencies:
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
66
  - - ! '>='
76
67
  - !ruby/object:Gem::Version
@@ -106,33 +97,26 @@ files:
106
97
  homepage: https://github.com/i2bskn/nginx_utils
107
98
  licenses:
108
99
  - MIT
100
+ metadata: {}
109
101
  post_install_message:
110
102
  rdoc_options: []
111
103
  require_paths:
112
104
  - lib
113
105
  required_ruby_version: !ruby/object:Gem::Requirement
114
- none: false
115
106
  requirements:
116
107
  - - ! '>='
117
108
  - !ruby/object:Gem::Version
118
109
  version: '0'
119
- segments:
120
- - 0
121
- hash: -3985509799625259397
122
110
  required_rubygems_version: !ruby/object:Gem::Requirement
123
- none: false
124
111
  requirements:
125
112
  - - ! '>='
126
113
  - !ruby/object:Gem::Version
127
114
  version: '0'
128
- segments:
129
- - 0
130
- hash: -3985509799625259397
131
115
  requirements: []
132
116
  rubyforge_project:
133
- rubygems_version: 1.8.25
117
+ rubygems_version: 2.0.3
134
118
  signing_key:
135
- specification_version: 3
119
+ specification_version: 4
136
120
  summary: Nginx utilities
137
121
  test_files:
138
122
  - spec/nginx_utils/cli_spec.rb