Class: Svnx::Project
- Inherits:
-
Object
- Object
- Svnx::Project
- Defined in:
- lib/svnx/project.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.
Instance Attribute Summary collapse
-
#dir ⇒ Object
readonly
Returns the value of attribute dir.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(dir: nil, url: nil, cls: nil) ⇒ Project
constructor
A new instance of Project.
- #path ⇒ Object
- #to_s ⇒ Object
- #url ⇒ Object
- #where ⇒ Object
Constructor Details
#initialize(dir: nil, url: nil, cls: nil) ⇒ Project
Returns a new instance of Project.
13 14 15 16 17 |
# File 'lib/svnx/project.rb', line 13 def initialize dir: nil, url: nil, cls: nil @dir = dir @url = url @cls = cls end |
Instance Attribute Details
#dir ⇒ Object (readonly)
Returns the value of attribute dir.
11 12 13 |
# File 'lib/svnx/project.rb', line 11 def dir @dir end |
Class Method Details
.add_delegator(cmd) ⇒ Object
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/svnx/project.rb', line 34 def self.add_delegator cmd require "svnx/#{cmd}/command" require "svnx/#{cmd}/options" initargs = Hash[url: "@url", path: "@dir", paths: "[ @dir ]"] optcls = Kernel.const_get "Svnx::#{cmd.to_s.capitalize}::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}, cls: @cls" a << " cmd = Svnx::#{cmd.to_s.capitalize}::Command.new({ #{cmdargs} }, cls: cls)" a << " cmd.respond_to?(:entries) ? cmd.entries : cmd.output" a << "end" end.join "\n" class_eval src end |
Instance Method Details
#path ⇒ Object
30 31 32 |
# File 'lib/svnx/project.rb', line 30 def path info.path end |
#to_s ⇒ Object
63 64 65 |
# File 'lib/svnx/project.rb', line 63 def to_s where.to_s end |
#url ⇒ Object
23 24 25 26 27 28 |
# File 'lib/svnx/project.rb', line 23 def url @url ||= begin entries = info entries && entries[0].url end end |
#where ⇒ Object
19 20 21 |
# File 'lib/svnx/project.rb', line 19 def where @url || @dir end |