Prompt class
- +
- /
- []
- []
- cd
- chmod
- chmod_r
- chown
- chown_r
- cp
- cp_r
- directories
- directory_entries
- document_entries
- documents
- entries
- file
- files
- glob
- install
- ln
- ln_s
- ln_sf
- ls
- mkdir
- mkdir_p
- mode
- mv
- new
- rm
- rm_r
- rm_rf
- rmdir
- to_s
- touch
[R] | work | @work store the present working directory as a Directory object. |
[ show source ]
# File lib/folio/prompt.rb, line 244 def self.[](path) new(path) end
[ show source ]
# File lib/folio/prompt.rb, line 20 def initialize(*path) opts = (Hash===path.last ? path.pop : {}) mode(opts) if path.empty? path = Dir.pwd else path = File.join(*path) end raise FileNotFound unless ::File.exist?(path) raise FileNotFound unless ::File.directory?(path) @path = Directory.new(path) end
Join paths.
[ show source ]
# File lib/folio/prompt.rb, line 62 def +(fname) @work =+ fname end
Alias for file
[ show source ]
# File lib/folio/prompt.rb, line 99 def cd(dir, &block) #dir = localize(dir) if block @work.cd(dir, &block) else @work += dir end end
[ show source ]
# File lib/folio/prompt.rb, line 189 def chmod(mode, list, options) list = localize(list) fileutils.chmod(mode, list, options) end
[ show source ]
# File lib/folio/prompt.rb, line 194 def chmod_r(mode, list, options) list = localize(list) fileutils.chmod_r(mode, list, options) end
alias_method :chmod_R, :chmod_r
[ show source ]
# File lib/folio/prompt.rb, line 200 def chown(user, group, list, options) list = localize(list) fileutils.chown(user, group, list, options) end
[ show source ]
# File lib/folio/prompt.rb, line 205 def chown_r(user, group, list, options) list = localize(list) fileutils.chown_r(user, group, list, options) end
cp(list, dir, options)
[ show source ]
# File lib/folio/prompt.rb, line 148 def cp(src, dest, options) src = localize(src) dest = localize(dest) fileutils.cp(src, dest, options) end
cp_r(list, dir, options)
[ show source ]
# File lib/folio/prompt.rb, line 155 def cp_r(src, dest, options) src = localize(src) dest = localize(dest) fileutils.cp_r(src, dest, options) end
Returns Enumerator of documents.
[ show source ]
# File lib/folio/prompt.rb, line 90 def directories ; work.directories ; end
Lists directory entries.
[ show source ]
# File lib/folio/prompt.rb, line 74 def directory_entries work.directory_entries end
Lists directory entries.
[ show source ]
# File lib/folio/prompt.rb, line 79 def document_entries work.document_entries end
Returns Enumerator of directories.
[ show source ]
# File lib/folio/prompt.rb, line 87 def documents ; work.documents ; end
Lists all entries.
[ show source ]
# File lib/folio/prompt.rb, line 68 def entries work.entries end
Get the FileObject for the given file name.
[ show source ]
# File lib/folio/prompt.rb, line 56 def file(name) FileObject(name) end
Returns Enumerator of files objects.
[ show source ]
# File lib/folio/prompt.rb, line 84 def files ; work.files ; end
Glob pattern.
[ show source ]
# File lib/folio/prompt.rb, line 93 def glob(*patterns) opts = (::Integer===patterns.last ? patterns.pop : 0) pattern = localize(pattern) ::Dir.glob(pattern, opts).each{ |f| FileObject[f] } end
[ show source ]
# File lib/folio/prompt.rb, line 183 def install(src, dest, mode, options) src = localize(src) dest = localize(dest) fileutils.install(src, dest, mode, options) end
ln(list, destdir, options)
[ show source ]
# File lib/folio/prompt.rb, line 128 def ln(old, new, options) old = localize(old) new = localize(new) fileutils.ln(old, new, options) end
ln_s(list, destdir, options)
[ show source ]
# File lib/folio/prompt.rb, line 135 def ln_s(old, new, options) old = localize(old) new = localize(new) fileutils.ln_s(old, new, options) end
[ show source ]
# File lib/folio/prompt.rb, line 141 def ln_sf(old, new, options) old = localize(old) new = localize(new) fileutils.ln_sf(old, new, options) end
Alias for entries
[ show source ]
# File lib/folio/prompt.rb, line 112 def mkdir(dir, options) dir = localize(dir) fileutils.mkdir(dir, options) end
[ show source ]
# File lib/folio/prompt.rb, line 117 def mkdir_p(dir, options) dir = localize(dir) fileutils.mkdir_p(dir, options) end
Opertaton mode. This can be :noop, :verbose or :dryrun. The later is the same as the first two combined.
[ show source ]
# File lib/folio/prompt.rb, line 38 def mode(opts=nil) return @mode unless opts opts.each do |key, val| next unless val case key when :noop @mode = (@mode == :verbose ? :dryrun : :noop) when :verbose @mode = (@mode == :noop ? :dryrun : :verbose) when :dryrun @mode = :dryrun end end end
mv(list, dir, options)
[ show source ]
# File lib/folio/prompt.rb, line 162 def mv(src, dest, options) src = localize(src) dest = localize(dest) fileutils.mv(src, dest, options) end
[ show source ]
# File lib/folio/prompt.rb, line 168 def rm(list, options) list = localize(list) fileutils.rm(list, options) end
[ show source ]
# File lib/folio/prompt.rb, line 173 def rm_r(list, options) list = localize(list) fileutils.rm_f(list, options) end
[ show source ]
# File lib/folio/prompt.rb, line 178 def rm_rf(list, options) list = localize(list) fileutils.rm_rf(list, options) end
[ show source ]
# File lib/folio/prompt.rb, line 122 def rmdir(dir, options) dir = localize(dir) fileutils.rmdir(dir, options) end
[ show source ]
# File lib/folio/prompt.rb, line 53 def to_s ; work.to_s ; end
alias_method :chown_R, :chown_r
[ show source ]
# File lib/folio/prompt.rb, line 211 def touch(list, options) list = localize(list) fileutils.touch(list, options) end