Class: Furik::PullRequests
- Inherits:
-
Object
- Object
- Furik::PullRequests
- Defined in:
- lib/furik/pull_requests.rb
Instance Method Summary collapse
- #all(&block) ⇒ Object
- #all! ⇒ Object
- #all_repo_names ⇒ Object
-
#initialize(client) ⇒ PullRequests
constructor
A new instance of PullRequests.
- #org_name_from(repo_name) ⇒ Object
-
#org_repo_names(org_name) ⇒ Object
It contains all repositories for your organization.
- #orgs_repo_names ⇒ Object
-
#pull_requests(repo_name) ⇒ Object
Use the issues api so specify the creator.
- #request_manager ⇒ Object
- #user_orgs_names ⇒ Object
-
#user_repo_names ⇒ Object
It contains repositories of your organization, If you are a public member of the organization.
Constructor Details
#initialize(client) ⇒ PullRequests
Returns a new instance of PullRequests.
5 6 7 8 |
# File 'lib/furik/pull_requests.rb', line 5 def initialize(client) @client = client @login = client.login end |
Instance Method Details
#all(&block) ⇒ Object
20 21 22 23 |
# File 'lib/furik/pull_requests.rb', line 20 def all(&block) @block = block @all || all! end |
#all! ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/furik/pull_requests.rb', line 25 def all! @all = all_repo_names.each.with_object([]) do |repo_name, memo| pulls = pull_requests(repo_name) memo.concat pulls if pulls.is_a?(Array) request_manager end end |
#all_repo_names ⇒ Object
64 65 66 |
# File 'lib/furik/pull_requests.rb', line 64 def all_repo_names self.user_repo_names.concat(self.orgs_repo_names).uniq end |
#org_name_from(repo_name) ⇒ Object
33 34 35 |
# File 'lib/furik/pull_requests.rb', line 33 def org_name_from(repo_name) repo_name.split('/').first end |
#org_repo_names(org_name) ⇒ Object
It contains all repositories for your organization.
79 80 81 |
# File 'lib/furik/pull_requests.rb', line 79 def org_repo_names(org_name) @client.org_repos(org_name).map(&:full_name) end |
#orgs_repo_names ⇒ Object
83 84 85 86 87 |
# File 'lib/furik/pull_requests.rb', line 83 def orgs_repo_names user_orgs_names.each_with_object([]) do |org_name, memo| memo.concat org_repo_names(org_name) end end |
#pull_requests(repo_name) ⇒ Object
Use the issues api so specify the creator
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/furik/pull_requests.rb', line 38 def pull_requests(repo_name) org_name = org_name_from(repo_name) unless @block if @org_name == org_name print '-' else puts '' print "#{org_name} -" @org_name = org_name end end issues = @client.issues(repo_name, creator: @login, state: 'open'). select { |issue| issue.pull_request } issues.concat @client.issues(repo_name, creator: @login, state: 'closed'). select { |issue| issue.pull_request } @block.call(repo_name, issues) if @block issues rescue Octokit::ClientError rescue => e puts e end |
#request_manager ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/furik/pull_requests.rb', line 10 def request_manager limit = @client.rate_limit if !limit.limit.zero? && limit.remaining.zero? puts "Oops! #{limit}" sleep limit.resets_in end # No rate limit for white listed users rescue Octokit::NotFound end |
#user_orgs_names ⇒ Object
74 75 76 |
# File 'lib/furik/pull_requests.rb', line 74 def user_orgs_names @client.orgs.map(&:login) end |
#user_repo_names ⇒ Object
It contains repositories of your organization, If you are a public member of the organization.
70 71 72 |
# File 'lib/furik/pull_requests.rb', line 70 def user_repo_names @client.repos.map(&:full_name) end |