Sha256: 37b56b3087f2a089e2fe60486e15c78087ca0228f6dc32ab3f608a0aced01d07

Contents?: true

Size: 572 Bytes

Versions: 4

Compression:

Stored size: 572 Bytes

Contents

require 'shivers/version'

require 'semantic'

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

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

      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

4 entries across 4 versions & 1 rubygems

Version Path
shivers-0.6.0.pre.2 lib/shivers.rb
shivers-0.6.0.pre.1 lib/shivers.rb
shivers-0.5.0 lib/shivers.rb
shivers-0.4.0.pre.1 lib/shivers.rb