Class: Svnx::Base::CommandLine

Inherits:
Object
  • Object
show all
Defined in:
lib/svnx/base/cmdline.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(subcommand: nil, xml: true, caching: false, args: Array.new) ⇒ CommandLine

Returns a new instance of CommandLine.



13
14
15
16
17
18
# File 'lib/svnx/base/cmdline.rb', line 13

def initialize subcommand: nil, xml: true, caching: false, args: Array.new
  @subcommand = subcommand
  @xml = xml
  @caching = caching
  @args = args
end

Instance Attribute Details

#errorObject (readonly)

Returns the value of attribute error.



10
11
12
# File 'lib/svnx/base/cmdline.rb', line 10

def error
  @error
end

#outputObject (readonly)

Returns the value of attribute output.



9
10
11
# File 'lib/svnx/base/cmdline.rb', line 9

def output
  @output
end

#statusObject (readonly)

Returns the value of attribute status.



11
12
13
# File 'lib/svnx/base/cmdline.rb', line 11

def status
  @status
end

Instance Method Details

#commandObject



20
21
22
23
24
25
26
27
28
29
# File 'lib/svnx/base/cmdline.rb', line 20

def command
  Array.new.tap do |a|
    a << 'svn'
    a << @subcommand
    if @xml
      a << '--xml'
    end
    a.concat @args
  end
end

#executeObject



31
32
33
34
35
36
37
38
39
40
# File 'lib/svnx/base/cmdline.rb', line 31

def execute
  cmdline = ::Command::Cacheable::Command.new command, caching: @caching, cachedir: Svnx::Env.instance.cache_dir
  cmdline.execute
  
  @output = cmdline.output
  @error = cmdline.error
  @status = cmdline.status

  @output
end