Class: Nailed::Github
- Inherits:
-
Object
- Object
- Nailed::Github
- Defined in:
- lib/nailed.rb
Instance Attribute Summary collapse
-
#client ⇒ Object
readonly
Returns the value of attribute client.
Instance Method Summary collapse
- #get_open_pulls ⇒ Object
-
#initialize ⇒ Github
constructor
A new instance of Github.
- #update_pull_states ⇒ Object
- #write_pull_trends(repo) ⇒ Object
Constructor Details
#initialize ⇒ Github
Returns a new instance of Github.
75 76 77 |
# File 'lib/nailed.rb', line 75 def initialize @client = Octokit::Client.new(:netrc => true) end |
Instance Attribute Details
#client ⇒ Object (readonly)
Returns the value of attribute client.
73 74 75 |
# File 'lib/nailed.rb', line 73 def client @client end |
Instance Method Details
#get_open_pulls ⇒ Object
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/nailed.rb', line 79 def get_open_pulls Nailed::PRODUCTS["products"].each do |product,values| organization = values["organization"] repos = values["repos"] repos.each do |repo| if organization.nil? pulls = @client.pull_requests(repo) else pulls = @client.pull_requests("#{organization}/#{repo}") end pulls.each do |pr| db_handler = Pullrequest.first_or_create( :pr_number => pr.number, :title => pr.title, :state => pr.state, :url => pr.html_url, :created_at => pr.created_at, :repository_rname => repo ) Nailed.save_state(db_handler) end unless pulls.empty? write_pull_trends(repo) end unless repos.nil? end end |
#update_pull_states ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/nailed.rb', line 106 def update_pull_states pulls = Pullrequest.all pulls.each do |db_pull| number = db_pull.pr_number repo = db_pull.repository_rname org = Repository.get(repo).organization_oname github_pull = @client.pull_request("#{org}/#{repo}", number) if github_pull.state == "closed" db_pull.destroy end end end |
#write_pull_trends(repo) ⇒ Object
119 120 121 122 123 124 125 126 127 128 |
# File 'lib/nailed.rb', line 119 def write_pull_trends(repo) open = Pullrequest.count(:repository_rname => repo) db_handler = Pulltrend.first_or_create( :time => Time.new.strftime("%Y-%m-%d %H:%M:%S"), :open => open, :repository_rname => repo ) Nailed.save_state(db_handler) end |