Module Haml::Version
In: lib/haml/version.rb

Methods

version  

Public Instance methods

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.

[Source]

    # File lib/haml/version.rb, line 8
 8:     def version
 9:       return @@version if defined?(@@version)
10: 
11:       numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
12:       @@version = {
13:         :major => numbers[0],
14:         :minor => numbers[1],
15:         :teeny => numbers[2]
16:       }
17:       @@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
18: 
19:       if File.exists?(scope('REVISION'))
20:         rev = File.read(scope('REVISION')).strip
21:         rev = nil if rev !~ /^([a-f0-9]+|\(.*\))$/
22:       end
23: 
24:       if (rev.nil? || rev == '(unknown)') && File.exists?(scope('.git/HEAD'))
25:         rev = File.read(scope('.git/HEAD')).strip
26:         if rev =~ /^ref: (.*)$/
27:           rev = File.read(scope(".git/#{$1}")).strip
28:         end
29:       end
30: 
31:       if rev
32:         @@version[:rev] = rev
33:         unless rev[0] == ?(
34:           @@version[:string] << "."
35:           @@version[:string] << rev[0...7]
36:         end
37:       end
38: 
39:       @@version
40:     end

[Validate]