Class: Release::Notes::Write
- Inherits:
-
Object
- Object
- Release::Notes::Write
- Includes:
- Configurable, Link
- Defined in:
- lib/release/notes/write.rb
Instance Method Summary collapse
-
#copy_over_notes ⇒ Object
private
Appends previous changelog to a temporary file.
-
#digest(str) ⇒ Object
Write strings to tempfile.
-
#digest_header(header) ⇒ Object
Adds formatted header to changelog.
-
#digest_title(title: nil, log_message: nil) ⇒ String
Formats titles to be added to the new file and removes tags from title if configured.
-
#format_line ⇒ String
private
If prettify_messages is true, remove the label keyword from log message else, just return the log message.
-
#header_present ⇒ String
private
Formats the header.
-
#initialize ⇒ Object
constructor
Release::Notes::Write initializer.
-
#link_message(log_message) ⇒ String
private
Returns the log message if message linking is not configured else, return the linked log_message.
-
#link_messages ⇒ String
private
Calls link_message method with a log message.
-
#new_temp_file_template ⇒ Object
private
Open temp file and output release notes header.
-
#prettify_linked_messages ⇒ String
private
Prettifies linked log messages.
-
#title_present ⇒ String
private
Formats the title.
-
#write_new_file ⇒ Object
append old file to new temp file overwrite output file with tmp file.
Constructor Details
#initialize ⇒ Object
Release::Notes::Write initializer
14 15 16 |
# File 'lib/release/notes/write.rb', line 14 def initialize new_temp_file_template end |
Instance Method Details
#copy_over_notes ⇒ Object (private)
Appends previous changelog to a temporary file
120 121 122 123 124 125 |
# File 'lib/release/notes/write.rb', line 120 def copy_over_notes File.open(config_temp_file, "a") do |f| f << NEWLINE IO.readlines(config_output_file)[2..-1].each { |line| f << line } end end |
#digest(str) ⇒ Object
Write strings to tempfile
23 24 25 |
# File 'lib/release/notes/write.rb', line 23 def digest(str) File.open(config_temp_file, "a") { |fi| fi << str } end |
#digest_header(header) ⇒ Object
Adds formatted header to changelog
47 48 49 50 |
# File 'lib/release/notes/write.rb', line 47 def digest_header(header) @header = header digest(header_present) end |
#digest_title(title: nil, log_message: nil) ⇒ String
Formats titles to be added to the new file and removes tags from title if configured
34 35 36 37 38 39 40 |
# File 'lib/release/notes/write.rb', line 34 def digest_title(title: nil, log_message: nil) @title = title @log_message = titles = title_present + format_line digest(titles) end |
#format_line ⇒ String (private)
If prettify_messages is true, remove the label keyword from log message else, just return the log message
91 92 93 94 95 |
# File 'lib/release/notes/write.rb', line 91 def format_line return "#{}#{NEWLINE}" if end |
#header_present ⇒ String (private)
Formats the header
72 73 74 |
# File 'lib/release/notes/write.rb', line 72 def header_present "#{NEWLINE}## #{@header}#{NEWLINE}" end |
#link_message(log_message) ⇒ String (private)
Returns the log message if message linking is not configured else, return the linked log_message
133 134 135 136 137 |
# File 'lib/release/notes/write.rb', line 133 def () return unless config_link_commits? link_lines(lines: ) end |
#link_messages ⇒ String (private)
Calls link_message method with a log message
102 103 104 |
# File 'lib/release/notes/write.rb', line 102 def @log_message end |
#new_temp_file_template ⇒ Object (private)
Open temp file and output release notes header
144 145 146 147 148 |
# File 'lib/release/notes/write.rb', line 144 def new_temp_file_template File.open(config_temp_file, "w") do |fi| fi << "# Release Notes#{NEWLINE}" end end |
#prettify_linked_messages ⇒ String (private)
Prettifies linked log messages
111 112 113 |
# File 'lib/release/notes/write.rb', line 111 def Prettify.new(line: ).perform end |
#title_present ⇒ String (private)
Formats the title
81 82 83 |
# File 'lib/release/notes/write.rb', line 81 def title_present "#{NEWLINE}#{@title}#{NEWLINE}#{NEWLINE}" end |
#write_new_file ⇒ Object
append old file to new temp file overwrite output file with tmp file
58 59 60 61 62 63 |
# File 'lib/release/notes/write.rb', line 58 def write_new_file copy_over_notes if config_release_notes_exist? && !config_force_rewrite? FileUtils.cp(config_temp_file, config_output_file) FileUtils.rm config_temp_file end |