File Shell
Comprehensive file system access tool. FileShell acts as a "virtual" shell prompt.
c = VirtualShell.new c.ls #=> ['ipso.txt']
Methods
[]
cd
chdir
chmod
chmod_R
chown
chown_R
cp
cp_r
dryrun?
install
ln
ln_s
ln_sf
ls
mkdir
mkdir_p
move
mv
new
pwd
quiet?
rm
rm_r
rm_rf
rmdir
root?
touch
verbose?
Attributes
[R] | root |
Public Class methods
[ + ]
# File lib/more/facets/fileshell.rb, line 33 def initialize(*root_and_options) @options = Hash === root_and_options ? root_and_options.pop : {} @root = root_and_options.first || "/" @dryrun = options[:dryrun] @quiet = options[:quiet] #@force = options[:force] end
Public Instance methods
Direct access to a directory or a file.
[ + ]
# File lib/more/facets/fileshell.rb, line 48 def [](name) if File.directory?(name) Dir.new(name) elsif File.file?(name) File.new(name) else nil end end
This method is also aliased as
chdir
[ + ]
# File lib/more/facets/fileshell.rb, line 80 def cd(dir, options=nil, &yld) fu(options).cd(dir, &yld) end
Alias for cd
chmod(mode, list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 160 def chmod(mode, list, options=nil) fu(options).chmod(mode, list) end
chmod_R(mode, list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 165 def chmod_R(mode, list, options=nil) fu(options).chmod_R(mode, list) end
chown(user, group, list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 170 def chown(user, group, list, options=nil) fu(options).chown(user, group, list) end
chown_R(user, group, list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 175 def chown_R(user, group, list, options=nil) fu(options).chown_R(user, group, list) end
[ + ]
# File lib/more/facets/fileshell.rb, line 122 def cp(src, dest, options=nil) fu(options).cp(src, dest) end
[ + ]
# File lib/more/facets/fileshell.rb, line 128 def cp_r(src, dest, options=nil) fu(options).cp_r(src, dest) end
[ + ]
# File lib/more/facets/fileshell.rb, line 42 def dryrun? ; @dryrun ; end
install(src, dest, mode = <src‘s>, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 155 def install(src, dest, mode=src, options=nil) fu(options).install(src, dest, mode) end
[ + ]
# File lib/more/facets/fileshell.rb, line 105 def ln(old, new, options=nil) fu(options).ln(old, new) end
[ + ]
# File lib/more/facets/fileshell.rb, line 111 def ln_s(old, new, options=nil) fu(options).ln_s(old, new) end
ln_sf(src, dest, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 116 def ln_sf(src, dest, options=nil) fu(options).ln_sf(src, dest) end
Directory listing
[ + ]
# File lib/more/facets/fileshell.rb, line 70 def ls(dir, options=nil) Dir.entries.collect do |f| File.directory?(f) ? Dir.new(f) : File.new(f) end end
[ + ]
# File lib/more/facets/fileshell.rb, line 87 def mkdir(dir, options=nil) fu(options).mkdir(dir) end
[ + ]
# File lib/more/facets/fileshell.rb, line 93 def mkdir_p(dir, options=nil) fu(options).mkdir_p(dir) end
Alias for mv
This method is also aliased as
move
[ + ]
# File lib/more/facets/fileshell.rb, line 134 def mv(src, dest, options=nil) fu(options).mv(src, dest) end
Present working directory.
[ + ]
# File lib/more/facets/fileshell.rb, line 67 def pwd; super; end
[ + ]
# File lib/more/facets/fileshell.rb, line 43 def quiet? ; @quiet ; end
rm(list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 140 def rm(list, options=nil) fu(options).rm(list) end
rm_r(list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 145 def rm_r(list, options=nil) fu(options).rm_r(list) end
rm_rf(list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 150 def rm_rf(list, options=nil) fu(options).rm_rf(list) end
[ + ]
# File lib/more/facets/fileshell.rb, line 99 def rmdir(dir, options=nil) fu(options).rmdir(dir) end
Is a directory root?
[ + ]
# File lib/more/facets/fileshell.rb, line 59 def root?(dir=nil) pth = File.expand_path(dir||work) return true if pth == '/' return true if pth =~ /^(\w:)?\/$/ false end
touch(list, options)
[ + ]
# File lib/more/facets/fileshell.rb, line 180 def touch(list, options=nil) fu(options).touch(list) end
[ + ]
# File lib/more/facets/fileshell.rb, line 44 def verbose? ; !@quiet ; end