Module: Cyclid::API::Plugins::ApiExtension::GithubMethods

Includes:
Config, Helpers, OAuth, PullRequest, Push, Methods
Defined in:
app/cyclid/plugins/api/github/push.rb,
app/cyclid/plugins/api/github/oauth.rb,
app/cyclid/plugins/api/github/config.rb,
app/cyclid/plugins/api/github/helpers.rb,
app/cyclid/plugins/api/github/methods.rb,
app/cyclid/plugins/api/github/pull_request.rb

Overview

Github plugin method callbacks

Defined Under Namespace

Modules: Config, Helpers, OAuth, PullRequest, Push

Instance Method Summary collapse

Methods included from Push

#event_push

Methods included from PullRequest

#event_pull_request, #insert_or_update_source

Methods included from OAuth

#oauth_callback, #oauth_request

Methods included from Config

#load_github_config

Methods included from Helpers

#find_job_file, #find_oauth_token, #humanish, #load_job_file, #normalize, #oauth_state, #pr_base, #pr_base_repo, #pr_base_url, #pr_head, #pr_head_repo, #pr_head_url, #pr_ref, #pr_repository, #pr_sha, #pr_trees_url, #pull_request, #push_clone_url, #push_head_commit, #push_ref, #push_repository, #push_sha

Methods included from Methods

#delete, #get, #put

Instance Method Details

#controller_pluginObject

Return a reference to the plugin that is associated with this controller; used by the lower level code.



42
43
44
# File 'app/cyclid/plugins/api/github/methods.rb', line 42

def controller_plugin
  Cyclid.plugins.find('github', Cyclid::API::Plugins::Api)
end

#post(headers, config) ⇒ Object

HTTP POST callback



47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'app/cyclid/plugins/api/github/methods.rb', line 47

def post(headers, config)
  return_failure(400, 'no event specified') \
    unless headers.include? 'X-Github-Event'

  return_failure(400, 'no delivery ID specified') \
    unless headers.include? 'X-Github-Delivery'

  event = headers['X-Github-Event']
  # Not used yet but will be when we add HMAC support
  # signature = headers['X-Hub-Signature'] || nil

  Cyclid.logger.debug "Github: event is #{event}"

  case event
  when 'pull_request'
    result = event_pull_request(config)
  when 'push'
    result = event_push(config)
  when 'ping'
    result = true
  when 'status'
    result = true
  else
    return_failure(400, "event type '#{event}' is not supported")
  end

  return result
end