Class: Gojira::Deck::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/gojira/deck/base.rb

Direct Known Subclasses

File, Gateway

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(binary_path, kong_addr = nil, config_file = nil, timeout = 10, tls_params = {}) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/gojira/deck/base.rb', line 11

def initialize(binary_path, kong_addr = nil, config_file = nil, timeout = 10, tls_params = {})
  @binary_path = binary_path
  @params = {
    kong_addr: kong_addr,
    config_file: config_file,
    timeout: timeout,
    tls_params: tls_params
  }
  @output = []
  @error = []
end

Instance Attribute Details

#binary_pathObject (readonly)

Returns the value of attribute binary_path.



8
9
10
# File 'lib/gojira/deck/base.rb', line 8

def binary_path
  @binary_path
end

#errorObject

Returns the value of attribute error.



9
10
11
# File 'lib/gojira/deck/base.rb', line 9

def error
  @error
end

#outputObject

Returns the value of attribute output.



9
10
11
# File 'lib/gojira/deck/base.rb', line 9

def output
  @output
end

#paramsObject (readonly)

Returns the value of attribute params.



8
9
10
# File 'lib/gojira/deck/base.rb', line 8

def params
  @params
end

Instance Method Details

#execute(command) ⇒ Object



23
24
25
26
27
28
# File 'lib/gojira/deck/base.rb', line 23

def execute(command)
  stdout_str, stderr_str, status = Open3.capture3("#{@binary_path} #{command} #{param_string}")
  @output << stdout_str.chomp and return if status.success?

  @error << "Error executing command: #{stderr_str}"
end