steto 0.0.3 → 0.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,5 +24,10 @@ module Steto
24
24
  check_if_needed
25
25
  @text
26
26
  end
27
+
28
+ def to_json
29
+ { :name => name, :status => status, :text => text }.to_json
30
+ end
31
+
27
32
  end
28
33
  end
@@ -1,13 +1,15 @@
1
1
  module Steto
2
2
  class ProcCheck < BaseCheck
3
3
 
4
+ attr_accessor :block
5
+
4
6
  def initialize(attributes = {}, &block)
5
7
  self.attributes = attributes
6
- @block = block
8
+ self.block = block
7
9
  end
8
10
 
9
11
  def check
10
- self.status = status_from_response(@block.call)
12
+ self.status = status_from_response(block.call)
11
13
  end
12
14
 
13
15
  def status_from_response(response)
data/lib/steto/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Steto
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/lib/steto.rb CHANGED
@@ -11,6 +11,7 @@ module Steto
11
11
  end
12
12
  end
13
13
 
14
+ require 'json'
14
15
  require 'steto/cocaine_ext'
15
16
 
16
17
  require 'steto/status'
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Steto::BaseCheck do
4
+
5
+ subject do
6
+ Steto::BaseCheck.new.tap do |check|
7
+ check.stub :check
8
+ end
9
+ end
10
+
11
+ describe "#to_json" do
12
+
13
+ it "should include name" do
14
+ subject.name = "dummy"
15
+ JSON.parse(subject.to_json).should include("name" => "dummy")
16
+ end
17
+
18
+ it "should include text" do
19
+ subject.text = "dummy"
20
+ JSON.parse(subject.to_json).should include("text" => "dummy")
21
+ end
22
+
23
+ it "should include status" do
24
+ subject.status = :critical
25
+ JSON.parse(subject.to_json).should include("status" => "critical")
26
+ end
27
+
28
+ end
29
+
30
+ end
@@ -2,6 +2,8 @@ require 'spec_helper'
2
2
 
3
3
  describe Steto::ProcCheck do
4
4
 
5
+ subject { Steto::ProcCheck.new { true } }
6
+
5
7
  describe "#status_from_response" do
6
8
 
7
9
  it "should return ok when response is true" do
@@ -25,6 +27,5 @@ describe Steto::ProcCheck do
25
27
  end
26
28
 
27
29
  end
28
-
29
30
 
30
31
  end
data/steto.gemspec CHANGED
@@ -26,4 +26,5 @@ Gem::Specification.new do |s|
26
26
 
27
27
  s.add_runtime_dependency "cocaine"
28
28
  s.add_runtime_dependency "parallel"
29
+ s.add_runtime_dependency "json"
29
30
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: steto
3
3
  version: !ruby/object:Gem::Version
4
- hash: 25
4
+ hash: 23
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 3
10
- version: 0.0.3
9
+ - 4
10
+ version: 0.0.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - Alban Peignier
@@ -16,7 +16,7 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2012-06-05 00:00:00 Z
19
+ date: 2012-06-07 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
22
  prerelease: false
@@ -102,6 +102,20 @@ dependencies:
102
102
  version: "0"
103
103
  name: parallel
104
104
  version_requirements: *id006
105
+ - !ruby/object:Gem::Dependency
106
+ prerelease: false
107
+ type: :runtime
108
+ requirement: &id007 !ruby/object:Gem::Requirement
109
+ none: false
110
+ requirements:
111
+ - - ">="
112
+ - !ruby/object:Gem::Version
113
+ hash: 3
114
+ segments:
115
+ - 0
116
+ version: "0"
117
+ name: json
118
+ version_requirements: *id007
105
119
  description: Ruby engine to check system status (with Nagios or custom checks)
106
120
  email:
107
121
  - alban@tryphon.eu
@@ -133,6 +147,7 @@ files:
133
147
  - lib/steto/status.rb
134
148
  - lib/steto/version.rb
135
149
  - spec/spec_helper.rb
150
+ - spec/steto/base_check_spec.rb
136
151
  - spec/steto/beep_reporter_spec.rb
137
152
  - spec/steto/config_spec.rb
138
153
  - spec/steto/engine_spec.rb
@@ -175,6 +190,7 @@ specification_version: 3
175
190
  summary: Check system status
176
191
  test_files:
177
192
  - spec/spec_helper.rb
193
+ - spec/steto/base_check_spec.rb
178
194
  - spec/steto/beep_reporter_spec.rb
179
195
  - spec/steto/config_spec.rb
180
196
  - spec/steto/engine_spec.rb