Class: Agents::SignalspamAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::SignalspamAgent
- Includes:
- FormConfigurable
- Defined in:
- lib/huginn_signalspam_agent/signalspam_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
83 84 85 |
# File 'lib/huginn_signalspam_agent/signalspam_agent.rb', line 83 def check report end |
#default_options ⇒ Object
33 34 35 36 37 38 39 40 41 |
# File 'lib/huginn_signalspam_agent/signalspam_agent.rb', line 33 def { 'username' => '', 'password' => '', 'raw_email' => '', 'debug' => 'false', 'expected_receive_period_in_days' => '2', } end |
#receive(incoming_events) ⇒ Object
74 75 76 77 78 79 80 81 |
# File 'lib/huginn_signalspam_agent/signalspam_agent.rb', line 74 def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do log event report end end end |
#validate_options ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
# File 'lib/huginn_signalspam_agent/signalspam_agent.rb', line 48 def unless ['username'].present? errors.add(:base, "username is a required field") end unless ['password'].present? errors.add(:base, "password is a required field") end unless ['raw_email'].present? errors.add(:base, "raw_email 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
70 71 72 |
# File 'lib/huginn_signalspam_agent/signalspam_agent.rb', line 70 def working? event_created_within?(['expected_receive_period_in_days']) && !recent_error_logs? end |