Skip to content
Snippets Groups Projects
Commit cd51af1a authored by Tiago Botelho's avatar Tiago Botelho
Browse files

adds events to services api deserialization

parent 4b7ec44b
No related branches found
No related tags found
No related merge requests found
Showing
with 104 additions and 41 deletions
module ServicesHelper
def service_event_description(event)
case event
when "push"
when "push", "push_events"
"Event will be triggered by a push to the repository"
when "tag_push"
when "tag_push", "tag_push_events"
"Event will be triggered when a new tag is pushed to the repository"
when "note"
when "note", "note_events"
"Event will be triggered when someone adds a comment"
when "issue"
when "issue", "issue_events"
"Event will be triggered when an issue is created/updated/closed"
when "confidential_issue"
when "confidential_issue", "confidential_issue_events"
"Event will be triggered when a confidential issue is created/updated/closed"
when "merge_request"
when "merge_request", "merge_request_events"
"Event will be triggered when a merge request is created/updated/merged"
when "build"
when "build", "build_events"
"Event will be triggered when a build status changes"
when "wiki_page"
when "wiki_page", "wiki_page_events"
"Event will be triggered when a wiki page is created/updated"
when "commit"
when "commit", "commit_events"
"Event will be triggered when a commit is created/updated"
end
end
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ You can create a Personal Access Token here:
http://app.asana.com/-/account_api'
end
 
def to_param
def self.to_param
'asana'
end
 
Loading
Loading
@@ -44,10 +44,14 @@ http://app.asana.com/-/account_api'
]
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def client
@_client ||= begin
Asana::Client.new do |c|
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ class AssemblaService < Service
'Project Management Software (Source Commits Endpoint)'
end
 
def to_param
def self.to_param
'assembla'
end
 
Loading
Loading
@@ -23,10 +23,14 @@ class AssemblaService < Service
]
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
 
Loading
Loading
Loading
Loading
@@ -40,7 +40,7 @@ class BambooService < CiService
'You must set up automatic revision labeling and a repository trigger in Bamboo.'
end
 
def to_param
def self.to_param
'bamboo'
end
 
Loading
Loading
@@ -56,7 +56,7 @@ class BambooService < CiService
]
end
 
def supported_events
def self.supported_events
%w(push)
end
 
Loading
Loading
Loading
Loading
@@ -19,7 +19,15 @@ class BugzillaService < IssueTrackerService
end
end
 
def to_param
def self.to_param
'bugzilla'
end
def self.supported_events
%w()
end
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
end
Loading
Loading
@@ -24,10 +24,14 @@ class BuildkiteService < CiService
hook.save
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
 
Loading
Loading
@@ -54,7 +58,7 @@ class BuildkiteService < CiService
'Continuous integration and deployments'
end
 
def to_param
def self.to_param
'buildkite'
end
 
Loading
Loading
Loading
Loading
@@ -19,14 +19,18 @@ class BuildsEmailService < Service
'Email the builds status to a list of recipients.'
end
 
def to_param
def self.to_param
'builds_email'
end
 
def supported_events
def self.supported_events
%w(build)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(push_data)
return unless supported_events.include?(push_data[:object_kind])
return unless should_build_be_notified?(push_data)
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ class CampfireService < Service
'Simple web-based real-time group chat'
end
 
def to_param
def self.to_param
'campfire'
end
 
Loading
Loading
@@ -24,10 +24,14 @@ class CampfireService < Service
]
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
 
Loading
Loading
Loading
Loading
@@ -25,7 +25,7 @@ class ChatNotificationService < Service
valid?
end
 
def supported_events
def self.supported_events
%w[push issue confidential_issue merge_request note tag_push
build pipeline wiki_page]
end
Loading
Loading
Loading
Loading
@@ -13,8 +13,8 @@ class ChatSlashCommandsService < Service
ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.token)
end
 
def supported_events
[]
def self.supported_events
%w()
end
 
def can_test?
Loading
Loading
Loading
Loading
@@ -8,10 +8,13 @@ class CiService < Service
self.respond_to?(:token) && self.token.present? && ActiveSupport::SecurityUtils.variable_size_secure_compare(token, self.token)
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
# Return complete url to build page
#
# Ex.
Loading
Loading
Loading
Loading
@@ -23,7 +23,7 @@ class CustomIssueTrackerService < IssueTrackerService
end
end
 
def to_param
def self.to_param
'custom_issue_tracker'
end
 
Loading
Loading
@@ -36,4 +36,12 @@ class CustomIssueTrackerService < IssueTrackerService
{ type: 'text', name: 'new_issue_url', placeholder: 'New Issue url' }
]
end
def self.supported_events
%w()
end
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
end
Loading
Loading
@@ -5,8 +5,8 @@
class DeploymentService < Service
default_value_for :category, 'deployment'
 
def supported_events
[]
def self.supported_events
%w()
end
 
def predefined_variables
Loading
Loading
Loading
Loading
@@ -32,7 +32,7 @@ class DroneCiService < CiService
true
end
 
def supported_events
def self.supported_events
%w(push merge_request tag_push)
end
 
Loading
Loading
@@ -87,7 +87,7 @@ class DroneCiService < CiService
'Drone is a Continuous Integration platform built on Docker, written in Go'
end
 
def to_param
def self.to_param
'drone_ci'
end
 
Loading
Loading
Loading
Loading
@@ -12,14 +12,18 @@ class EmailsOnPushService < Service
'Email the commits and diff of each push to a list of recipients.'
end
 
def to_param
def self.to_param
'emails_on_push'
end
 
def supported_events
def self.supported_events
%w(push tag_push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(push_data)
return unless supported_events.include?(push_data[:object_kind])
 
Loading
Loading
Loading
Loading
@@ -13,7 +13,7 @@ class ExternalWikiService < Service
'Replaces the link to the internal wiki with a link to an external wiki.'
end
 
def to_param
def self.to_param
'external_wiki'
end
 
Loading
Loading
@@ -29,4 +29,12 @@ class ExternalWikiService < Service
nil
end
end
def self.supported_events
%w()
end
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
end
Loading
Loading
@@ -12,7 +12,7 @@ class FlowdockService < Service
'Flowdock is a collaboration web app for technical teams.'
end
 
def to_param
def self.to_param
'flowdock'
end
 
Loading
Loading
@@ -22,10 +22,14 @@ class FlowdockService < Service
]
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
 
Loading
Loading
Loading
Loading
@@ -12,7 +12,7 @@ class GemnasiumService < Service
'Gemnasium monitors your project dependencies and alerts you about updates and security vulnerabilities.'
end
 
def to_param
def self.to_param
'gemnasium'
end
 
Loading
Loading
@@ -23,10 +23,14 @@ class GemnasiumService < Service
]
end
 
def supported_events
def self.supported_events
%w(push)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
 
Loading
Loading
Loading
Loading
@@ -7,7 +7,7 @@ class GitlabIssueTrackerService < IssueTrackerService
 
default_value_for :default, true
 
def to_param
def self.to_param
'gitlab'
end
 
Loading
Loading
Loading
Loading
@@ -27,7 +27,7 @@ class HipchatService < Service
'Private group chat and IM'
end
 
def to_param
def self.to_param
'hipchat'
end
 
Loading
Loading
@@ -45,10 +45,14 @@ class HipchatService < Service
]
end
 
def supported_events
def self.supported_events
%w(push issue confidential_issue merge_request note tag_push build)
end
 
def self.event_names
self.supported_events.map { |event| "#{event}_events" }
end
def execute(data)
return unless supported_events.include?(data[:object_kind])
message = create_message(data)
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment