Class: Svnx::Base::Command

Inherits:
Object
  • Object
show all
Includes:
Logue::Loggable
Defined in:
lib/svnx/base/command.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options, cls: nil, optcls: nil, exec: nil, xml: false, caching: caching? ) ⇒ Command

Returns a new instance of Command.



34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/svnx/base/command.rb', line 34

def initialize options, cls: nil, optcls: nil, exec: nil, xml: false, caching: caching?
  factory = CommandFactory.new
  params = factory.create self.class, cmdlinecls: cls, optcls: optcls
  
  optcls ||= params[:options_class]
  
  @options = optcls.new options
  cmdargs = @options.to_args
  subcommand = params[:subcommand]
  
  cls ||= params[:command_line_class]
  
  @cmdline = exec || cls.new(subcommand: subcommand, xml: xml, caching: caching, args: cmdargs)
  debug "@cmdline: #{@cmdline}"
  
  @output = @cmdline.execute
  debug "@output: #{@output && @output[0 .. 100]}"
  
  @error = @cmdline.error
  debug "@error: #{@error}"
  
  @status = @cmdline.status
  debug "@status: #{@status}"
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



29
30
31
# File 'lib/svnx/base/command.rb', line 29

def error
  @error
end

#optionsObject (readonly)

Returns the value of attribute options.



32
33
34
# File 'lib/svnx/base/command.rb', line 32

def options
  @options
end

#outputObject (readonly)

Returns the value of attribute output.



28
29
30
# File 'lib/svnx/base/command.rb', line 28

def output
  @output
end

#statusObject (readonly)

Returns the value of attribute status.



30
31
32
# File 'lib/svnx/base/command.rb', line 30

def status
  @status
end

Class Method Details

.cachingObject



15
16
17
18
19
# File 'lib/svnx/base/command.rb', line 15

def caching
  define_method :caching? do
    true
  end
end

.noncachingObject



21
22
23
24
25
# File 'lib/svnx/base/command.rb', line 21

def noncaching
  define_method :caching? do
    false
  end
end