Move the Haml::VERSION-generation logic into Haml.version.

This commit is contained in:
Nathan Weizenbaum 2008-04-10 22:01:25 -07:00
parent 0fae457e2f
commit c38202800d
1 changed files with 4 additions and 1 deletions

View File

@ -881,6 +881,7 @@ $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
module Haml
# 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.
def self.version
return @@version if defined?(@@version)
@ -890,6 +891,8 @@ module Haml
:minor => numbers[1],
:teeny => numbers[2]
}
@@version[:string] = [:major, :minor, :teeny].map { |comp| @@version[comp] }.compact.join('.')
@@version
end
# Returns the path of file relative to the Haml root.
@ -899,7 +902,7 @@ module Haml
# A string representing the version of Haml.
# A more fine-grained representation is generated by Haml.version.
VERSION = [:major, :minor, :teeny].map { |comp| version[comp] }.compact.join('.') unless defined?(Haml::VERSION)
VERSION = version[:string] unless defined?(Haml::VERSION)
# This method is called by init.rb,
# which is run by Rails on startup.