-
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f4d94d1
commit fe25b0b
Showing
6 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# frozen_string_literal: true | ||
|
||
class TravisEvent | ||
attr_reader :processor | ||
delegate :process, to: :processor | ||
|
||
## | ||
# The TravisEvent handler checks which type of event we are dealing with. | ||
# | ||
# If it is a known event, create a specific handler and let it take care of | ||
# the next steps. If not kick off a Sentry error. | ||
|
||
def initialize(payload) | ||
case payload['type'] | ||
when 'push' | ||
TravisEvent::Push.new(payload) | ||
when 'pull_request' | ||
TravisEvent::Push.new(payload) | ||
when 'cron' | ||
TravisEvent::Push.new(payload) | ||
when 'api' | ||
TravisEvent::Push.new(payload) | ||
else | ||
Raven.capture_message("Unknown Hook Received: #{payload['type']}", extra: payload) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class TravisEvent | ||
class Base | ||
attr_reader :payload | ||
|
||
def initialize(payload) | ||
@payload = payload | ||
process | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# frozen_string_literal: true | ||
|
||
class TravisEvent | ||
class Push < TravisEvent::Base | ||
def process | ||
::TravisEvent.new(payload) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# frozen_string_literal: true | ||
|
||
class Travis < ApplicationRecord | ||
belongs_to(:pull_requests) | ||
|
||
def sef.update_with_travis_payload(payload) | ||
Travis.where(travis_id: payload['id']).first_or_initialize.tap do |travis| | ||
travis.type = payload['type'] | ||
travis.state = payload['state'] | ||
travis.status = payload['status'] | ||
travis.result = payload['result'] | ||
travis.status_message = payload['status_message'] | ||
travis.result_message = payload['result_message'] | ||
travis.started_at = payload['started_at'] | ||
travis.finished_at = payload['finished_at'] | ||
travis.duration = payload['duration'] | ||
travis.build_url = payload['build_url'] | ||
travis.commit_id = payload['commit_id'] | ||
travis.commit = payload['commit'] | ||
travis.base_commit = payload['base_commit'] | ||
travis.head_commit = payload['head_commit'] | ||
travis.branch = payload['branch'] | ||
travis.message = payload['message'] | ||
travis.compare_url = payload['compare_url'] | ||
travis.committed_at = payload['committed_at'] | ||
travis.author_name = payload['author_name'] | ||
travis.author_email = payload['author_email'] | ||
travis.committer_name = payload['committer_name'] | ||
travis._committer_email = payload['committer_email'] | ||
travis.pull_request = payload['pull_request'] | ||
travis.pull_request_number = payload['payload_request_number'] | ||
travis.request_title = payload['request_title'] | ||
travis.tag = payload['tag'] | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters