Class: Fuey::Trace
- Inherits:
-
Object
- Object
- Fuey::Trace
- Includes:
- ModelInitializer, Observable
- Defined in:
- lib/fuey_client/fuey/trace.rb
Instance Attribute Summary collapse
-
#name ⇒ Object
Returns the value of attribute name.
-
#steps ⇒ Object
Returns the value of attribute steps.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ Trace
constructor
A new instance of Trace.
- #run ⇒ Object
- #to_s ⇒ Object
-
#update(status) ⇒ Object
Handle updates from inpsections via observation.
Constructor Details
#initialize(args) ⇒ Trace
Returns a new instance of Trace.
12 13 14 15 |
# File 'lib/fuey_client/fuey/trace.rb', line 12 def initialize(args) super(args) @steps ||= Array.new end |
Instance Attribute Details
#name ⇒ Object
Returns the value of attribute name.
10 11 12 |
# File 'lib/fuey_client/fuey/trace.rb', line 10 def name @name end |
#steps ⇒ Object
Returns the value of attribute steps.
10 11 12 |
# File 'lib/fuey_client/fuey/trace.rb', line 10 def steps @steps end |
Class Method Details
.all ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/fuey_client/fuey/trace.rb', line 17 def self.all Config::Fuey.traces.keys.map do |trace_name| trace = Trace.new :name => trace_name Config::Fuey.traces.send(trace_name).each do |step| inspection_class = ActiveSupport::Inflector.constantize %(Fuey::Inspections::#{step.keys.first}) inspection = inspection_class.new(step.values.first) inspection.add_observer(trace) trace.steps.push inspection end trace end end |
Instance Method Details
#run ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/fuey_client/fuey/trace.rb', line 47 def run changed notify_observers( "fuey.trace.new", { :name => name, :status => "executed", :statusMessage => "", :steps => steps.map(&:status) } ) ActiveSupport::Notifications.instrument("run.trace", {:trace => self.to_s}) do run, failed, current = 0, 0, "" steps.each do |step| run += 1 current = step.name step.execute if step.failed? failed += 1 break end end if failed == 0 %(#{name} passed. #{steps.size} steps, #{run} executed, #{failed} failed.) else %(#{name} failed on #{current}. #{steps.size} steps, #{run} executed, #{failed} failed.) end end end |
#to_s ⇒ Object
30 31 32 |
# File 'lib/fuey_client/fuey/trace.rb', line 30 def to_s %(#{name}: [#{steps.join(', ')}]) end |
#update(status) ⇒ Object
Handle updates from inpsections via observation
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/fuey_client/fuey/trace.rb', line 35 def update(status) changed notify_observers( "fuey.trace.update", { :name => name, :status => status[:status], :statusMessage => status[:statusMessage], :steps => [ status ] }) end |