Class: ChangelogGenerator::PullRequest
- Inherits:
-
Object
- Object
- ChangelogGenerator::PullRequest
- Defined in:
- lib/changelog_generator/pull_request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#changelog_text ⇒ Object
Returns the value of attribute changelog_text.
-
#head_sha ⇒ Object
Returns the value of attribute head_sha.
-
#issues ⇒ Object
Returns the value of attribute issues.
-
#merged_at ⇒ Object
Returns the value of attribute merged_at.
-
#number ⇒ Object
Returns the value of attribute number.
-
#title ⇒ Object
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(args) ⇒ PullRequest
constructor
A new instance of PullRequest.
-
#link_text(user, repo, formatting_style) ⇒ Object
- Generates a link snippet for this PR with desired text formatting Params:
user - The username of the repo owner
repo - The name of the github repository
formatting_style -
The text formatting style symbol.
- The name of the github repository
- The username of the repo owner
- Generates a link snippet for this PR with desired text formatting Params:
Constructor Details
#initialize(args) ⇒ PullRequest
Returns a new instance of PullRequest.
22 23 24 25 26 |
# File 'lib/changelog_generator/pull_request.rb', line 22 def initialize(args) args.each do |k,v| instance_variable_set("@#{k}", v) unless v.nil? end end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
4 5 6 |
# File 'lib/changelog_generator/pull_request.rb', line 4 def body @body end |
#changelog_text ⇒ Object
Returns the value of attribute changelog_text.
6 7 8 |
# File 'lib/changelog_generator/pull_request.rb', line 6 def changelog_text @changelog_text end |
#head_sha ⇒ Object
Returns the value of attribute head_sha.
7 8 9 |
# File 'lib/changelog_generator/pull_request.rb', line 7 def head_sha @head_sha end |
#issues ⇒ Object
Returns the value of attribute issues.
9 10 11 |
# File 'lib/changelog_generator/pull_request.rb', line 9 def issues @issues end |
#merged_at ⇒ Object
Returns the value of attribute merged_at.
8 9 10 |
# File 'lib/changelog_generator/pull_request.rb', line 8 def merged_at @merged_at end |
#number ⇒ Object
Returns the value of attribute number.
5 6 7 |
# File 'lib/changelog_generator/pull_request.rb', line 5 def number @number end |
#title ⇒ Object
Returns the value of attribute title.
3 4 5 |
# File 'lib/changelog_generator/pull_request.rb', line 3 def title @title end |
Class Method Details
.from_github_pr(github_pr) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/changelog_generator/pull_request.rb', line 11 def self.from_github_pr(github_pr) self.new({ title: github_pr['title'], body: github_pr.body.body, number: github_pr['number'], changelog_text: changelog_from_pr(github_pr), head_sha: github_pr.head.sha, merged_at: github_pr.merged_at }) end |
Instance Method Details
#link_text(user, repo, formatting_style) ⇒ Object
Generates a link snippet for this PR with desired text formatting Params:
user-
The username of the repo owner
repo-
The name of the github repository
formatting_style-
The text formatting style symbol
33 34 35 36 37 38 39 40 |
# File 'lib/changelog_generator/pull_request.rb', line 33 def link_text(user, repo, formatting_style) if formatting_style == :slack return "<https://github.com/#{user}/#{repo}/pull/#{self.number}|##{self.number}> " elsif formatting_style == :markdown return "[##{self.number}](https://github.com/#{user}/#{repo}/pull/#{self.number}) " end return "" end |