lib/grizzled/fileutil/includer.rb in grizzled-ruby-0.1.7 vs lib/grizzled/fileutil/includer.rb in grizzled-ruby-0.1.8
- old
+ new
@@ -78,22 +78,25 @@
nil
end
end
# Internal fake URI
- class FakeURI < URI::Generic
+ class FakeURI
+ attr_accessor :path
def initialize(path)
- super(scheme=nil,
- userinfo=nil,
- host=nil,
- port=nil,
- registry=nil,
- path=path,
- opaque=nil,
- query=nil,
- fragment=nil)
+ @fake_methods = [:scheme, :userinfo, :host, :port, :registry, :opaque,
+ :query, :fragment]
+ @path = path
end
+
+ def method_missing(meth, *args, &block)
+ if @fake_methods.include? meth
+ nil
+ else
+ raise NoMethodError.new("Undefined method: #{meth.to_s}")
+ end
+ end
end
# == Introduction
#
# An +Includer+ object preprocesses a text file, resolve _include_
@@ -251,11 +254,14 @@
# Could be a relative path. Should be relative to the parent input.
pathname = Pathname.new(source)
if not pathname.absolute?
# Not an absolute path, and the including source has a path
# (i.e., wasn't a string). Make this one relative to the path.
- uri = cur_uri.clone
- uri.path = File.join(::File.dirname(cur_uri.path), source)
+ parent_path = cur_uri.path
+ abs = File.absolute_path(
+ File.join(::File.dirname(cur_uri.path), source)
+ )
+ uri = FakeURI.new(abs)
end
end
open_source(uri)
end