module Rake::FileUtilsExt

def nowrite(value=nil)

# original value when code is done.
# temporarily to _v_. Return to the
nowrite(v) { code } # Execute code with the nowrite flag set
nowrite(v) # set the nowrite flag to _v_.
# nowrite flag
nowrite # return the current value of the
Examples:

echoed to standard output.
utilities. If verbose is true, then the utility method is
Get/set the nowrite flag controlling output from the FileUtils
def nowrite(value=nil)
  oldvalue = FileUtilsExt.nowrite_flag
  FileUtilsExt.nowrite_flag = value unless value.nil?
  if block_given?
    begin
      yield
    ensure
      FileUtilsExt.nowrite_flag = oldvalue
    end
  end
  oldvalue
end

def rake_check_options(options, *optdecl)

options are found.
+optdecl+. An ArgumentError exception is thrown if non-declared
Check that the options do not contain options not listed in
def rake_check_options(options, *optdecl)
  h = options.dup
  optdecl.each do |name|
    h.delete name
  end
  raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless
    h.empty?
end

def rake_merge_option(args, defaults)

Merge the given options with the default values.
def rake_merge_option(args, defaults)
  if Hash === args.last
    defaults.update(args.last)
    args.pop
  end
  args.push defaults
  args
end

def rake_output_message(message)

Send the message to the default rake output (which is $stderr).
def rake_output_message(message)
  $stderr.puts(message)
end

def verbose(value=nil)

# original value when code is done.
# temporarily to _v_. Return to the
verbose(v) { code } # Execute code with the verbose flag set
verbose(v) # set the verbose flag to _v_.
# verbose flag
verbose # return the current value of the
Examples:

echoed to standard output.
utilities. If verbose is true, then the utility method is
Get/set the verbose flag controlling output from the FileUtils
def verbose(value=nil)
  oldvalue = FileUtilsExt.verbose_flag
  FileUtilsExt.verbose_flag = value unless value.nil?
  if block_given?
    begin
      yield
    ensure
      FileUtilsExt.verbose_flag = oldvalue
    end
  end
  FileUtilsExt.verbose_flag
end

def when_writing(msg=nil)


instead of actually building the project.

DRYRUN: Building Project

will print:
conditions. If the nowrite(true) flag is set, then the example
The following code will build the project under normal

end
project.build
when_writing("Building Project") do

Example:

from running when the :nowrite flag is set.
Use this function to prevent potentially destructive ruby code
def when_writing(msg=nil)
  if FileUtilsExt.nowrite_flag
    $stderr.puts "DRYRUN: #{msg}" if msg
  else
    yield
  end
end