Class: DogEventer::ChefRun
- Inherits:
-
EventEmitter
- Object
- EventEmitter
- DogEventer::ChefRun
- Defined in:
- lib/dogeventer/event_emitter.rb
Instance Attribute Summary
Attributes inherited from EventEmitter
Instance Method Summary collapse
- #date_happened(date = nil) ⇒ Object
- #error(duration = nil, date = nil) ⇒ Object
- #event_object ⇒ Object
- #event_type ⇒ Object
-
#initialize(host, start_time) ⇒ ChefRun
constructor
A new instance of ChefRun.
- #msg_title(duration) ⇒ Object
- #priority(alert_type) ⇒ Object
- #source_type_name ⇒ Object
- #success(duration = nil, date = nil) ⇒ Object
- #to_event(alert_type, duration = nil, date = nil) ⇒ Object
Methods inherited from EventEmitter
Constructor Details
#initialize(host, start_time) ⇒ ChefRun
Returns a new instance of ChefRun.
134 135 136 137 138 |
# File 'lib/dogeventer/event_emitter.rb', line 134 def initialize(host, start_time) @host = host @start_time = start_time @events = [] end |
Instance Method Details
#date_happened(date = nil) ⇒ Object
152 153 154 |
# File 'lib/dogeventer/event_emitter.rb', line 152 def date_happened(date=nil) (date || @start_time).to_i end |
#error(duration = nil, date = nil) ⇒ Object
185 186 187 |
# File 'lib/dogeventer/event_emitter.rb', line 185 def error(duration=nil, date=nil) to_event :error, duration end |
#event_object ⇒ Object
144 145 146 |
# File 'lib/dogeventer/event_emitter.rb', line 144 def event_object() @host end |
#event_type ⇒ Object
148 149 150 |
# File 'lib/dogeventer/event_emitter.rb', line 148 def event_type() "config_management.run" end |
#msg_title(duration) ⇒ Object
140 141 142 |
# File 'lib/dogeventer/event_emitter.rb', line 140 def msg_title(duration) "Chef completed in #{duration} seconds on #{@host}" end |
#priority(alert_type) ⇒ Object
160 161 162 163 164 165 166 |
# File 'lib/dogeventer/event_emitter.rb', line 160 def priority(alert_type) if alert_type == :error :normal else :low end end |
#source_type_name ⇒ Object
156 157 158 |
# File 'lib/dogeventer/event_emitter.rb', line 156 def source_type_name() "Chef" end |
#success(duration = nil, date = nil) ⇒ Object
182 183 184 |
# File 'lib/dogeventer/event_emitter.rb', line 182 def success(duration=nil, date=nil) to_event :success, duration end |
#to_event(alert_type, duration = nil, date = nil) ⇒ Object
168 169 170 171 172 173 174 175 176 177 178 179 180 |
# File 'lib/dogeventer/event_emitter.rb', line 168 def to_event(alert_type, duration=nil, date=nil) duration = duration || rand(1000) @events << { :event_object => event_object, :event_type => event_type, :alert_type => alert_type, :date_happened => date_happened(date), :msg_title => msg_title(duration), :source_type_name => source_type_name, :host => @host, :priority => priority(alert_type) } end |