lib/pa/cmd.rb in pa-1.1.3 vs lib/pa/cmd.rb in pa-1.1.4
- old
+ new
@@ -57,25 +57,24 @@
# @see File.readlink
def readlink(path)
File.readlink(get(path))
end
-
# change directory
#
# @param [String,Pa] path
def cd(path=ENV["HOME"], &blk)
- ::Dir.chdir(get(path), &blk)
+ Dir.chdir(get(path), &blk)
end
# chroot
# @see {Dir.chroot}
#
# @param [String] path
# @return [nil]
def chroot(path)
- ::Dir.chroot(get(path))
+ Dir.chroot(get(path))
end
# touch a blank file
#
# @overload touch(*paths, o={})
@@ -133,16 +132,16 @@
# @option o [Symbol] :tmpdir (ENV["TEMP"])
# @return [String] path
def mktmpdir(o={}, &blk)
p = _mktmpname(o)
File.mkdir(p)
- begin blk.call(p) ensure ::Dir.delete(p) end if blk
+ begin blk.call(p) ensure Dir.delete(p) end if blk
p
end # def mktmpdir
def home(user=nil)
- ::Dir.home
+ Dir.home
end
# make temp file
# @see mktmpdir
#
@@ -299,18 +298,17 @@
# a rename util
#
# @example
#
- # Pa.rename('/home/guten.jpg') {|pa| pa.name+'_1'+pa.fext} # => '/home/guten_1.jpg'
- # Pa('/home/guten.jpg').rename {|pa| pa.name+'_1'+pa.fext} # => <#Pa('/home/guten_1.jpg')>
+ # Pa.rename2('/home/guten.jpg') {|pa| pa.name+'_1'+pa.fext} # => '/home/guten_1.jpg'
#
# @param [String,Pa] src
# @yieldparam [Pa] pa
# @yieldreturn [String] fname
# @return [String,Pa] # Pa.rename return String. Pa#rename return Pa.
- def rename(src, &blk)
+ def rename2(src, &blk)
src = Pa(src)
fname = blk.call(src)
src.dir.join(fname).path
end
@@ -427,11 +425,11 @@
stack << p
p = File.dirname(p)
end
stack.reverse.each do |path|
- ::Dir.mkdir(path)
+ Dir.mkdir(path)
File.chmod(o[:mode], path)
end
}
end
@@ -461,10 +459,10 @@
def _rmdir(pa, o={})
return if not File.exists?(pa.p)
pa.each {|pa1|
File.directory?(pa1.p) ? _rmdir(pa1, o) : File.delete(pa1.p)
}
- File.directory?(pa.p) ? ::Dir.rmdir(pa.p) : File.delete(pa.p)
+ File.directory?(pa.p) ? Dir.rmdir(pa.p) : File.delete(pa.p)
end
# I'm recursive
#
# @param [String] src