mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
Add a method to the Haml module to scope file paths.
This commit is contained in:
parent
30b5e8ab9a
commit
0fae457e2f
2 changed files with 7 additions and 2 deletions
|
@ -884,7 +884,7 @@ module Haml
|
|||
def self.version
|
||||
return @@version if defined?(@@version)
|
||||
|
||||
numbers = File.read(File.dirname(__FILE__) + '/../VERSION').strip.split('.').map { |n| n.to_i }
|
||||
numbers = File.read(scope('VERSION')).strip.split('.').map { |n| n.to_i }
|
||||
@@version = {
|
||||
:major => numbers[0],
|
||||
:minor => numbers[1],
|
||||
|
@ -892,6 +892,11 @@ module Haml
|
|||
}
|
||||
end
|
||||
|
||||
# Returns the path of file relative to the Haml root.
|
||||
def self.scope(file) # :nodoc:
|
||||
File.join(File.dirname(__FILE__), '..', file)
|
||||
end
|
||||
|
||||
# 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)
|
||||
|
|
|
@ -35,7 +35,7 @@ if defined?(RAILS_ROOT)
|
|||
# because the new init file is sufficiently flexible
|
||||
# to not need updating.
|
||||
rails_init_file = File.join(RAILS_ROOT, 'vendor', 'plugins', 'haml', 'init.rb')
|
||||
haml_init_file = File.join(File.dirname(__FILE__), '..', '..', 'init.rb')
|
||||
haml_init_file = Haml.scope('init.rb')
|
||||
if File.exists?(rails_init_file)
|
||||
require 'fileutils'
|
||||
FileUtils.cp(haml_init_file, rails_init_file) unless FileUtils.cmp(rails_init_file, haml_init_file)
|
||||
|
|
Loading…
Reference in a new issue