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.
12 13 14 15 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 12 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.
10 11 12 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 10 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
28 29 30 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 28 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
33 34 35 36 37 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 33 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?
23 24 25 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 23 def invalid? !valid? end |
#valid? ⇒ Boolean
Match the line with the validation rules
18 19 20 |
# File 'lib/changelog/changelog_line/changelog_line.rb', line 18 def valid? raise 'ChangelogLine subclass must implement the valid? method' end |