Sha256: c214679366411e2156a480890997b21406e5445465a2bc2401a725718a20f563

Contents?: true

Size: 846 Bytes

Versions: 2

Compression:

Stored size: 846 Bytes

Contents

require 'changelog/changelog_line/changelog_entry_line'
require 'changelog/changelog_line/changelog_header_line'
require 'changelog/changelog_line/changelog_placeholder_line'

module Danger
  module Changelog
    # A parser of the CHANGELOG.md lines
    class ChangelogLineParser
      # Returns an instance of Changelog::ChangelogLine class based on the given line
      def self.parse(line)
        changelog_line_class = available_changelog_lines.find do |changelog_line|
          changelog_line.validates_as_changelog_line?(line)
        end
        return nil unless changelog_line_class
        changelog_line_class.new(line)
      end

      private_class_method

      def self.available_changelog_lines
        # Order is important
        [ChangelogPlaceholderLine, ChangelogEntryLine, ChangelogHeaderLine]
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
danger-changelog-0.3.0 lib/changelog/changelog_line/changelog_line_parser.rb
danger-changelog-0.2.1 lib/changelog/changelog_line/changelog_line_parser.rb