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

Handles Haml version-reporting. Haml not only reports the standard three version numbers, but its Git revision hash as well, if it was installed from Git.

### Methods

version

### Included Modules

Haml::Util

### Public Instance methods

version()

Returns a hash representing the version of Haml. The `:major`, `:minor`, and `:teeny` keys have their respective numbers as Fixnums. The `:name` key has the name of the version. The `:string` key contains a human-readable string representation of the version. The `:number` key is the major, minor, and teeny keys separated by periods. If Haml is checked out from Git, the `:rev` key will have the revision hash. For example:

        {
          :string => "2.1.0.9616393",
          :rev    => "9616393b8924ef36639c7e82aa88a51a24d16949",
          :number => "2.1.0",
          :major  => 2, :minor => 1, :teeny => 0
        }

If a prerelease version of Haml is being used, the `:string` and `:number` fields will reflect the full version (e.g. `"2.2.beta.1"`), and the `:teeny` field will be `-1`. A `:prerelease` key will contain the name of the prerelease (e.g. `"beta"`), and a `:prerelease_number` key will contain the rerelease number. For example:

        {
          :string => "3.0.beta.1",
          :number => "3.0.beta.1",
          :major => 3, :minor => 0, :teeny => -1,
          :prerelease => "beta",
          :prerelease_number => 1
        }

@return [{Symbol => String/Fixnum}] The version hash

[Source]

        # File lib/haml/version.rb, line 42
    42:     def version
    43:       return @@version if defined?(@@version)
    44:
    45:       numbers = File.read(scope('VERSION')).strip.split('.').
    46:         map {|n| n =~ /^[0-9]+$/ ? n.to_i : n}
    47:       name = File.read(scope('VERSION_NAME')).strip
    48:       @@version = {
    49:         :major => numbers[0],
    50:         :minor => numbers[1],
    51:         :teeny => numbers[2],
    52:         :name => name
    53:       }
    54:
    55:       if numbers[3].is_a?(String)
    56:         @@version[:teeny] = -1
    57:         @@version[:prerelease] = numbers[3]
    58:         @@version[:prerelease_number] = numbers[4]
    59:       end
    60:
    61:       @@version[:number] = numbers.join('.')
    62:       @@version[:string] = @@version[:number].dup
    63:
    64:       if rev = revision_number
    65:         @@version[:rev] = rev
    66:         unless rev[0] == ?(
    67:           @@version[:string] << "." << rev[0...7]
    68:         end
    69:       end
    70:
    71:       @@version[:string] << " (#{name})"
    72:       @@version
    73:     end

[Validate]