Module: Haml::Version
Constant Summary
Constants included from Util
Instance Method Summary collapse
-
#version ⇒ Object
Returns a hash representing the version of Haml.
Methods included from Util
#def_static_method, #enum_with_index, #has?, #map_hash, #map_keys, #map_vals, #merge_adjacent_strings, #powerset, #ruby1_8?, #scope, #static_method_name, #to_hash
Instance Method Details
#version ⇒ Object
Returns a hash representing the version of Haml. The :major, :minor, and :teeny keys have their respective numbers. The :string key contains a human-readable string representation of the version. If Haml is checked out from Git, the :rev key will have the revision hash.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/haml/version.rb', line 12 def version return @@version if defined?(@@version) numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i } @@version = { :major => numbers[0], :minor => numbers[1], :teeny => numbers[2] } @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.') 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] << "." @@version[:string] << rev[0...7] end end @@version end |