fuey_client 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/fuey_client/fuey/log.rb +5 -1
- data/lib/fuey_client/fuey/reporters.rb +1 -0
- data/lib/fuey_client/fuey/reporters/error_logger.rb +13 -0
- data/lib/fuey_client/fuey/reporters/redis.rb +1 -1
- data/lib/fuey_client/fuey/trace.rb +7 -0
- data/lib/fuey_client/version.rb +1 -1
- data/spec/fuey_client/fuey/inspections/inspection_spec.rb +48 -32
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f079db9962809a0e42b00bd385b9184a132ee771
|
4
|
+
data.tar.gz: d86dfd426a5db986e654829d8f7877693bf8c8c6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 25383482a7ffc6050a40a19dca2618195e2fa1f2418215a6b758c9d3ebddd9a530fecd945248dd01009a290f3834e75e43ce45146aa322edd186d2f48b604d55
|
7
|
+
data.tar.gz: c92968edaffae7143578e0dbacfcc14303e41438acb063ef90b9bbb43e02de4ffeb111e5c7003161c5adee2cbbca48e0bbc09f5c3d97833553e96ce473881326
|
data/lib/fuey_client/fuey/log.rb
CHANGED
@@ -7,9 +7,13 @@ module Fuey
|
|
7
7
|
logger.info "[#{Config::Fuey.title}] #{message}"
|
8
8
|
end
|
9
9
|
|
10
|
+
def self.alert(message)
|
11
|
+
logger.error "[#{Config::Fuey.title}] #{message}"
|
12
|
+
end
|
13
|
+
|
10
14
|
# Handles ActiveSupport::Notifications
|
11
15
|
def call(name, started, finished, unique_id, payload)
|
12
|
-
Fuey::Log.write %([
|
16
|
+
Fuey::Log.write %([#{name}] Completed in #{finished - started} seconds. #{payload})
|
13
17
|
end
|
14
18
|
|
15
19
|
def self.logger
|
@@ -1,7 +1,9 @@
|
|
1
1
|
require "fuey_client/fuey/model_initializer"
|
2
|
+
require "fuey_client/fuey/reporters"
|
2
3
|
require "active_support"
|
3
4
|
require "observer"
|
4
5
|
|
6
|
+
|
5
7
|
module Fuey
|
6
8
|
class Trace
|
7
9
|
include ModelInitializer
|
@@ -21,12 +23,17 @@ module Fuey
|
|
21
23
|
inspection_class = ActiveSupport::Inflector.constantize %(Fuey::Inspections::#{step.keys.first})
|
22
24
|
inspection = inspection_class.new(step.values.first)
|
23
25
|
inspection.add_observer(trace)
|
26
|
+
inspection.add_observer(error_logger)
|
24
27
|
trace.steps.push inspection
|
25
28
|
end
|
26
29
|
trace
|
27
30
|
end
|
28
31
|
end
|
29
32
|
|
33
|
+
def self.error_logger
|
34
|
+
@@error_logger ||= Fuey::Reporters::ErrorLogger.new
|
35
|
+
end
|
36
|
+
|
30
37
|
def to_s
|
31
38
|
%(#{name}: [#{steps.join(', ')}])
|
32
39
|
end
|
data/lib/fuey_client/version.rb
CHANGED
@@ -2,51 +2,67 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
describe Fuey::Inspections::Inspection do
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
class TestInspection < Fuey::Inspections::Inspection
|
5
|
+
def successful_inspection
|
6
|
+
Class.new(Fuey::Inspections::Inspection) do
|
8
7
|
def _execute
|
9
8
|
self.pass
|
10
9
|
end
|
11
10
|
end
|
12
|
-
|
13
|
-
Given(:subscriber) { double "Observer" }
|
11
|
+
end
|
14
12
|
|
15
|
-
|
16
|
-
|
13
|
+
def failed_inspection
|
14
|
+
Class.new(Fuey::Inspections::Inspection) do
|
15
|
+
def _execute
|
16
|
+
self.fail
|
17
|
+
end
|
17
18
|
end
|
19
|
+
end
|
18
20
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
Given {
|
21
|
+
class InspectionObserver
|
22
|
+
def initialize(inspection)
|
23
|
+
@inspection = inspection
|
24
|
+
@inspection.add_observer self
|
25
|
+
end
|
26
|
+
|
27
|
+
def update; end
|
28
|
+
|
29
|
+
def expects_notification_of(*states)
|
30
|
+
states.each do |state|
|
31
|
+
self.should_receive(:update).
|
32
|
+
with({
|
33
|
+
:type => @inspection.class.to_s,
|
34
|
+
:name => @inspection.name,
|
35
|
+
:status => state
|
36
|
+
})
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
describe "observing execution" do
|
42
|
+
context "when it fails" do
|
43
|
+
Given(:inspection) { failed_inspection.new({ :name => 'Example' }) }
|
44
|
+
Given(:subscriber) { InspectionObserver.new(inspection) }
|
45
|
+
Given { subscriber.expects_notification_of('pending', 'executed', 'failed') }
|
46
|
+
When { inspection.execute }
|
47
|
+
Then { expect( inspection ).to be_failed }
|
48
|
+
end
|
49
|
+
|
50
|
+
context "when it passes" do
|
51
|
+
Given(:inspection) { successful_inspection.new({ :name => 'Example' }) }
|
52
|
+
Given(:subscriber) { InspectionObserver.new(inspection) }
|
53
|
+
Given { subscriber.expects_notification_of('pending', 'executed', 'passed') }
|
42
54
|
When { inspection.execute }
|
43
|
-
Then { expect( inspection ).to
|
55
|
+
Then { expect( inspection ).to be_passed }
|
44
56
|
end
|
45
57
|
end
|
46
58
|
|
47
|
-
describe "
|
59
|
+
describe "it's state" do
|
48
60
|
Given (:inspection) { Fuey::Inspections::Inspection.new }
|
49
61
|
|
62
|
+
context "initially" do
|
63
|
+
Then { expect( inspection.state ).to eql('pending') }
|
64
|
+
end
|
65
|
+
|
50
66
|
context "when the inspection passes" do
|
51
67
|
When { inspection.pass }
|
52
68
|
Then { expect( inspection ).to be_passed }
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: fuey_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matt Snyder
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: configurethis
|
@@ -145,6 +145,7 @@ files:
|
|
145
145
|
- lib/fuey_client/fuey/model_initializer.rb
|
146
146
|
- lib/fuey_client/fuey/null_object.rb
|
147
147
|
- lib/fuey_client/fuey/reporters.rb
|
148
|
+
- lib/fuey_client/fuey/reporters/error_logger.rb
|
148
149
|
- lib/fuey_client/fuey/reporters/redis.rb
|
149
150
|
- lib/fuey_client/fuey/trace.rb
|
150
151
|
- lib/fuey_client/version.rb
|