Class: Danger::GitHub
- Inherits:
-
Object
- Object
- Danger::GitHub
- Defined in:
- lib/danger/request_sources/github.rb
Instance Attribute Summary collapse
-
#ci_source ⇒ Object
Returns the value of attribute ci_source.
-
#pr_json ⇒ Object
Returns the value of attribute pr_json.
Instance Method Summary collapse
- #api_url ⇒ Object
- #get_details ⇒ Object
-
#initialize(ci_source) ⇒ GitHub
constructor
A new instance of GitHub.
- #latest_pr_commit_ref ⇒ Object
- #pr_body ⇒ Object
- #pr_title ⇒ Object
Constructor Details
#initialize(ci_source) ⇒ GitHub
Returns a new instance of GitHub.
9 10 11 |
# File 'lib/danger/request_sources/github.rb', line 9 def initialize(ci_source) self.ci_source = ci_source end |
Instance Attribute Details
#ci_source ⇒ Object
Returns the value of attribute ci_source.
7 8 9 |
# File 'lib/danger/request_sources/github.rb', line 7 def ci_source @ci_source end |
#pr_json ⇒ Object
Returns the value of attribute pr_json.
7 8 9 |
# File 'lib/danger/request_sources/github.rb', line 7 def pr_json @pr_json end |
Instance Method Details
#api_url ⇒ Object
13 14 15 |
# File 'lib/danger/request_sources/github.rb', line 13 def api_url "https://api.github.com/repos/#{ci_source.repo_slug}/pulls/#{ci_source.pull_request_id}" end |
#get_details ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'lib/danger/request_sources/github.rb', line 17 def get_details response = REST.get api_url if response.ok? self.pr_json = JSON.parse(response.body) else puts "Something went wrong getting GitHub details for #{api_url} - (#{response.status_code})" puts response.body raise "Could not get the pull request details from GitHub." end end |
#latest_pr_commit_ref ⇒ Object
28 29 30 |
# File 'lib/danger/request_sources/github.rb', line 28 def latest_pr_commit_ref self.pr_json['base']['sha'] end |
#pr_body ⇒ Object
36 37 38 |
# File 'lib/danger/request_sources/github.rb', line 36 def pr_body self.pr_json['body'] end |
#pr_title ⇒ Object
32 33 34 |
# File 'lib/danger/request_sources/github.rb', line 32 def pr_title self.pr_json['title'] end |