Class: Release::Notes::Tag
- Inherits:
-
Object
- Object
- Release::Notes::Tag
- Includes:
- Configurable
- Defined in:
- lib/release/notes/tag.rb
Instance Attribute Summary collapse
-
#_hashes ⇒ Object
Returns the value of attribute _hashes.
-
#previous_tag ⇒ Object
readonly
Returns the value of attribute previous_tag.
-
#tag ⇒ Object
readonly
Returns the value of attribute tag.
Instance Method Summary collapse
-
#all_labels ⇒ Array
private
Array of strings containing all labels.
-
#commits_available? ⇒ Boolean
private
Are there git sha's with commits?.
-
#formatted_date(date = nil) ⇒ String
private
Formats a supplied date.
-
#header ⇒ String
private
Generate header title.
-
#initialize(tag:, writer:, previous_tag:) ⇒ Tag
constructor
Release::Notes::Tag initializer.
-
#log_commits ⇒ Hash
private
Creates new commit objects from the @_commits object.
-
#perform ⇒ Object
Adds log messages to @_commits variable, and if there are commits that need to be added to changelog, add the header and associated log messages.
- #standard_title(title) ⇒ Object private
-
#store_commits ⇒ Object
private
Adds log messages to @_commits.
-
#system_log(**opts) ⇒ String
private
Create new system object that contains log messages between tag_from and tag_to with the relevant options.
-
#tag_date ⇒ String
private
Transform tag into date.
-
#title(title) ⇒ String
private
Title or formatted tag date.
-
#titles ⇒ Array
private
Array of strings containing all titles.
Constructor Details
#initialize(tag:, writer:, previous_tag:) ⇒ Tag
Release::Notes::Tag initializer
17 18 19 20 21 22 23 24 |
# File 'lib/release/notes/tag.rb', line 17 def initialize(tag:, writer:, previous_tag:) @tag = tag @writer = writer @previous_tag = previous_tag @_commits = {} @_hashes = [] end |
Instance Attribute Details
#_hashes ⇒ Object
Returns the value of attribute _hashes.
7 8 9 |
# File 'lib/release/notes/tag.rb', line 7 def _hashes @_hashes end |
#previous_tag ⇒ Object (readonly)
Returns the value of attribute previous_tag.
8 9 10 |
# File 'lib/release/notes/tag.rb', line 8 def previous_tag @previous_tag end |
#tag ⇒ Object (readonly)
Returns the value of attribute tag.
8 9 10 |
# File 'lib/release/notes/tag.rb', line 8 def tag @tag end |
Instance Method Details
#all_labels ⇒ Array (private)
Array of strings containing all labels
128 129 130 |
# File 'lib/release/notes/tag.rb', line 128 def all_labels [config_features, config_bugs, config_misc] end |
#commits_available? ⇒ Boolean (private)
Are there git sha's with commits?
53 54 55 |
# File 'lib/release/notes/tag.rb', line 53 def commits_available? @_commits.present? end |
#formatted_date(date = nil) ⇒ String (private)
Formats a supplied date
64 65 66 |
# File 'lib/release/notes/tag.rb', line 64 def formatted_date(date = nil) DateFormatter.new(date).humanize end |
#header ⇒ String (private)
Generate header title
73 74 75 |
# File 'lib/release/notes/tag.rb', line 73 def header config_header_title_type.yield_self { |t| title(t) } # config_header_title = "tag" end |
#log_commits ⇒ Hash (private)
Creates new commit objects from the @_commits object
82 83 84 85 86 |
# File 'lib/release/notes/tag.rb', line 82 def log_commits @_commits.each do |key, val| Commits.new(title: titles[key], value: val, writer: @writer, tagger: self).perform end end |
#perform ⇒ Object
Adds log messages to @_commits variable, and if there are commits that need to be added to changelog, add the header and associated log messages
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/release/notes/tag.rb', line 32 def perform store_commits # adds to @_commits if commits_available? # true writer_digest_header(header) # <File:./release-notes.tmp.md (closed)> log_commits # hash [0,1,2...], messages for sha end self rescue MissingTag => e $stderr.puts "<#{e.class.name.demodulize}>: #{e}" # rubocop:disable Style/StderrPuts raise end |
#standard_title(title) ⇒ Object (private)
159 160 161 |
# File 'lib/release/notes/tag.rb', line 159 def standard_title(title) title == "tag" ? tag : formatted_date(tag_date) end |
#store_commits ⇒ Object (private)
Adds log messages to @_commits
102 103 104 105 106 107 108 109 |
# File 'lib/release/notes/tag.rb', line 102 def store_commits all_labels.each_with_index do |lab, i| system_log(label: lab).tap { |str| @_commits[i] = str if str.present? } end # if log_all = true @_commits[all_labels.size] = system_log(log_all: true) if config_log_all end |
#system_log(**opts) ⇒ String (private)
Create new system object that contains log messages between tag_from and tag_to with the relevant options
119 120 121 |
# File 'lib/release/notes/tag.rb', line 119 def system_log(**opts) System.new({ tag_from: previous_tag, tag_to: tag }.merge(opts)).log end |
#tag_date ⇒ String (private)
Transform tag into date
93 94 95 |
# File 'lib/release/notes/tag.rb', line 93 def tag_date System.tag_date(tag: tag) end |
#title(title) ⇒ String (private)
Title or formatted tag date
tag as the title, if not use the tag date
150 151 152 153 154 155 156 157 |
# File 'lib/release/notes/tag.rb', line 150 def title(title) return standard_title(title) unless config_update_release_notes_before_tag? && tag == "HEAD" formatted_date unless title == "tag" return config_newest_tag if config_newest_tag.present? raise MissingTag, "No tag version was passed as an option when generating release notes" end |
#titles ⇒ Array (private)
Array of strings containing all titles
137 138 139 140 |
# File 'lib/release/notes/tag.rb', line 137 def titles [config_feature_title, config_bug_title, config_misc_title, config_log_all_title] end |