QUIET = 0 NORMAL = 1 VERBOSE = 2 class Sys module Client def sys Sys.instance end #todo: look up ruby dynamic proxy def say(msg) sys.say(msg) end def svn(cmd, return_output = false) sys.svn(cmd, return_output) end def run(cmd, return_output = false) sys.run(cmd, return_output) end def verbosity=(level) sys.verbosity = level end def verbosity sys.verbosity end end @@instance = Sys.new def self.instance @@instance end attr_accessor :verbosity def initialize(verbosity = NORMAL) @verbosity = verbosity end def say(msg) puts msg if verbosity > QUIET end def svn(cmd, return_output = false) svncmd = "svn" svncmd += " --quiet" if (cmd =~ /^(up|co)/ && verbosity == QUIET) output = run("#{svncmd} #{cmd}", return_output) puts output if output && verbosity == VERBOSE output end def run(cmd, return_output = false) val = nil say("\t#{cmd}") if verbosity == VERBOSE if (return_output) val = `#{cmd}` else cmd += ">/dev/null"if verbosity == QUIET system(cmd) end unless $?.success? puts caller.join("\n\t") raise "Failure: '#{cmd}' returned #{$?.exitstatus}" end val end end