RakeFileUtils provides a custom version of the FileUtils methods that respond to the verbose and nowrite commands.
Get/set the nowrite flag controlling output from the FileUtils utilities. If verbose is true, then the utility method is echoed to standard output.
Examples:
nowrite # return the current value of the nowrite flag nowrite(v) # set the nowrite flag to _v_. nowrite(v) { code } # Execute code with the nowrite flag set temporarily to _v_. # Return to the original value when code is done.
# File lib/rake.rb, line 1128 1128: def nowrite(value=nil) 1129: oldvalue = RakeFileUtils.nowrite_flag 1130: RakeFileUtils.nowrite_flag = value unless value.nil? 1131: if block_given? 1132: begin 1133: yield 1134: ensure 1135: RakeFileUtils.nowrite_flag = oldvalue 1136: end 1137: end 1138: oldvalue 1139: end
Get/set the verbose flag controlling output from the FileUtils utilities. If verbose is true, then the utility method is echoed to standard output.
Examples:
verbose # return the current value of the verbose flag verbose(v) # set the verbose flag to _v_. verbose(v) { code } # Execute code with the verbose flag set temporarily to _v_. # Return to the original value when code is done.
# File lib/rake.rb, line 1107 1107: def verbose(value=nil) 1108: oldvalue = RakeFileUtils.verbose_flag 1109: RakeFileUtils.verbose_flag = value unless value.nil? 1110: if block_given? 1111: begin 1112: yield 1113: ensure 1114: RakeFileUtils.verbose_flag = oldvalue 1115: end 1116: end 1117: RakeFileUtils.verbose_flag 1118: end
Use this function to prevent protentially destructive ruby code from running when the :nowrite flag is set.
Example:
when_writing("Building Project") do project.build end
The following code will build the project under normal conditions. If the nowrite(true) flag is set, then the example will print:
DRYRUN: Building Project
instead of actually building the project.
# File lib/rake.rb, line 1155 1155: def when_writing(msg=nil) 1156: if RakeFileUtils.nowrite_flag 1157: puts "DRYRUN: #{msg}" if msg 1158: else 1159: yield 1160: end 1161: end
Check that the options do not contain options not listed in optdecl. An ArgumentError exception is thrown if non-declared options are found.
# File lib/rake.rb, line 1182 1182: def rake_check_options(options, *optdecl) 1183: h = options.dup 1184: optdecl.each do |name| 1185: h.delete name 1186: end 1187: raise ArgumentError, "no such option: #{h.keys.join(' ')}" unless h.empty? 1188: end
Merge the given options with the default values.
# File lib/rake.rb, line 1164 1164: def rake_merge_option(args, defaults) 1165: if Hash === args.last 1166: defaults.update(args.last) 1167: args.pop 1168: end 1169: args.push defaults 1170: args 1171: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.