class Flo::Provider::GithubFlo

Public Class Methods

new(opts={}) click to toggle source

Creates a new GithubFlo Provider instance

@param [Hash] opts The options needed to create the provider @option opts [String] :user The username of the github user @option opts [String] :token an access token for the user @option opts [String] :repo the name of the repo, e.g. 'salesforce/github_flo'

# File lib/flo/provider/github_flo.rb, line 20
def initialize(opts={})
  username = opts[:user]
  token = opts[:token]
  @repo = opts[:repo]

  @client = opts[:client] || Octokit::Client.new(login: username, password: token)
end

Public Instance Methods

add_labels_to_an_issue(opts={}) click to toggle source

Adds labels to a Github Issue

@param [Hash] opts Options for updating an issue @option opts [String] :number The issue number to update @option opts [Array<String>] :labels A list of labels to add to the issue

Remaining options will be passed to octokit. See octokit's documentation for updating issues

# File lib/flo/provider/github_flo.rb, line 49
def add_labels_to_an_issue(opts={})
  options = {repo: @repo}.merge(opts)
  @client.add_labels_to_an_issue(options.delete(:repo), options.delete(:number), options[:labels])
  OpenStruct.new(success?: true)
end
create_pull_request(opts={}) click to toggle source

Creates a Github pull request

@option opts [String] base ('master') The base branch for the pull request @option opts [String] head The head containing the new changes @option opts [String] Title The title for the pull request @option opts [String] Body The body of the pull request

Remaining options will be passed to octokit. See octokit's documentation for updating issues

# File lib/flo/provider/github_flo.rb, line 77
def create_pull_request(opts={})
  repo = opts[:repo] || @repo
  @client.create_pull_request(
                              repo,
                              opts.delete(:base),
                              opts.delete(:head),
                              opts.delete(:title),
                              opts.delete(:body)
                              )
  OpenStruct.new(success?: true)
end
issue(opts={}) click to toggle source

Provides an Octokit issue. This is helpful when you want to take some other action based on the state of an issue.

@param [Hash] opts Options for finding the issue @option opts [String] :number The issue number to fetch

@return [Sawyer::Resource] The issue returned from octokit

# File lib/flo/provider/github_flo.rb, line 63
def issue(opts={})
  options = {repo: @repo}.merge(opts)
  @client.issue(options[:repo], options[:number])
end
update_issue(opts={}) click to toggle source

Updates a Github issue

@param [Hash] opts Options for updating an issue @option opts [String] :number The issue number to update

Remaining options will be passed to octokit. See octokit's documentation for updating issues

# File lib/flo/provider/github_flo.rb, line 35
def update_issue(opts={})
  options = {repo: @repo}.merge(opts)
  @client.update_issue(options.delete(:repo), options.delete(:number), options)
  OpenStruct.new(success?: true)
end