module Haml::Version
def version
-
({Symbol => String/Fixnum})
- The version hash
def version return @@version if defined?(@@version) numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i } name = File.read(scope('VERSION_NAME')).strip @@version = { :major => numbers[0], :minor => numbers[1], :teeny => numbers[2], :name => name } @@version[:number] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') @@version[:string] = @@version[:number].dup if File.exists?(scope('REVISION')) rev = File.read(scope('REVISION')).strip rev = nil if rev !~ /^([a-f0-9]+|\(.*\))$/ end if (rev.nil? || rev == '(unknown)') && File.exists?(scope('.git/HEAD')) rev = File.read(scope('.git/HEAD')).strip if rev =~ /^ref: (.*)$/ rev = File.read(scope(".git/#{$1}")).strip end end if rev @@version[:rev] = rev unless rev[0] == ?( @@version[:string] << "." << rev[0...7] end @@version[:string] << " (#{name})" end @@version end