Move method back to Pathname.

This commit is contained in:
Adam Vandenberg 2010-08-15 17:17:26 -07:00
parent 85b9c7eca1
commit 157425cc10

View File

@ -208,6 +208,21 @@ class Pathname
prefix = prefix.to_s prefix = prefix.to_s
self.to_s[0, prefix.length] == prefix self.to_s[0, prefix.length] == prefix
end end
def make_relative_symlink src
self.dirname.mkpath
Dir.chdir self.dirname do
# TODO use Ruby function so we get exceptions
# NOTE Ruby functions may work, but I had a lot of problems
rv=system 'ln', '-sf', src.relative_path_from(self.dirname)
unless rv and $? == 0
raise <<-EOS
Could not create symlink #{to_s}.
Check that you have permssions on #{self.dirname}
EOS
end
end
end
end end
# sets $n and $d so you can observe creation of stuff # sets $n and $d so you can observe creation of stuff
@ -228,17 +243,11 @@ module ObserverPathnameExtension
$d+=1 $d+=1
end end
def make_relative_symlink src def make_relative_symlink src
dirname.mkpath super
Dir.chdir dirname do
# TODO use Ruby function so we get exceptions
# NOTE Ruby functions may work, but I had a lot of problems
rv=system 'ln', '-sf', src.relative_path_from(dirname)
raise "Could not create symlink #{to_s}" unless rv and $? == 0
puts "ln #{to_s}" if ARGV.verbose? puts "ln #{to_s}" if ARGV.verbose?
$n+=1 $n+=1
end end
end end
end
$n=0 $n=0
$d=0 $d=0