Class: Agents::GithubAutosyncForkAgent

Inherits:
Agent
  • Object
show all
Includes:
FormConfigurable
Defined in:
lib/huginn_github_autosync_fork_agent/github_autosync_fork_agent.rb

Instance Method Summary collapse

Instance Method Details

#checkObject



85
86
87
# File 'lib/huginn_github_autosync_fork_agent/github_autosync_fork_agent.rb', line 85

def check
  check_sync
end

#default_optionsObject



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

def default_options
  {
    'repository' => '',
    'src_branch' => 'master',
    'tgt_branch' => 'master',
    'debug' => 'false',
    'expected_receive_period_in_days' => '2',
    'token' => ''
  }
end

#validate_optionsObject



55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'lib/huginn_github_autosync_fork_agent/github_autosync_fork_agent.rb', line 55

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

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

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


81
82
83
# File 'lib/huginn_github_autosync_fork_agent/github_autosync_fork_agent.rb', line 81

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