steto 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,14 +19,25 @@ module Steto
19
19
  def command_line
20
20
  # => "--critical=:critical --warning=:warning"
21
21
  params = options.map do |option, value|
22
- cli_option = option.to_s.gsub("_","-")
23
- unless value == true
24
- "--#{cli_option}=:#{option}"
22
+ unless option.size == 1
23
+ cli_option = option.to_s.gsub("_","-")
24
+ unless value == true
25
+ "--#{cli_option}=:#{option}"
26
+ else
27
+ "--#{cli_option}"
28
+ end
25
29
  else
26
- "--#{cli_option}"
30
+ unless value == true
31
+ "-#{option} :#{option}"
32
+ else
33
+ "-#{option}"
34
+ end
27
35
  end
28
36
  end.sort.join(' ')
29
- @command_line ||= Cocaine::CommandLine.new(command, params, options.merge(:expected_outcodes => [0, 1, 2, 3]))
37
+
38
+ command_options = Hash[options.map { |k,v| [ k, v.to_s ] }]
39
+
40
+ @command_line ||= Cocaine::CommandLine.new(command, params, command_options.merge(:expected_outcodes => [0, 1, 2, 3]))
30
41
  end
31
42
 
32
43
  def status_from_command_line
data/lib/steto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steto
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
@@ -4,17 +4,17 @@ describe Steto::BeepReporter do
4
4
 
5
5
  it "should beep twice when one of checks is critical" do
6
6
  subject.should_receive(:beep).with(2)
7
- subject.report [ mock :status => Steto::Status.new(:critical) ]
7
+ subject.report [ mock(:status => Steto::Status.new(:critical)) ]
8
8
  end
9
9
 
10
10
  it "should beep when one of checks is warning" do
11
11
  subject.should_receive(:beep)
12
- subject.report [ mock :status => Steto::Status.new(:warning) ]
12
+ subject.report [ mock(:status => Steto::Status.new(:warning)) ]
13
13
  end
14
14
 
15
15
  it "should not beep when no check is warning or critical" do
16
16
  subject.should_not_receive(:beep)
17
- subject.report [ mock :status => Steto::Status.new(:info) ]
17
+ subject.report [ mock(:status => Steto::Status.new(:info)) ]
18
18
  end
19
19
 
20
20
  end
@@ -32,19 +32,30 @@ describe Steto::NagiosCheck do
32
32
 
33
33
  describe "#command_line" do
34
34
 
35
- it "should use command as binary" do
35
+ before do
36
36
  subject.stub :command => "dummy"
37
+ end
38
+
39
+ it "should use command as binary" do
37
40
  subject.command_line.command.should == "dummy"
38
41
  end
39
42
 
40
43
  it "should use options as parameters" do
41
- subject.stub :command => "dummy"
42
44
  subject.stub :options => { :warning => "1,0.5,0.5", :critical => "1,1,1" }
43
45
  subject.command_line.command.should == "dummy --critical='1,1,1' --warning='1,0.5,0.5'"
44
46
  end
45
47
 
48
+ it "should support non string options" do
49
+ subject.stub :options => { :port => 4567 }
50
+ subject.command_line.command.should == "dummy --port='4567'"
51
+ end
52
+
53
+ it "should support short options" do
54
+ subject.stub :options => { :p => 4567 }
55
+ subject.command_line.command.should == "dummy -p '4567'"
56
+ end
57
+
46
58
  it "should rename option with underscores" do
47
- subject.stub :command => "dummy"
48
59
  subject.stub :options => { :with_underscore => "yes" }
49
60
  subject.command_line.command.should == "dummy --with-underscore='yes'"
50
61
  end
data/steto.gemspec CHANGED
@@ -21,10 +21,10 @@ Gem::Specification.new do |s|
21
21
  # specify any dependencies here; for example:
22
22
  s.add_development_dependency "rspec"
23
23
  s.add_development_dependency "rake"
24
- s.add_development_dependency "rcov"
24
+ s.add_development_dependency "simplecov"
25
25
  s.add_development_dependency "RedCloth"
26
26
 
27
- s.add_runtime_dependency "cocaine"
27
+ s.add_runtime_dependency "cocaine", "0.2.1"
28
28
  s.add_runtime_dependency "parallel"
29
29
  s.add_runtime_dependency "json"
30
30
  end
metadata CHANGED
@@ -1,132 +1,137 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: steto
3
- version: !ruby/object:Gem::Version
4
- hash: 21
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.6
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 0
9
- - 5
10
- version: 0.0.5
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Alban Peignier
14
9
  - Florent Peyraud
15
10
  autorequire:
16
11
  bindir: bin
17
12
  cert_chain: []
18
-
19
- date: 2012-06-07 00:00:00 Z
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
23
- type: :development
24
- requirement: &id001 !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
13
+ date: 2012-10-18 00:00:00.000000000 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
33
16
  name: rspec
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- prerelease: false
17
+ requirement: !ruby/object:Gem::Requirement
18
+ none: false
19
+ requirements:
20
+ - - ! '>='
21
+ - !ruby/object:Gem::Version
22
+ version: '0'
37
23
  type: :development
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ prerelease: false
25
+ version_requirements: !ruby/object:Gem::Requirement
39
26
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
27
+ requirements:
28
+ - - ! '>='
29
+ - !ruby/object:Gem::Version
30
+ version: '0'
31
+ - !ruby/object:Gem::Dependency
47
32
  name: rake
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- prerelease: false
51
- type: :development
52
- requirement: &id003 !ruby/object:Gem::Requirement
33
+ requirement: !ruby/object:Gem::Requirement
53
34
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
61
- name: rcov
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: '0'
39
+ type: :development
64
40
  prerelease: false
41
+ version_requirements: !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
47
+ - !ruby/object:Gem::Dependency
48
+ name: simplecov
49
+ requirement: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
65
55
  type: :development
66
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ prerelease: false
57
+ version_requirements: !ruby/object:Gem::Requirement
67
58
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
59
+ requirements:
60
+ - - ! '>='
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
75
64
  name: RedCloth
76
- version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
65
+ requirement: !ruby/object:Gem::Requirement
66
+ none: false
67
+ requirements:
68
+ - - ! '>='
69
+ - !ruby/object:Gem::Version
70
+ version: '0'
71
+ type: :development
78
72
  prerelease: false
79
- type: :runtime
80
- requirement: &id005 !ruby/object:Gem::Requirement
73
+ version_requirements: !ruby/object:Gem::Requirement
81
74
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
75
+ requirements:
76
+ - - ! '>='
77
+ - !ruby/object:Gem::Version
78
+ version: '0'
79
+ - !ruby/object:Gem::Dependency
89
80
  name: cocaine
90
- version_requirements: *id005
91
- - !ruby/object:Gem::Dependency
92
- prerelease: false
81
+ requirement: !ruby/object:Gem::Requirement
82
+ none: false
83
+ requirements:
84
+ - - '='
85
+ - !ruby/object:Gem::Version
86
+ version: 0.2.1
93
87
  type: :runtime
94
- requirement: &id006 !ruby/object:Gem::Requirement
88
+ prerelease: false
89
+ version_requirements: !ruby/object:Gem::Requirement
95
90
  none: false
96
- requirements:
97
- - - ">="
98
- - !ruby/object:Gem::Version
99
- hash: 3
100
- segments:
101
- - 0
102
- version: "0"
91
+ requirements:
92
+ - - '='
93
+ - !ruby/object:Gem::Version
94
+ version: 0.2.1
95
+ - !ruby/object:Gem::Dependency
103
96
  name: parallel
104
- version_requirements: *id006
105
- - !ruby/object:Gem::Dependency
106
- prerelease: false
97
+ requirement: !ruby/object:Gem::Requirement
98
+ none: false
99
+ requirements:
100
+ - - ! '>='
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
107
103
  type: :runtime
108
- requirement: &id007 !ruby/object:Gem::Requirement
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
109
106
  none: false
110
- requirements:
111
- - - ">="
112
- - !ruby/object:Gem::Version
113
- hash: 3
114
- segments:
115
- - 0
116
- version: "0"
107
+ requirements:
108
+ - - ! '>='
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
117
112
  name: json
118
- version_requirements: *id007
113
+ requirement: !ruby/object:Gem::Requirement
114
+ none: false
115
+ requirements:
116
+ - - ! '>='
117
+ - !ruby/object:Gem::Version
118
+ version: '0'
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ none: false
123
+ requirements:
124
+ - - ! '>='
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
119
127
  description: Ruby engine to check system status (with Nagios or custom checks)
120
- email:
128
+ email:
121
129
  - alban@tryphon.eu
122
130
  - florent@tryphon.eu
123
131
  executables: []
124
-
125
132
  extensions: []
126
-
127
133
  extra_rdoc_files: []
128
-
129
- files:
134
+ files:
130
135
  - .gitignore
131
136
  - Gemfile
132
137
  - Guardfile
@@ -157,38 +162,35 @@ files:
157
162
  - steto.gemspec
158
163
  homepage: https://github.com/tryphon/steto
159
164
  licenses: []
160
-
161
165
  post_install_message:
162
166
  rdoc_options: []
163
-
164
- require_paths:
167
+ require_paths:
165
168
  - lib
166
- required_ruby_version: !ruby/object:Gem::Requirement
169
+ required_ruby_version: !ruby/object:Gem::Requirement
167
170
  none: false
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- hash: 3
172
- segments:
171
+ requirements:
172
+ - - ! '>='
173
+ - !ruby/object:Gem::Version
174
+ version: '0'
175
+ segments:
173
176
  - 0
174
- version: "0"
175
- required_rubygems_version: !ruby/object:Gem::Requirement
177
+ hash: -2351214180611345255
178
+ required_rubygems_version: !ruby/object:Gem::Requirement
176
179
  none: false
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- hash: 3
181
- segments:
180
+ requirements:
181
+ - - ! '>='
182
+ - !ruby/object:Gem::Version
183
+ version: '0'
184
+ segments:
182
185
  - 0
183
- version: "0"
186
+ hash: -2351214180611345255
184
187
  requirements: []
185
-
186
188
  rubyforge_project: steto
187
- rubygems_version: 1.8.15
189
+ rubygems_version: 1.8.23
188
190
  signing_key:
189
191
  specification_version: 3
190
192
  summary: Check system status
191
- test_files:
193
+ test_files:
192
194
  - spec/spec_helper.rb
193
195
  - spec/steto/base_check_spec.rb
194
196
  - spec/steto/beep_reporter_spec.rb