Sha256: 7af7adc098bfc33a4a40dc21fee6c19fdfb814e37873850b470de5a801e4bc05

Contents?: true

Size: 585 Bytes

Versions: 5

Compression:

Stored size: 585 Bytes

Contents

# frozen_string_literal: true

module Shivers
  class Version
    def self.from_file(path)
      git_sha = ENV['GIT_SHA'] || 'LOCAL'
      metadata = git_sha.to_s

      base_version =
        if File.exist?(path)
          File.open(path) { |file| file.read.strip }
        else
          '0.0.0'
        end

      Version.new("#{base_version}+#{metadata}")
    end

    def initialize(version_string)
      @version = Semantic::Version.new(version_string)
    end

    def to_docker_tag
      to_s.gsub('+', '_').downcase
    end

    def to_s
      @version.to_s
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
shivers-0.6.0.pre.15 lib/shivers/version.rb
shivers-0.6.0.pre.14 lib/shivers/version.rb
shivers-0.6.0.pre.13 lib/shivers/version.rb
shivers-0.6.0.pre.12 lib/shivers/version.rb
shivers-0.6.0.pre.11 lib/shivers/version.rb