Sha256: ab8dadeab4c73480c84326b23d0163ce75f2358c495761baf1af695215f6544f

Contents?: true

Size: 1.21 KB

Versions: 1

Compression:

Stored size: 1.21 KB

Contents

module RTM # :nodoc:
  module VERSION # :nodoc:
    unless self.const_defined?("MAJOR")
      require 'date'
      if Object.const_defined?("Gem") && rtmgem = Gem.loaded_specs["rtm"]
        # Try to determine version from Gem, if we're loaded from there
        today = rtmgem.date
      elsif File.exist?(File.join(File.dirname(__FILE__), "../../../.hg"))
        begin
          # Try to get the latest Mercurial commit date
           hg_date_string = `hg --cwd "#{File.dirname(__FILE__)}" parent --template "{date|isodate}"`
           today = Date.parse(hg_date_string)
         rescue Exception => e
           warn("We're running from Mercurial, but Mercurial binary 'hg' is not in system path (or something else with parsing version from hg went wront)")
         end
      end
      # Fall back to current day if not set before
      today ||= Date.today

      DATE = [today.year, today.month, today.day]
      ISODATE = "%04d-%02d-%02d" % DATE # => "2010-01-26"
      COMPACTDATE = "%04d%02d%02d" % DATE # => "20100126"

      MAJOR  = 0
      MINOR  = 3
      TINY   = 1
      BUILD  = ENV['BUILD_NUMBER'] || COMPACTDATE

      STRING = [MAJOR, MINOR, TINY].compact.join('.')

      SUMMARY = "rtm #{STRING}"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rtm-0.3.1 lib/rtm/version.rb