Class: Agents::GithubAutocommitAgent
- Inherits:
-
Agent
- Object
- Agent
- Agents::GithubAutocommitAgent
- Includes:
- FormConfigurable
- Defined in:
- lib/huginn_github_autocommit_agent/github_autocommit_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
177 178 179 |
# File 'lib/huginn_github_autocommit_agent/github_autocommit_agent.rb', line 177 def check commit end |
#default_options ⇒ Object
92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/huginn_github_autocommit_agent/github_autocommit_agent.rb', line 92 def { 'repository' => '', 'version' => '', 'commit_message' => '', 'committer_name' => '', 'committer_email' => '', 'emit_events' => 'true', 'expected_receive_period_in_days' => '2', 'token' => '', 'rules' => '[{name: "", owner: "", my_repository: "", pattern: "", file: "" }' } end |
#receive(incoming_events) ⇒ Object
168 169 170 171 172 173 174 175 |
# File 'lib/huginn_github_autocommit_agent/github_autocommit_agent.rb', line 168 def receive(incoming_events) incoming_events.each do |event| interpolate_with(event) do log event commit end end end |
#validate_options ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 |
# File 'lib/huginn_github_autocommit_agent/github_autocommit_agent.rb', line 117 def unless ['repository'].present? errors.add(:base, "repository is a required field") end unless ['version'].present? errors.add(:base, "version is a required field") end unless ['commit_message'].present? errors.add(:base, "commit_message is a required field") end unless ['committer_name'].present? errors.add(:base, "committer_name is a required field") end unless ['committer_email'].present? errors.add(:base, "committer_email is a required field") end unless ['token'].present? errors.add(:base, "token is a required field") end # # if options[:type] == :array && (options[:values].blank? || !options[:values].is_a?(Array)) # raise ArgumentError.new('When using :array as :type you need to provide the :values as an Array') # end if .has_key?('add_release_details') && boolify(['add_release_details']).nil? errors.add(:base, "if provided, add_release_details 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 if .has_key?('emit_events') && boolify(['emit_events']).nil? errors.add(:base, "if provided, emit_events 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
164 165 166 |
# File 'lib/huginn_github_autocommit_agent/github_autocommit_agent.rb', line 164 def working? event_created_within?(['expected_receive_period_in_days']) && !recent_error_logs? end |