Sha256: 5178fc368767f8676ff1547de882acafd733f1b8111ab9905e2bb72756d8cb07

Contents?: true

Size: 1.2 KB

Versions: 1

Compression:

Stored size: 1.2 KB

Contents

# frozen_string_literal: true

module GFSM
  module Data
    class ChangeType
      attr_reader :matcher, :title, :bump_type, :priority, :ignore_on_changelog, :commits

      def initialize(matcher, title, bump_type, priority, ignore_on_changelog)
        @matcher = matcher
        @title = title
        @bump_type = bump_type
        @priority = priority
        @ignore_on_changelog = ignore_on_changelog
        @commits = []
      end

      def bump_major?
        @bump_type == :major
      end
      
      def bump_minor?
        @bump_type == :minor
      end
      
      def bump_patch?
        @bump_type == :patch
      end

      def ignore_on_changelog?
        @ignore_on_changelog
      end

      def to_s
        @title
      end

      def to_changelog_entry
        "### #{@title}"
      end

      def self.find_highest_bump(change_types)
        highest_bump = :patch

        change_types.each do |change_type|
          if change_type.bump_major?
            highest_bump = :major

            # Early exit, it can't go higher than this!
            break
          elsif change_type.bump_minor?
            highest_bump = :minor
          end
        end

        highest_bump
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
gfsm-0.8.0 lib/data/change_type.rb