Class: Agents::HttpObservatoryMozillaAgent

Inherits:
Agent
  • Object
show all
Includes:
FormConfigurable
Defined in:
lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



106
107
108
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 106

def check
  check_status
end

#default_optionsObject



63
64
65
66
67
68
69
70
71
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 63

def default_options
  {
    'debug' => 'false',
    'expected_receive_period_in_days' => '2',
    'hidden' => 'false',
    'rescan' => 'false',
    'changes_only' => 'true'
  }
end

#validate_optionsObject



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 80

def validate_options
  if options.has_key?('changes_only') && boolify(options['changes_only']).nil?
    errors.add(:base, "if provided, changes_only must be true or false")
  end

  if options.has_key?('debug') && boolify(options['debug']).nil?
    errors.add(:base, "if provided, debug must be true or false")
  end

  unless options['expected_receive_period_in_days'].present? && options['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

  if options.has_key?('hidden') && boolify(options['hidden']).nil?
    errors.add(:base, "if provided, hidden must be true or false")
  end

  if options.has_key?('rescan') && boolify(options['rescan']).nil?
    errors.add(:base, "if provided, rescan must be true or false")
  end
end

#working?Boolean

Returns:

  • (Boolean)


102
103
104
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 102

def working?
  event_created_within?(options['expected_receive_period_in_days']) && !recent_error_logs?
end