Module: PDK::Util::Version

Defined in:
lib/pdk/util/version.rb

Class Method Summary collapse

Class Method Details

.git_refObject



26
27
28
29
30
31
32
33
# File 'lib/pdk/util/version.rb', line 26

def self.git_ref
  require 'pdk/util/git'
  source_git_dir = File.join(PDK::Util::Filesystem.expand_path('../../..', File.dirname(__FILE__)), '.git')

  return unless PDK::Util::Filesystem.directory?(source_git_dir)

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

.pdk_refObject



12
13
14
15
# File 'lib/pdk/util/version.rb', line 12

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

.pkg_shaObject



17
18
19
20
21
22
23
24
# File 'lib/pdk/util/version.rb', line 17

def self.pkg_sha
  if version_file && PDK::Util::Filesystem.exist?(version_file)
    ver = PDK::Util::Filesystem.read_file(version_file)
    sha = ver.strip.split('.')[5] unless ver.nil?
  end

  sha
end

.version_fileObject



35
36
37
38
39
40
# File 'lib/pdk/util/version.rb', line 35

def self.version_file
  require 'pdk/util'

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

.version_stringObject



6
7
8
9
10
# File 'lib/pdk/util/version.rb', line 6

def self.version_string
  require 'pdk/version'

  "#{PDK::VERSION} #{pdk_ref}".strip.freeze
end