Class: Svnx::Exec
- Inherits:
-
Object
- Object
- Svnx::Exec
- Defined in:
- lib/svnx/exec.rb
Overview
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.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir: nil, url: nil, cmdlinecls: nil) ⇒ Exec
constructor
A new instance of Exec.
- #path ⇒ Object
- #to_s ⇒ Object
- #where ⇒ Object
Constructor Details
#initialize(dir: nil, url: nil, cmdlinecls: nil) ⇒ Exec
Returns a new instance of Exec.
14 15 16 17 18 |
# File 'lib/svnx/exec.rb', line 14 def initialize dir: nil, url: nil, cmdlinecls: nil @dir = dir @url = url @cmdlinecls = cmdlinecls end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/svnx/exec.rb', line 11 def dir @dir end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
12 13 14 |
# File 'lib/svnx/exec.rb', line 12 def url @url end |
Class Method Details
.add_delegator(cmd) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# 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 |
Instance Method Details
#path ⇒ Object
31 32 33 |
# File 'lib/svnx/exec.rb', line 31 def path info.path end |
#to_s ⇒ Object
65 66 67 |
# File 'lib/svnx/exec.rb', line 65 def to_s where.to_s end |
#where ⇒ Object
20 21 22 |
# File 'lib/svnx/exec.rb', line 20 def where @url || @dir end |