mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Fallback if Pathname#relative_path_from fails
It can fail due to different prefixes, e.g., drive letters or UNC paths on DOSish platform.
This commit is contained in:
parent
df275179bd
commit
ec03d13742
2 changed files with 4 additions and 2 deletions
|
@ -25,7 +25,8 @@ class RubyVM::Dumper
|
||||||
end
|
end
|
||||||
|
|
||||||
def new_erb spec
|
def new_erb spec
|
||||||
path = Pathname.new(__FILE__).relative_path_from(Pathname.pwd).dirname
|
path = Pathname.new(__FILE__)
|
||||||
|
path = (path.relative_path_from(Pathname.pwd) rescue path).dirname
|
||||||
path += '../views'
|
path += '../views'
|
||||||
path += spec
|
path += spec
|
||||||
src = path.read mode: 'rt:utf-8:utf-8'
|
src = path.read mode: 'rt:utf-8:utf-8'
|
||||||
|
|
|
@ -20,7 +20,8 @@ class RubyVM::Scanner
|
||||||
attr_reader :__LINE__
|
attr_reader :__LINE__
|
||||||
|
|
||||||
def initialize path
|
def initialize path
|
||||||
src = Pathname.new(__FILE__).relative_path_from(Pathname.pwd).dirname
|
src = Pathname.new(__FILE__)
|
||||||
|
src = (src.relative_path_from(Pathname.pwd) rescue src).dirname
|
||||||
src += path
|
src += path
|
||||||
@__LINE__ = 1
|
@__LINE__ = 1
|
||||||
@__FILE__ = src.to_path
|
@__FILE__ = src.to_path
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue