Sha256: f8a99bbbccf3430cc723a39c3ff004f30b9c0f65605f719181c760354651fa66

Contents?: true

Size: 847 Bytes

Versions: 5

Compression:

Stored size: 847 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

5 entries across 5 versions & 1 rubygems

Version Path
danger-changelog-0.6.0 lib/changelog/changelog_line/changelog_line_parser.rb
danger-changelog-0.5.0 lib/changelog/changelog_line/changelog_line_parser.rb
danger-changelog-0.4.2 lib/changelog/changelog_line/changelog_line_parser.rb
danger-changelog-0.4.1 lib/changelog/changelog_line/changelog_line_parser.rb
danger-changelog-0.4.0 lib/changelog/changelog_line/changelog_line_parser.rb