Class: Danger::Changelog::ChangelogLine
- Inherits:
-
Object
- Object
- Danger::Changelog::ChangelogLine
- Defined in:
- lib/changelog/changelog_line/changelog_line.rb
Overview
An abstract CHANGELOG.md line.
Direct Known Subclasses
ChangelogEntryLine, ChangelogHeaderLine, ChangelogPlaceholderLine
Constant Summary collapse
- NON_DELIMITERS =
/[^(){}\[\]]*/.freeze
- PAIRED =
/\(#{NON_DELIMITERS}\)|\{#{NON_DELIMITERS}\}|\[#{NON_DELIMITERS}\]/.freeze
- DELIMITER =
/[(){}\[\]]/.freeze
Instance Attribute Summary collapse
-
#line ⇒ Object
Returns the value of attribute line.
Class Method Summary collapse
-
.validates_as_changelog_line?(_line) ⇒ Boolean
Match the given line if it potentially represents the specific changelog line.
Instance Method Summary collapse
- #balanced?(line_with_parens) ⇒ Boolean
-
#initialize(line) ⇒ ChangelogLine
constructor
A new instance of ChangelogLine.
-
#invalid? ⇒ Boolean
Match the line with the validation rules opposite to valid?.
-
#valid? ⇒ Boolean
Match the line with the validation rules.
Constructor Details
#initialize(line) ⇒ ChangelogLine
Returns a new instance of ChangelogLine.
11 12 13 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 11 def initialize(line) self.line = line end |
Instance Attribute Details
#line ⇒ Object
Returns the value of attribute line.
9 10 11 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 9 def line @line end |
Class Method Details
.validates_as_changelog_line?(_line) ⇒ Boolean
Match the given line if it potentially represents the specific changelog line
26 27 28 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 26 def self.validates_as_changelog_line?(_line) abort "You need to include a function for #{self} for validates_as_changelog_line?" end |
Instance Method Details
#balanced?(line_with_parens) ⇒ Boolean
31 32 33 34 35 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 31 def balanced?(line_with_parens) line_with_parens = line_with_parens.dup line_with_parens.gsub!(PAIRED, ''.freeze) while line_with_parens =~ PAIRED line_with_parens !~ DELIMITER end |
#invalid? ⇒ Boolean
Match the line with the validation rules opposite to valid?
21 22 23 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 21 def invalid? !valid? end |
#valid? ⇒ Boolean
Match the line with the validation rules
16 17 18 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 16 def valid? raise 'ChangelogLine subclass must implement the valid? method' end |