Class: Chef::Deployment::Monitor::HistoryFileSink
- Defined in:
- lib/chef_deployment_monitor/sinks.rb
Instance Attribute Summary collapse
-
#file ⇒ Object
readonly
Returns the value of attribute file.
Instance Method Summary collapse
-
#initialize ⇒ HistoryFileSink
constructor
A new instance of HistoryFileSink.
-
#receive(data) ⇒ Object
will append data to the history file within 5 seconds of last deployment the array is a FIFO.
Constructor Details
#initialize ⇒ HistoryFileSink
Returns a new instance of HistoryFileSink.
26 27 28 29 30 31 32 33 |
# File 'lib/chef_deployment_monitor/sinks.rb', line 26 def initialize @file = Monitor::Config[:history_file] @history = if File.exist?(file) JSON.parse(File.read(file)) rescue [] else [] end end |
Instance Attribute Details
#file ⇒ Object (readonly)
Returns the value of attribute file.
24 25 26 |
# File 'lib/chef_deployment_monitor/sinks.rb', line 24 def file @file end |
Instance Method Details
#receive(data) ⇒ Object
will append data to the history file within 5 seconds of last deployment the array is a FIFO
38 39 40 41 42 |
# File 'lib/chef_deployment_monitor/sinks.rb', line 38 def receive(data) history = [data] + history.take(Monitor::Config[:history_file_size] - 1) File.write(file, history.to_json) end |