diff --git a/lib/haml/template.rb b/lib/haml/template.rb index d12b38f4..0e400666 100644 --- a/lib/haml/template.rb +++ b/lib/haml/template.rb @@ -26,7 +26,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 = Haml.scope('init.rb') + haml_init_file = Haml::Util.scope('init.rb') begin if File.exists?(rails_init_file) require 'fileutils' diff --git a/lib/haml/util.rb b/lib/haml/util.rb index 7b37db8f..e7e123b1 100644 --- a/lib/haml/util.rb +++ b/lib/haml/util.rb @@ -8,6 +8,11 @@ module Haml RUBY_VERSION = ::RUBY_VERSION.split(".").map {|s| s.to_i} + # Returns the path of file relative to the Haml root. + def scope(file) + File.expand_path File.join(File.dirname(__FILE__), '..', '..', file) + end + def to_hash(arr) arr.compact.inject({}) {|h, (k, v)| h[k] = v; h} end diff --git a/lib/haml/version.rb b/lib/haml/version.rb index 6e822076..e2b33c37 100644 --- a/lib/haml/version.rb +++ b/lib/haml/version.rb @@ -1,5 +1,9 @@ +require 'haml/util' + module Haml module Version + include Haml::Util + # 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. @@ -38,10 +42,5 @@ module Haml @@version end - - # Returns the path of file relative to the Haml root. - def scope(file) # :nodoc: - File.expand_path File.join(File.dirname(__FILE__), '..', '..', file) - end end end diff --git a/test/haml/util_test.rb b/test/haml/util_test.rb index 834f8482..6151426d 100644 --- a/test/haml/util_test.rb +++ b/test/haml/util_test.rb @@ -1,9 +1,14 @@ #!/usr/bin/env ruby require File.dirname(__FILE__) + '/../test_helper' +require 'pathname' class UtilTest < Test::Unit::TestCase include Haml::Util + def test_scope + assert(File.exist?(scope("Rakefile"))) + end + def test_to_hash assert_equal({ :foo => 1,