Add a :number key to Haml.version.

This commit is contained in:
Nathan Weizenbaum 2009-06-29 21:54:53 -07:00
parent 7518015a1b
commit 94b742a8bb
1 changed files with 7 additions and 4 deletions

View File

@ -12,13 +12,15 @@ module 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",
# :major => 2, :minor => 1, :teeny => 0
# :string => "2.1.0.9616393",
# :rev => "9616393b8924ef36639c7e82aa88a51a24d16949",
# :number => "2.1.0",
# :major => 2, :minor => 1, :teeny => 0
# }
#
# @return [Hash<Symbol, String/Fixnum>] The version hash
@ -33,7 +35,8 @@ module Haml
:teeny => numbers[2],
:name => name
}
@@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
@@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