class Svnx::Exec

A low-level wrapper around the Svnx commands, converting arguments (svnx/<command>/options) into entries (svnx/<command>/entry) or output. Enhances the low level functionality.

Attributes

dir[R]
url[R]

Public Class Methods

add_delegator(cmd) click to toggle source
# File lib/svnx/exec.rb, line 35
def self.add_delegator cmd
  require "svnx/#{cmd}/command"
  require "svnx/#{cmd}/options"

  modname  = Kernel.const_get "Svnx::" + cmd.to_s.capitalize    
  initargs = { url: "@url", path: "@dir", paths: "[ @dir ]" }
  optcls   = modname::Options
  opts     = optcls.new Hash.new
  fields   = opts.fields.keys
  params   = fields.collect { |key| key.to_s + ": " + (initargs[key] || "nil") }.join ", "
  cmdargs  = fields.collect { |key| key.to_s + ": " + key.to_s }.join ", "
  
  src = Array.new.tap do |a|
    a << "def #{cmd} #{params}, cmdlinecls: @cmdlinecls"
    a << "  svncmd = #{modname}::Command.new({ #{cmdargs} }, cmdlinecls: cmdlinecls)"
    a << "  svncmd.respond_to?(:entries) ? svncmd.entries : svncmd.output"
    a << "end"
  end.join "\n"
  
  class_eval src
end
new(dir: nil, url: nil, cmdlinecls: nil) click to toggle source
# File lib/svnx/exec.rb, line 14
def initialize dir: nil, url: nil, cmdlinecls: nil
  @dir = dir
  @url = url
  @cmdlinecls = cmdlinecls
end

Public Instance Methods

path() click to toggle source
# File lib/svnx/exec.rb, line 31
def path
  info.path
end
to_s() click to toggle source
# File lib/svnx/exec.rb, line 65
def to_s
  where.to_s
end
where() click to toggle source
# File lib/svnx/exec.rb, line 20
def where
  @url || @dir
end