Class: CommitFormat::Formatter::Message
- Inherits:
-
Object
- Object
- CommitFormat::Formatter::Message
- Defined in:
- lib/commit_format/formatter.rb
Instance Method Summary collapse
- #end! ⇒ Object
-
#initialize ⇒ Message
constructor
A new instance of Message.
-
#line(string) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity.
- #to_s ⇒ Object
Constructor Details
#initialize ⇒ Message
Returns a new instance of Message.
48 49 50 51 52 |
# File 'lib/commit_format/formatter.rb', line 48 def initialize @lines = [] @paragraph = [] @code_block = false end |
Instance Method Details
#end! ⇒ Object
86 87 88 |
# File 'lib/commit_format/formatter.rb', line 86 def end! write_paragraph end |
#line(string) ⇒ Object
rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/commit_format/formatter.rb', line 54 def line(string) # rubocop:disable Metrics/MethodLength, Metrics/CyclomaticComplexity, Metrics/PerceivedComplexity if code_block_fence?(string) new_paragraph code_block! lines << string return elsif code_block? lines << string return elsif string.empty? # Line break new_paragraph line_break return elsif string.start_with? "#" write_paragraph heading string return elsif fixed_line?(string) new_paragraph lines << string return elsif heading_line?(string) write_paragraph lines << string return end paragraph << string # Line with line break and the end write_paragraph if string.end_with? " " end |
#to_s ⇒ Object
90 91 92 |
# File 'lib/commit_format/formatter.rb', line 90 def to_s @lines.join("\n") end |