Class: ListPullRequests::User
- Inherits:
-
Object
- Object
- ListPullRequests::User
- Defined in:
- lib/list_pull_requests/user.rb
Instance Attribute Summary collapse
-
#all ⇒ Object
Returns the value of attribute all.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
- #create_prs(url) ⇒ Object
- #get_all ⇒ Object
- #get_merged ⇒ Object
- #get_unmerged ⇒ Object
-
#initialize(name) ⇒ User
constructor
A new instance of User.
Constructor Details
#initialize(name) ⇒ User
Returns a new instance of User.
4 5 6 7 |
# File 'lib/list_pull_requests/user.rb', line 4 def initialize(name) @name = name @all = [] end |
Instance Attribute Details
#all ⇒ Object
Returns the value of attribute all.
2 3 4 |
# File 'lib/list_pull_requests/user.rb', line 2 def all @all end |
#name ⇒ Object
Returns the value of attribute name.
2 3 4 |
# File 'lib/list_pull_requests/user.rb', line 2 def name @name end |
Instance Method Details
#create_prs(url) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/list_pull_requests/user.rb', line 24 def create_prs(url) puts "Retrieving list of pulls....".red page = 1 begin # begin json = JSON.parse(open(url + "&page=#{page}").read) amount ||= json["total_count"] json["items"].each do |pr| all << ListPullRequests::Pr.new(pr["pull_request"]["url"], pr["html_url"], pr["title"], pr["created_at"]) end page += 1 # rescue OpenURI::HTTPError # puts "error control" # end end until all.count == amount all end |
#get_all ⇒ Object
9 10 11 12 |
# File 'lib/list_pull_requests/user.rb', line 9 def get_all result = create_prs("https://api.github.com/search/issues?per_page=100&q=is:pr+author:#{name}") # binding.pry end |
#get_merged ⇒ Object
14 15 16 17 |
# File 'lib/list_pull_requests/user.rb', line 14 def get_merged create_prs("https://api.github.com/search/issues?per_page=100&q=is:merged+author:#{name}") # binding.pry end |
#get_unmerged ⇒ Object
19 20 21 22 |
# File 'lib/list_pull_requests/user.rb', line 19 def get_unmerged create_prs("https://api.github.com/search/issues?per_page=100&q=is:unmerged+author:#{name}") # binding.pry end |