Parent

Piston::Command

The base class which all commands subclass to obtain services from.

Attributes

args[R]
dry_run[RW]
force[RW]
lock[RW]
logging_stream[W]
quiet[RW]
recursive[RW]
revision[RW]
show_updates[RW]
verbose[RW]

Public Class Methods

new(non_options, options) click to toggle source
# File lib/piston/command.rb, line 11
def initialize(non_options, options)
  @args = non_options

  # Because the Windows shell does not process wildcards, we must do it
  # here ourselves
  @args.collect! do |arg|
    next arg unless arg =~ /[*?]/
    Dir[arg]
  end

  options.each do |option, value|
    self.send("#{option}=", value)
  end
end

Public Instance Methods

find_targets() click to toggle source
# File lib/piston/command.rb, line 57
def find_targets
  targets = Array.new
  svn(:propget, '--recursive', Piston::ROOT).each_line do |line|
    next unless line =~ /^([^ ]+)\s-\s.*$/
    targets << $1
  end

  targets
end
logging_stream() click to toggle source

Returns an IO-like object to which all information should be logged.

# File lib/piston/command.rb, line 48
def logging_stream
  @logging_stream ||= $stdout
end
skip(dir, msg, header=true) click to toggle source
# File lib/piston/command.rb, line 52
def skip(dir, msg, header=true)
  logging_stream.print "Skipping '#{dir}': " if header
  logging_stream.puts msg
end
svn(*args) click to toggle source

Run a Subversion command using the shell. If the Subversion command returns an existstatus different from zero, a RuntimeError is raised.

# File lib/piston/command.rb, line 28
def svn(*args)
  args = args.flatten.compact.map do |arg|
    if arg.to_s =~ /[ *?@]/ then
      %("#{arg}")
    else
      arg
    end
  end

  command = "svn #{args.join(' ')}"
  logging_stream.puts command if verbose
  return if dry_run
  ENV['LANGUAGE'] = 'en_US'
  result = `#{command}`
  logging_stream.puts result if verbose
  raise "Command #{command} resulted in an error:\n\n#{result}" unless $?.exitstatus.zero?
  result
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.