module Pwrake::GfarmPath
Public Instance Methods
from_fs(x)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 66 def from_fs(x) Pathname(x).relative_path_from(@@fs_subdir) end
from_local(x)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 57 def from_local(x) pn = Pathname(x) if pn.absolute? pn.relative_path_from(@@local_mountpoint) else Pathname.pwd.relative_path_from(@@local_mountpoint) + pn end end
fs_to_local(x)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 84 def fs_to_local(x) x = from_fs(x) x = to_local(x) x.to_s end
gfarm2fs?(d=nil)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 43 def gfarm2fs?(d=nil) d ||= @@local_mountpoint mount_type = nil open('/etc/mtab','r') do |f| f.each_line do |l| if /#{d} (?:type )?(\S+)/o =~ l mount_type = $1 break end end end /gfarm2fs/ =~ mount_type end
gfpath(file='.')
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 90 def gfpath(file='.') begin IO.popen("gfstat '#{file}'") do |f| if /File: "([^"]+)"/ =~ f.gets #" return $1 end end rescue end nil end
local_to_fs(x)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 78 def local_to_fs(x) x = from_local(x) x = to_fs(x) x.to_s end
mountpoint()
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 22 def mountpoint @@local_mountpoint end
mountpoint=(d)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 18 def mountpoint=(d) @@local_mountpoint = Pathname.new(d) end
mountpoint_of_cwd()
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 7 def mountpoint_of_cwd path = Pathname.pwd while !path.mountpoint? path = path.parent end path end
pwd()
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 39 def pwd Pathname.pwd.relative_path_from(@@local_mountpoint) end
subdir()
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 35 def subdir @@fs_subdir.to_s end
subdir=(d)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 26 def subdir=(d) if d @@fs_subdir = Pathname.new(d) if @@fs_subdir.relative? @@fs_subdir = Pathname.new('/') + @@fs_subdir end end end
to_fs(x)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 70 def to_fs(x) @@fs_subdir + Pathname(x) end
to_local(x)
click to toggle source
# File lib/pwrake/gfarm/gfarm_path.rb, line 74 def to_local(x) @@local_mountpoint + Pathname(x) end