Class: WhatsupGithub::Row
- Inherits:
-
Object
- Object
- WhatsupGithub::Row
- Defined in:
- lib/whatsup_github/row.rb
Overview
Row to be converted to entry in future table
Instance Attribute Summary collapse
-
#assignee ⇒ Object
readonly
Returns the value of attribute assignee.
-
#author ⇒ Object
readonly
Returns the value of attribute author.
-
#author_url ⇒ Object
readonly
Returns the value of attribute author_url.
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#is_private ⇒ Object
readonly
Returns the value of attribute is_private.
-
#labels ⇒ Object
readonly
Returns the value of attribute labels.
-
#link ⇒ Object
readonly
Returns the value of attribute link.
-
#membership ⇒ Object
readonly
Returns the value of attribute membership.
-
#merge_commit ⇒ Object
readonly
Returns the value of attribute merge_commit.
-
#pr_number ⇒ Object
readonly
Returns the value of attribute pr_number.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Instance Method Summary collapse
- #date ⇒ Object
- #description ⇒ Object
-
#initialize(args) ⇒ Row
constructor
A new instance of Row.
- #labels_from_config ⇒ Object
- #magic_word ⇒ Object
- #parse_body ⇒ Object
- #required_labels ⇒ Object
- #type ⇒ Object
- #versions ⇒ Object
Constructor Details
#initialize(args) ⇒ Row
Returns a new instance of Row.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/whatsup_github/row.rb', line 18 def initialize(args) @repo = args[:repo] @repo_url = args[:repo_url] @is_private = args[:private] @title = args[:pr_title] @body = args[:pr_body] @date = args[:date] @labels = args[:pr_labels] @assignee = args[:assignee] @author = args[:author] @author_url = args[:author_url] @pr_number = args[:pr_number] @link = args[:pr_url] @merge_commit = args[:merge_commit_sha] @membership = args[:membership] @config = Config.instance end |
Instance Attribute Details
#assignee ⇒ Object (readonly)
Returns the value of attribute assignee.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def assignee @assignee end |
#author ⇒ Object (readonly)
Returns the value of attribute author.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def @author end |
#author_url ⇒ Object (readonly)
Returns the value of attribute author_url.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def @author_url end |
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def body @body end |
#is_private ⇒ Object (readonly)
Returns the value of attribute is_private.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def is_private @is_private end |
#labels ⇒ Object (readonly)
Returns the value of attribute labels.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def labels @labels end |
#link ⇒ Object (readonly)
Returns the value of attribute link.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def link @link end |
#membership ⇒ Object (readonly)
Returns the value of attribute membership.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def membership @membership end |
#merge_commit ⇒ Object (readonly)
Returns the value of attribute merge_commit.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def merge_commit @merge_commit end |
#pr_number ⇒ Object (readonly)
Returns the value of attribute pr_number.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def pr_number @pr_number end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
6 7 8 |
# File 'lib/whatsup_github/row.rb', line 6 def title @title end |
Instance Method Details
#date ⇒ Object
53 54 55 |
# File 'lib/whatsup_github/row.rb', line 53 def date @date.strftime('%B %-e, %Y') end |
#description ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/whatsup_github/row.rb', line 72 def description # If a PR body includes a phrase 'whatsnew', then parse the body. # If there are at least one required label but PR body does not include what's new, warn about missing 'whatsnew' if body.include?(magic_word) parse_body else = "MISSING #{magic_word} in the #{type} PR \##{pr_number}: \"#{title}\" assigned to #{assignee} (#{link})" puts end end |
#labels_from_config ⇒ Object
36 37 38 |
# File 'lib/whatsup_github/row.rb', line 36 def labels_from_config @config.labels end |
#magic_word ⇒ Object
44 45 46 |
# File 'lib/whatsup_github/row.rb', line 44 def magic_word @config.magic_word end |
#parse_body ⇒ Object
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/whatsup_github/row.rb', line 61 def parse_body # Split PR description in two parts by 'magic word', and take the second half description_splited = body.split(magic_word)[-1] # Convert new line separators to <br> tags newline_splited = description_splited.split("\n") cleaned_array = newline_splited.map { |e| e.delete "\r\*" } cleaned_array.delete('') striped_array = cleaned_array.map(&:strip) striped_array.join('<br/>') end |
#required_labels ⇒ Object
40 41 42 |
# File 'lib/whatsup_github/row.rb', line 40 def required_labels @config.required_labels end |
#type ⇒ Object
57 58 59 |
# File 'lib/whatsup_github/row.rb', line 57 def type (labels & labels_from_config).join(', ') end |
#versions ⇒ Object
48 49 50 51 |
# File 'lib/whatsup_github/row.rb', line 48 def versions label_versions = labels.select { |label| label.start_with?(/\d\./) } label_versions.join(', ') end |