Class: Agents::WriteFileAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::WriteFileAgent
- Includes:
- FormConfigurable
- Defined in:
- lib/huginn_write_file_agent/write_file_agent.rb
Instance Method Summary collapse
- #check ⇒ Object
- #default_options ⇒ Object
- #receive(incoming_events) ⇒ Object
- #validate_options ⇒ Object
- #working? ⇒ Boolean
Instance Method Details
#check ⇒ Object
92 93 94 |
# File 'lib/huginn_write_file_agent/write_file_agent.rb', line 92 def check write_file end |
#default_options ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'lib/huginn_write_file_agent/write_file_agent.rb', line 38 def { 'path' => '/tmp/huginn_output.txt', 'content' => 'Default content', 'mode' => '0644', 'owner' => 'huginn:huginn', 'expected_receive_period_in_days' => '10', 'debug' => 'false' } end |
#receive(incoming_events) ⇒ Object
83 84 85 86 87 88 89 90 |
# File 'lib/huginn_write_file_agent/write_file_agent.rb', line 83 def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do log event write_file end end end |
#validate_options ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/huginn_write_file_agent/write_file_agent.rb', line 55 def # errors.add(:base, "type has invalid value: should be 'generate'") if interpolated['type'].present? && !%w(generate).include?(interpolated['type']) unless ['path'].present? errors.add(:base, "path is a required field") end unless ['mode'].present? errors.add(:base, "mode is a required field") end unless ['owner'].present? errors.add(:base, "owner is a required field") end if .has_key?('debug') && boolify(['debug']).nil? errors.add(:base, "if provided, debug must be true or false") end unless ['expected_receive_period_in_days'].present? && ['expected_receive_period_in_days'].to_i > 0 errors.add(:base, "Please provide 'expected_receive_period_in_days' to indicate how many days can pass before this Agent is considered to be not working") end end |
#working? ⇒ Boolean
79 80 81 |
# File 'lib/huginn_write_file_agent/write_file_agent.rb', line 79 def working? event_created_within?(['expected_receive_period_in_days']) && !recent_error_logs? end |