fuey_client 0.5.5 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: dda931d07b4e4ebf6198e5c1cbc40af36084182b
4
- data.tar.gz: 049feb3fb6a41e59cb535b57775ffe52b1ff5ac5
3
+ metadata.gz: f079db9962809a0e42b00bd385b9184a132ee771
4
+ data.tar.gz: d86dfd426a5db986e654829d8f7877693bf8c8c6
5
5
  SHA512:
6
- metadata.gz: c4ff3f46992bbe9698c2f62a0895b355fbb02d086b9d607d511134df58160a584be855602f0ca08bdda77ae43796aae63429f8c993ee8b0205d0d5b6190cc609
7
- data.tar.gz: 7087d0187e1962db59b52e3394578ad6adc920ef5de42d237489159f23cfe22fd43063cf624c7a1472b4c883b09211e140dbe38fdd576319917802418108e1f5
6
+ metadata.gz: 25383482a7ffc6050a40a19dca2618195e2fa1f2418215a6b758c9d3ebddd9a530fecd945248dd01009a290f3834e75e43ce45146aa322edd186d2f48b604d55
7
+ data.tar.gz: c92968edaffae7143578e0dbacfcc14303e41438acb063ef90b9bbb43e02de4ffeb111e5c7003161c5adee2cbbca48e0bbc09f5c3d97833553e96ce473881326
@@ -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 %([Event #{name}] Completed in #{finished - started} seconds. #{payload})
16
+ Fuey::Log.write %([#{name}] Completed in #{finished - started} seconds. #{payload})
13
17
  end
14
18
 
15
19
  def self.logger
@@ -1 +1,2 @@
1
1
  require "fuey_client/fuey/reporters/redis"
2
+ require "fuey_client/fuey/reporters/error_logger"
@@ -0,0 +1,13 @@
1
+ require "fuey_client/fuey/log"
2
+
3
+ module Fuey
4
+ module Reporters
5
+ class ErrorLogger
6
+ def update(status)
7
+ if status[:status] == 'failed'
8
+ Log.alert "#{status[:name]} failed. #{status[:statusMessage]}"
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,4 +1,3 @@
1
-
2
1
  require "redis"
3
2
  require "json"
4
3
 
@@ -10,6 +9,7 @@ module Fuey
10
9
  :host => Config::Redis.host,
11
10
  :port => Config::Redis.port )
12
11
  end
12
+ private :redis
13
13
 
14
14
  # Handles update from observable
15
15
  def update(channel, message)
@@ -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
@@ -1,3 +1,3 @@
1
1
  module FueyClient
2
- VERSION = "0.5.5"
2
+ VERSION = "0.6.0"
3
3
  end
@@ -2,51 +2,67 @@ require 'spec_helper'
2
2
 
3
3
  describe Fuey::Inspections::Inspection do
4
4
 
5
- describe "observing an inspection" do
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
- Given(:inspection) { TestInspection.new({ :name => 'Example' }) }
13
- Given(:subscriber) { double "Observer" }
11
+ end
14
12
 
15
- describe "and it's initial state" do
16
- Then { expect( inspection.state ).to eql('pending') }
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
- describe "while executing" do
20
- Given { subscriber.
21
- should_receive(:update).
22
- with({
23
- :type => 'TestInspection',
24
- :name => 'Example',
25
- :status => 'pending'
26
- }) }
27
- Given { subscriber.
28
- should_receive(:update).
29
- with({
30
- :type => 'TestInspection',
31
- :name => 'Example',
32
- :status => 'executed'
33
- }) }
34
- Given { subscriber.
35
- should_receive(:update).
36
- with({
37
- :type => 'TestInspection',
38
- :name => 'Example',
39
- :status => 'passed'
40
- }) }
41
- Given { inspection.add_observer subscriber }
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 have_passed }
55
+ Then { expect( inspection ).to be_passed }
44
56
  end
45
57
  end
46
58
 
47
- describe "inspecting state" do
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.5.5
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-08-28 00:00:00.000000000 Z
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