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



72
73
74
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 72

def check
  check_status
end

#default_optionsObject



39
40
41
42
43
44
45
46
47
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 39

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

#validate_optionsObject



54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 54

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
end

#working?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/huginn_http_observatory_mozilla_agent/http_observatory_mozilla_agent.rb', line 68

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