Skip to content

Commit

Permalink
Fix load and require for absolute paths
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamcat4 committed Jul 14, 2010
1 parent 0a89728 commit e7d585b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions lib/script.rb
Expand Up @@ -52,7 +52,11 @@ def initialize(main_file) # :yields: self
# from those sub files.

def load(file, wrap = false)
load_in_module(File.join(@__dir, file))
if file =~ /^\//
load_in_module(file)
else
load_in_module(File.join(@__dir, file))
end
true
rescue MissingFile
super
Expand All @@ -70,7 +74,11 @@ def load(file, wrap = false)
def require(feature)
unless @__loaded_features[feature]
@__loaded_features[feature] = true
file = File.join(@__dir, feature)
if feature =~ /^\//
file = feature
else
file = File.join(@__dir, feature)
end
file += ".rb" unless /\.rb$/ =~ file
load_in_module(file)
end
Expand Down

0 comments on commit e7d585b

Please sign in to comment.