Sha256: 79945c6e62cbd26d0d2b844323a5fe34c11f1521389a8e901ca3396a43883b7f

Contents?: true

Size: 983 Bytes

Versions: 4

Compression:

Stored size: 983 Bytes

Contents

require 'pdk/version'
require 'pdk/cli/exec'
require 'pdk/util/git'
require 'pdk/logger'

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
        if version_file && File.exist?(version_file)
          ver = File.read(version_file)
          sha = ver.strip.split('.')[5] unless ver.nil?
        end

        sha
      end

      def self.git_ref
        source_git_dir = File.join(File.expand_path('../../..', File.dirname(__FILE__)), '.git')

        return unless File.directory?(source_git_dir)

        PDK::Util::Git.describe(source_git_dir)
      end

      def self.version_file
        # FIXME: this gets called a LOT and doesn't currently get cached
        PDK::Util.find_upwards('PDK_VERSION', File.dirname(__FILE__))
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
pdk-1.13.0 lib/pdk/util/version.rb
pdk-1.12.0 lib/pdk/util/version.rb
pdk-1.11.1 lib/pdk/util/version.rb
pdk-1.11.0 lib/pdk/util/version.rb