Sha256: ed7698823e95fa8d4e9cf7abeabc3f5ee1371cf964535fb015ea464e9ed9a1ab
Contents?: true
Size: 1.38 KB
Versions: 4
Compression:
Stored size: 1.38 KB
Contents
module Hubstats class EventsHandler def route(payload, type) puts case type when "issue_comment" || "IssueCommentEvent" comment_processor(payload,"Issue") when "commit_comment" || "CommitCommentEvent" comment_processor(payload,"Commit") when "pull_request" || "PullRequestEvent" pull_processor(payload) when "pull_request_review_comment" || "PullRequestReviewCommentEvent" comment_processor(payload,"PullRequest") end end def pull_processor(payload) pull_request = payload[:pull_request] pull_request[:repository] = payload[:repository] Hubstats::PullRequest.create_or_update(pull_request) end def comment_processor(payload,kind) comment = payload[:comment] comment[:kind] = kind comment[:repo_id] = payload[:repository][:id] comment[:pull_number] = get_pull_number(payload) Hubstats::Comment.create_or_update(comment) end #grabs the number off of anyone of the various places it can be def get_pull_number(payload) if payload[:pull_request] return payload[:pull_request][:number] elsif payload[:issue] return payload[:issue][:number] elsif payload[:comment][:pull_request_url] return payload[:comment][:pull_request_url].split('/')[-1] else return nil end end end end
Version data entries
4 entries across 4 versions & 1 rubygems
Version | Path |
---|---|
hubstats-0.0.8 | lib/hubstats/events_handler.rb |
hubstats-0.0.7 | lib/hubstats/events_handler.rb |
hubstats-0.0.6 | lib/hubstats/events_handler.rb |
hubstats-0.0.5 | lib/hubstats/events_handler.rb |