Class: Agents::GithubCheckTopicAgent

Inherits:
Agent
  • Object
show all
Includes:
FormConfigurable
Defined in:
lib/huginn_github_check_topic_agent/github_check_topic_agent.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



81
82
83
# File 'lib/huginn_github_check_topic_agent/github_check_topic_agent.rb', line 81

def check
  fetch
end

#default_optionsObject



37
38
39
40
41
42
43
44
45
46
# File 'lib/huginn_github_check_topic_agent/github_check_topic_agent.rb', line 37

def default_options
  {
    'debug' => 'false',
    'expected_receive_period_in_days' => '2',
    'token' => '',
    'owner' => '',
    'wanted_topic' => '',
    'regex_filter_name' => ''
  }
end

#validate_optionsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
# File 'lib/huginn_github_check_topic_agent/github_check_topic_agent.rb', line 55

def validate_options
  unless options['token'].present?
    errors.add(:base, "token is a required field")
  end

  unless options['owner'].present?
    errors.add(:base, "owner is a required field")
  end

  unless options['wanted_topic'].present?
    errors.add(:base, "wanted_topic is a required field")
  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)


77
78
79
# File 'lib/huginn_github_check_topic_agent/github_check_topic_agent.rb', line 77

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