lib/pa/cmd.rb in pa-1.2.0 vs lib/pa/cmd.rb in pa-1.2.1
- old
+ new
@@ -12,10 +12,16 @@
=end
class Pa
module Cmd
extend Util::Concern
module ClassMethods
+ DELEGATE_METHODS = [ :home ]
+
+ def home2
+ Dir.home
+ end
+
# link
#
# @overload ln(src, dest)
# @overload ln([src,..], directory)
#
@@ -29,11 +35,11 @@
# ln force
#
# @see ln
# @return [nil]
def ln_f(src_s, dest, o={})
- o[:force]=true
+ o[:force] = true
_ln(:link, src_s, dest, o)
end
# symbol link
#
@@ -156,14 +162,10 @@
end if blk
p
end # def mktmpdir
- def home
- Dir.home
- end
-
# make temp file
# @see mktmpdir
#
# @overload mktmpfile2(name=$$, o={}, &blk)
# @param [Hash] o options
@@ -209,11 +211,11 @@
# @return [nil]
def rm(*paths)
paths, o = Util.extract_options(paths)
glob(*paths) { |pa|
extra_doc = o[:force] ? "-f " : nil
- puts "rm #{extra_doc}#{pd.p}" if o[:verbose]
+ puts "rm #{extra_doc}#{pa.p}" if o[:verbose]
if File.directory?(pa.p)
if o[:force]
next
else
@@ -415,10 +417,11 @@
end
end
end # def _move
+ # @param [Array<String,Pa>] paths
def _touch(paths, o)
o[:mode] ||= 0644
paths.map!{|v|get(v)}
paths.each {|p|
extra_doc = o[:force] ? "-f " : nil
@@ -428,11 +431,11 @@
o[:force] ? next : raise(Errno::EEXIST, "File exist -- #{p}")
end
mkdir(File.dirname(p)) if o[:mkdir]
- if win32?
+ if Util.win32?
# win32 BUG. must f.write("") then file can be deleted.
File.open(p, "w"){|f| f.chmod(o[:mode]); f.write("")}
else
File.open(p, "w"){|f| f.chmod(o[:mode])}
end
@@ -546,8 +549,16 @@
#File.chown(src_stat.uid, src_stat.gid, dest)
File.utime(src_stat.atime, src_stat.mtime, dest)
rescue Errno::ENOENT
end
end # _copy
+
+ DELEGATE_METHODS.each do |mth|
+ class_eval <<-EOF
+ def #{mth}(*args, &blk)
+ Pa(#{mth}2(*args, &blk))
+ end
+ EOF
+ end
end
end
end