ruby-changes:60659
From: Nobuyoshi <ko1@a...>
Date: Sun, 5 Apr 2020 12:00:25 +0900 (JST)
Subject: [ruby-changes:60659] ec03d13742 (master): Fallback if Pathname#relative_path_from fails
https://git.ruby-lang.org/ruby.git/commit/?id=ec03d13742 From ec03d137428f83f7d8819e13cb788fbd7d4e75c7 Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sun, 5 Apr 2020 11:49:11 +0900 Subject: Fallback if Pathname#relative_path_from fails It can fail due to different prefixes, e.g., drive letters or UNC paths on DOSish platform. diff --git a/tool/ruby_vm/helpers/dumper.rb b/tool/ruby_vm/helpers/dumper.rb index 00c301c..98104f4 100644 --- a/tool/ruby_vm/helpers/dumper.rb +++ b/tool/ruby_vm/helpers/dumper.rb @@ -25,7 +25,8 @@ class RubyVM::Dumper https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/helpers/dumper.rb#L25 end 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 += spec src = path.read mode: 'rt:utf-8:utf-8' diff --git a/tool/ruby_vm/helpers/scanner.rb b/tool/ruby_vm/helpers/scanner.rb index 593271a..ef6de81 100644 --- a/tool/ruby_vm/helpers/scanner.rb +++ b/tool/ruby_vm/helpers/scanner.rb @@ -20,7 +20,8 @@ class RubyVM::Scanner https://github.com/ruby/ruby/blob/trunk/tool/ruby_vm/helpers/scanner.rb#L20 attr_reader :__LINE__ 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 @__LINE__ = 1 @__FILE__ = src.to_path -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/