Sha256: bdd5d735fb193d68718fd9eb6afaee201f350624409ab3c9a2d69a35d589e159

Contents?: true

Size: 808 Bytes

Versions: 2

Compression:

Stored size: 808 Bytes

Contents

require_relative '../comparator/version'

class DevelopTagGenerator
  def initialize(tags)
    @tags = tags
  end

  def first_tag
    "dev-v0.0.1"
  end

  def next_develop_tag(to_increment)
    last_version = biggest_version
    case to_increment
    when "major"
      "dev-v#{last_version.major + 1}.0.0"
    when "minor"
      "dev-v#{last_version.major}.#{last_version.minor + 1}.0"
    when "patch"
      "dev-v#{last_version.major}.#{last_version.minor}.#{last_version.patch + 1}"
    end
  end

  def develop_tag_exists?
    @tags.any? { |tag| /^dev-v\d+.\d+.\d*$/ =~ tag }
  end

  private

  def biggest_version
    @tags.select { |tag| /^dev-v\d+.\d+.\d*$/ =~ tag }
         .map { |tag| tag.split("-v")[1] }
         .map { |version_string| Version.new(version_string) }
         .max
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
build_promotion_tool-0.1.2 lib/build_promotion_tool/generator/develop_tag_generator.rb
build_promotion_tool-0.1.1 lib/build_promotion_tool/generator/develop_tag_generator.rb