Class: Agents::TwitterPublishv2Agent
- Inherits:
-
Agent
- Object
- Agent
- Agents::TwitterPublishv2Agent
- Includes:
- FormConfigurable
- Defined in:
- lib/huginn_twitter_publishv2_agent/twitter_publishv2_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
112 113 114 |
# File 'lib/huginn_twitter_publishv2_agent/twitter_publishv2_agent.rb', line 112 def check publish() end |
#default_options ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/huginn_twitter_publishv2_agent/twitter_publishv2_agent.rb', line 48 def { 'message' => "{{text}}", 'debug' => 'false', 'consumer_key' => '', 'consumer_secret' => '', 'access_token' => '', 'token_secret' => '', 'emit_events' => 'true', 'expected_receive_period_in_days' => '2', } end |
#receive(incoming_events) ⇒ Object
103 104 105 106 107 108 109 110 |
# File 'lib/huginn_twitter_publishv2_agent/twitter_publishv2_agent.rb', line 103 def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do log event publish() end end end |
#validate_options ⇒ Object
69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/huginn_twitter_publishv2_agent/twitter_publishv2_agent.rb', line 69 def unless ['consumer_key'].present? errors.add(:base, "consumer_key is a required field") end unless ['consumer_secret'].present? errors.add(:base, "consumer_secret must be true or false") end if .has_key?('emit_events') && boolify(['emit_events']).nil? errors.add(:base, "if provided, emit_events must be true or false") end unless ['access_token'].present? errors.add(:base, "access_token must be true or false") end unless ['token_secret'].present? errors.add(:base, "token_secret must be true or false") 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
99 100 101 |
# File 'lib/huginn_twitter_publishv2_agent/twitter_publishv2_agent.rb', line 99 def working? event_created_within?(['expected_receive_period_in_days']) && !recent_error_logs? end |