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.
-
#validation_result ⇒ Object
Returns the value of attribute validation_result.
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 14 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 11 def initialize(line) self.line = line self.validation_result = nil 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 |
#validation_result ⇒ Object
Returns the value of attribute validation_result.
9 10 11 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 9 def validation_result @validation_result end |
Class Method Details
.validates_as_changelog_line?(_line) ⇒ Boolean
Match the given line if it potentially represents the specific changelog line
27 28 29 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 27 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
32 33 34 35 36 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 32 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?
22 23 24 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 22 def invalid? !valid? end |
#valid? ⇒ Boolean
Match the line with the validation rules
17 18 19 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 17 def valid? raise 'ChangelogLine subclass must implement the valid? method' end |