Module: TezosClient::ClientInterface::ClientWrapper

Included in:
TezosClient::ClientInterface
Defined in:
lib/tezos_client/client_interface/client_wrapper.rb

Overview

Wrapper used to call the tezos-client binary

Instance Method Summary collapse

Instance Method Details

#call_client(command) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/tezos_client/client_interface/client_wrapper.rb', line 7

def call_client(command)
  cmd = "#{client_cmd} #{command}"
  Open3.popen3(cmd) do |_stdin, stdout, stderr, wait_thr|
    err = stderr.read
    status = wait_thr.value.exitstatus

    if status != 0
      raise "command '#{cmd}' existed with status #{status}: #{err}"
    end

    log err
    output = stdout.read

    if block_given?
      yield(output)
    else
      output
    end
  end
end

#client_cmdObject



28
29
30
31
32
33
34
# File 'lib/tezos_client/client_interface/client_wrapper.rb', line 28

def client_cmd
  res = "tezos-client -l"
  if config_file
    res = "#{res} -c #{config_file}"
  end
  res
end