mirror of
https://github.com/haml/haml.git
synced 2022-11-09 12:33:31 -05:00
[Haml] Move Version#scope to Util#scope.
This commit is contained in:
parent
56c2f83704
commit
f4ef490475
4 changed files with 15 additions and 6 deletions
|
@ -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'
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Add table
Reference in a new issue