cosine / advanced-fileutils

Advanced file utilities for Ruby

This URL has Read+Write access

name age message
file README Loading commit data...
file Rakefile
file advanced-fileutils.gemspec
directory lib/
directory spec/
README
AdvFileUtils is a collection of advanced file utilities for Ruby
scripts.

It is presently incomplete.  Those methods already implemented are
listed below without an "x_" prefix, but among their options will only
acknowledge :noop and :verbose so far.

The particular collection of available functions is also in flux.  Some
may even be spun out into other libraries.

    append          Quickly append data to a file.
    truncate        Works like #append but truncates the file when opening.
    replace         Works like #truncate but writes to lockfile then replaces.
    edit            Invokes external editor, such as vi, to edit a file.
    system          Runs an external command (more verbose than Kernel.system).

    shell           An alias for system.
    sh              An alias for system.

If 'advanced-fileutils' is required, then the methods are available at
AdvFileUtils.method_name.  If 'fileutils/advanced' is required instead,
then the methods can also be called at FileUtils.method_name.

#
# = advanced-fileutils.rb
#
# Copyright (c) 2009 Michael H. Buselli
#
# This program is free software.
# You can distribute/modify this program under the same terms of Ruby.
#
# == module AdvFileUtils
#
# Advanced FileUtils contains more methods you might have wished were in
# FileUtils.
#
# === Module Functions
#
#   append(filename, data, options)
#   append(filename, options) {|file| .... }
#   truncate(filename, options)
#   truncate(filename, data, options)
#   truncate(filename, options) {|file| .... }
#   replace(filename, data, options)            # does "atomic" file change
#   replace(filename, options) {|file| .... }
# x_insert(filename, data, options)             # :line => 7
# x_insert(filename, options) {|file| .... }
# x_update(filename, data, options)             # :line => 7
# x_update(filename, options) {|file| .... }    # :lines => 7..10
#                                               # :separator => ':'
#                                               # :where => '$1 = mbuselli'
#   edit(filename, options)                     # :visual => true
#   edit(filename, data, options)
#   system(command_list, options)
#   shell(command_list, options)                # alias of system
#   sh(command_list, options)                   # alias of system
# x_sudo(command_list, options)                 # :runas => 0
#
# Many options are not implemented yet.
#