Class: Kachikachi::GitHub

Inherits:
Object
  • Object
show all
Defined in:
lib/kachikachi/git_hub.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ GitHub

Returns a new instance of GitHub.



8
9
10
# File 'lib/kachikachi/git_hub.rb', line 8

def initialize(options)
  @options = options
end

Instance Attribute Details

#client=(value) ⇒ Object

Sets the attribute client

Parameters:

  • value

    the value to set the attribute client to.



6
7
8
# File 'lib/kachikachi/git_hub.rb', line 6

def client=(value)
  @client = value
end

Instance Method Details

#pull_requestsObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/kachikachi/git_hub.rb', line 12

def pull_requests
  pull_request_numbers = @options['pull-request-numbers']
  return pull_request_numbers.map { |number| PullRequest.new(number, @options) } if pull_request_numbers
  
  options = {
    state: @options[:state]
  }
  options[:creator] = @options[:user] if @options[:user]

  issues = milestone_numbers.map { |number|
    options[:milestone] = number
    client.list_issues(@options[:repo], options).select(&:pull_request)
  }.flatten

  issues.map{ |issue| PullRequest.new(issue.number, @options) }.select{ |pr| pr.base.ref == @options['base-branch'] }
end