Sha256: a148d9c6f1e731dbee012023d003014df413d02957afb4fc3dcc4606369d5ef9

Contents?: true

Size: 1019 Bytes

Versions: 1

Compression:

Stored size: 1019 Bytes

Contents

module Rbbt
  VERSIONS = IndiferentHash.setup({})

  def self.add_version(file)
    dir = Path.caller_lib_dir(file)
    libname = File.basename(dir).sub('rbbt-','')
    return if VERSIONS.include? libname

    version = if dir.VERSION.exists?
      dir.VERSION.read
    elsif dir[".git"].exists?
      head = dir[".git"]["HEAD"].read.split(" ").last.strip
      dir[".git"][head].read.strip
    elsif libname.include?("-")
      name,_sep, v = libname.partition("-")
      if v =~ /^\d+\.\d+\.\d+$/
        libname = name
        v
      else
        nil
      end
    else
      nil
    end
    return if version.nil?

    VERSIONS[libname] = version
  end

  def self.versions
    versions = Rbbt::VERSIONS
    Gem.loaded_specs.keys.each do |gem|
      next unless gem.include? 'rbbt'
      iii gem
      name = gem.sub('rbbt-','')
      next if versions.include? name
      version =  Gem.loaded_specs[gem].version.version
      versions[name] = version
    end
    versions
  end

  Rbbt.add_version(__FILE__)
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rbbt-util-5.25.34 lib/rbbt/util/version.rb