Class: PRlist::PullRequests
- Inherits:
-
Object
- Object
- PRlist::PullRequests
- Defined in:
- lib/pr_list/pull_requests.rb
Instance Attribute Summary collapse
-
#pulls ⇒ Object
readonly
Returns the value of attribute pulls.
Instance Method Summary collapse
- #auth!(token) ⇒ Object
- #authorized? ⇒ Boolean
- #by_date ⇒ Object
-
#initialize(token = nil, repos = []) ⇒ PullRequests
constructor
A new instance of PullRequests.
- #load!(repo) ⇒ Object
- #repos ⇒ Object
Constructor Details
#initialize(token = nil, repos = []) ⇒ PullRequests
Returns a new instance of PullRequests.
41 42 43 44 45 46 |
# File 'lib/pr_list/pull_requests.rb', line 41 def initialize(token = nil, repos = []) @pulls ||= [] @github ||= __authenticate token repos.each { |repo| load!(repo) } if end |
Instance Attribute Details
#pulls ⇒ Object (readonly)
Returns the value of attribute pulls.
39 40 41 |
# File 'lib/pr_list/pull_requests.rb', line 39 def pulls @pulls end |
Instance Method Details
#auth!(token) ⇒ Object
52 53 54 |
# File 'lib/pr_list/pull_requests.rb', line 52 def auth!(token) @github = __authenticate token end |
#authorized? ⇒ Boolean
48 49 50 |
# File 'lib/pr_list/pull_requests.rb', line 48 def return !@github.nil? end |
#by_date ⇒ Object
64 65 66 67 68 |
# File 'lib/pr_list/pull_requests.rb', line 64 def by_date sorted_pulls = @pulls.sort_by { |pr| pr.date } block_given? ? sorted_pulls.each { |pr| yield pr } : sorted_pulls end |
#load!(repo) ⇒ Object
56 57 58 59 60 61 62 |
# File 'lib/pr_list/pull_requests.rb', line 56 def load!(repo) raise NoAuthError, "You must authorized with github using #auth first" unless @github.issues(repo).each do |issue| __load_issue issue if issue.pull_request? end end |
#repos ⇒ Object
70 71 72 |
# File 'lib/pr_list/pull_requests.rb', line 70 def repos @pulls.collect { |pr| pr.repo }.uniq end |