Sha256: ae42faae3142004b7281cb80cf8d7abc6c56a56980a3b173d17a53004cd1e795

Contents?: true

Size: 863 Bytes

Versions: 2

Compression:

Stored size: 863 Bytes

Contents

require 'pdk/version'
require 'pdk/cli/exec'

module PDK
  module Util
    module Version
      def self.version_string
        "#{PDK::VERSION} #{pdk_ref}".strip.freeze
      end

      def self.pdk_ref
        ref = "#{pkg_sha} #{git_ref}".strip
        ref.empty? ? nil : "(#{ref})"
      end

      def self.pkg_sha
        version_file = File.join(File.expand_path('../../..', File.dirname(__FILE__)), 'VERSION')

        if File.exist? version_file
          ver = File.read(version_file)
          sha = ver.strip.split('.')[-1] unless ver.nil?
        end

        sha
      end

      def self.git_ref
        ref_result = PDK::CLI::Exec.git('--git-dir', File.join(File.expand_path('../../..', File.dirname(__FILE__)), '.git'), 'describe', '--all', '--long')

        ref_result[:stdout].strip if ref_result[:exit_code].zero?
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
pdk-0.3.0 lib/pdk/util/version.rb
pdk-0.2.0 lib/pdk/util/version.rb