Better handling of the Compass::VERSION scheme.
This commit is contained in:
parent
9ab44866bb
commit
d1a155b59a
@ -7,7 +7,12 @@ end
|
|||||||
|
|
||||||
module Compass
|
module Compass
|
||||||
extend Compass::Version
|
extend Compass::Version
|
||||||
VERSION = "#{version[:major]}.#{version[:minor]}.#{version[:patch]}"
|
def self.const_missing(const)
|
||||||
|
# This avoid reading from disk unless the VERSION is requested.
|
||||||
|
if const == :VERSION
|
||||||
|
version[:string]
|
||||||
|
end
|
||||||
|
end
|
||||||
def base_directory
|
def base_directory
|
||||||
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
||||||
end
|
end
|
||||||
|
@ -6,18 +6,12 @@ module Compass
|
|||||||
# The :rev key will have the current revision hash.
|
# The :rev key will have the current revision hash.
|
||||||
#
|
#
|
||||||
# This method swiped from Haml and then modified, some credit goes to Nathan Weizenbaum
|
# This method swiped from Haml and then modified, some credit goes to Nathan Weizenbaum
|
||||||
attr_writer :version
|
|
||||||
def version
|
def version
|
||||||
return @version if defined?(@version)
|
if defined?(@version)
|
||||||
|
@version
|
||||||
read_version_file
|
else
|
||||||
|
read_version
|
||||||
if r = revision
|
|
||||||
@version[:rev] = r
|
|
||||||
@version[:string] << " [#{r[0...7]}]"
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@version
|
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
@ -26,22 +20,20 @@ module Compass
|
|||||||
File.join(File.dirname(__FILE__), '..', '..', file)
|
File.join(File.dirname(__FILE__), '..', '..', file)
|
||||||
end
|
end
|
||||||
|
|
||||||
def read_version_file
|
def read_version
|
||||||
require 'yaml'
|
require 'yaml'
|
||||||
@version = YAML::load(File.read(scope('VERSION.yml')))
|
@version = YAML::load(File.read(scope('VERSION.yml')))
|
||||||
@version[:string] = "#{@version[:major]}.#{@version[:minor]}.#{@version[:patch]}"
|
|
||||||
@version[:teeny] = @version[:patch]
|
@version[:teeny] = @version[:patch]
|
||||||
|
@version[:string] = "#{@version[:major]}.#{@version[:minor]}.#{@version[:patch]}"
|
||||||
|
@version[:string] << ".#{@version[:build]}" if @version[:build]
|
||||||
|
if !ENV['OFFICIAL'] && r = revision
|
||||||
|
@version[:string] << ".dev.#{r[0..6]}"
|
||||||
|
end
|
||||||
|
@version
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision
|
def revision
|
||||||
revision_from_git || revision_from_file
|
revision_from_git
|
||||||
end
|
|
||||||
|
|
||||||
def revision_from_file
|
|
||||||
if File.exists?(scope('REVISION'))
|
|
||||||
rev = File.read(scope('REVISION')).strip
|
|
||||||
rev if rev =~ /[a-f0-9]+/
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def revision_from_git
|
def revision_from_git
|
||||||
@ -52,6 +44,5 @@ module Compass
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
Loading…
Reference in New Issue
Block a user