Class: Release::Notes::Commits
- Inherits:
-
Object
- Object
- Release::Notes::Commits
- Includes:
- Configurable
- Defined in:
- lib/release/notes/commits.rb
Constant Summary collapse
- REGEX_DELIMETER =
/(?=-)/
Instance Attribute Summary collapse
-
#title ⇒ Object
readonly
Returns the value of attribute title.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Instance Method Summary collapse
-
#choose_messages_by_hash ⇒ Array
private
Determine what messages will be added to final output.
-
#create_commits_hash(arr, hsh) ⇒ String
private
Create the commits hash.
-
#duplicate_commit?(key) ⇒ Boolean
private
Determines whether key has already been added to the release_notes.
-
#initialize(title:, value:, writer:, tagger:) ⇒ Commits
constructor
Release::Notes::Commits initializer method.
-
#join_messages(arr) ⇒ String
private
Transforms an array of messages into a single.
-
#output_unique_messages(messages) ⇒ String
private
Log messages without duplicates.
-
#perform ⇒ File
Perform method.
-
#remove_duplicate_hashes(obj) ⇒ Array
private
Remove duplicate log messages.
-
#split_commits ⇒ Hash
private
Split commits by sha.
-
#split_values(&_block) ⇒ Hash
private
Split messages by sha.
Constructor Details
#initialize(title:, value:, writer:, tagger:) ⇒ Commits
Release::Notes::Commits initializer method
19 20 21 22 23 24 25 |
# File 'lib/release/notes/commits.rb', line 19 def initialize(title:, value:, writer:, tagger:) @title = title @value = value @writer = writer @tagger = tagger end |
Instance Attribute Details
#title ⇒ Object (readonly)
Returns the value of attribute title.
9 10 11 |
# File 'lib/release/notes/commits.rb', line 9 def title @title end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
9 10 11 |
# File 'lib/release/notes/commits.rb', line 9 def value @value end |
Instance Method Details
#choose_messages_by_hash ⇒ Array (private)
Determine what messages will be added to final output
50 51 52 53 54 |
# File 'lib/release/notes/commits.rb', line 50 def split_commits.tap do |obj| remove_duplicate_hashes(obj) end end |
#create_commits_hash(arr, hsh) ⇒ String (private)
Create the commits hash
64 65 66 |
# File 'lib/release/notes/commits.rb', line 64 def create_commits_hash(arr, hsh) hsh[arr[0].strip] = arr[1..-1].join end |
#duplicate_commit?(key) ⇒ Boolean (private)
Determines whether key has already been added to the release_notes
75 76 77 |
# File 'lib/release/notes/commits.rb', line 75 def duplicate_commit?(key) config_single_label && @tagger._hashes.include?(key) end |
#join_messages(arr) ⇒ String (private)
Transforms an array of messages into a single
86 87 88 |
# File 'lib/release/notes/commits.rb', line 86 def (arr) "#{arr.join(NEWLINE)}#{NEWLINE}" end |
#output_unique_messages(messages) ⇒ String (private)
Log messages without duplicates
97 98 99 |
# File 'lib/release/notes/commits.rb', line 97 def () writer_digest_title(title: title, log_message: ()) end |
#perform ⇒ File
Perform method
32 33 34 35 36 37 38 39 40 41 |
# File 'lib/release/notes/commits.rb', line 32 def perform .tap do |obj| next if obj.empty? @tagger._hashes += obj.keys (obj.values) end self end |
#remove_duplicate_hashes(obj) ⇒ Array (private)
Remove duplicate log messages
108 109 110 |
# File 'lib/release/notes/commits.rb', line 108 def remove_duplicate_hashes(obj) obj.keys.each { |key| obj.delete(key) if duplicate_commit?(key) } end |
#split_commits ⇒ Hash (private)
Split commits by sha
117 118 119 120 121 122 123 |
# File 'lib/release/notes/commits.rb', line 117 def split_commits split_values do |arr, obj| arr.split(REGEX_DELIMETER).tap do |split_arr| create_commits_hash(split_arr, obj) # "- Add our own release notes" end end end |
#split_values(&_block) ⇒ Hash (private)
Split messages by sha
NEWLINE = "\n"
134 135 136 137 138 |
# File 'lib/release/notes/commits.rb', line 134 def split_values(&_block) value.split(NEWLINE).each_with_object({}) do |arr, obj| yield arr, obj end end |