Class: DevTools::PRlist::PullRequests
- Inherits:
-
Object
- Object
- DevTools::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.
42 43 44 45 46 47 |
# File 'lib/pr_list/pull_requests.rb', line 42 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.
40 41 42 |
# File 'lib/pr_list/pull_requests.rb', line 40 def pulls @pulls end |
Instance Method Details
#auth!(token) ⇒ Object
53 54 55 |
# File 'lib/pr_list/pull_requests.rb', line 53 def auth!(token) @github = __authenticate token end |
#authorized? ⇒ Boolean
49 50 51 |
# File 'lib/pr_list/pull_requests.rb', line 49 def return !@github.nil? end |
#by_date ⇒ Object
65 66 67 68 69 |
# File 'lib/pr_list/pull_requests.rb', line 65 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
57 58 59 60 61 62 63 |
# File 'lib/pr_list/pull_requests.rb', line 57 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
71 72 73 |
# File 'lib/pr_list/pull_requests.rb', line 71 def repos @pulls.collect { |pr| pr.repo }.uniq end |