class Danger::Changelog::ChangelogLine

An abstract CHANGELOG.md line.

Constants

DELIMITER
NON_DELIMITERS
PAIRED

Attributes

line[RW]
validation_result[RW]

Public Class Methods

new(line) click to toggle source
# File lib/changelog/changelog_line/changelog_line.rb, line 12
def initialize(line)
  self.line = line
  self.validation_result = nil
end
validates_as_changelog_line?(_line) click to toggle source

Match the given line if it potentially represents the specific changelog line

# 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

Public Instance Methods

balanced?(line_with_parens) click to toggle source

stackoverflow.com/questions/25979364/ruby-regex-for-matching-brackets

# 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?() click to toggle source

Match the line with the validation rules opposite to valid?

# File lib/changelog/changelog_line/changelog_line.rb, line 23
def invalid?
  !valid?
end
valid?() click to toggle source

Match the line with the validation rules

# File lib/changelog/changelog_line/changelog_line.rb, line 18
def valid?
  raise 'ChangelogLine subclass must implement the valid? method'
end