Module: CardanoUp::Bins

Defined in:
lib/cardano-up/bins.rb

Overview

Installing binaries for Cardano

Class Method Summary collapse

Class Method Details

.install(release) ⇒ Object

Get cardano-wallet bundle binaries to your computer.

Parameters:

  • release (String)
    • ‘latest’ | /^v20.2-.2-.2/

Raises:

  • CardanoUp::VersionNotSupportedError



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/cardano-up/bins.rb', line 9

def self.install(release)
  CardanoUp.configure_default unless CardanoUp.configured?
  configs = CardanoUp.config
  url = CardanoUp::Utils.get_binary_url(release)
  bin_dir_env = FileUtils.mkdir_p(configs[:bin_dir]).first
  file_to_unpack = File.join(bin_dir_env, 'binary-dist')
  CardanoUp::Utils.wget(url, file_to_unpack)

  unpack_binary(file_to_unpack, bin_dir_env)
  return_versions(bin_dir_env)
end

.return_versions(bin_dir = nil) ⇒ Object

Return versions of installed components

Raises:

  • CardanoUp::ConfigNotSetError



23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/cardano-up/bins.rb', line 23

def self.return_versions(bin_dir = nil)
  bindir = bin_dir.nil? ? CardanoUp.config[:bin_dir] : bin_dir
  exe = CardanoUp::Utils.win? ? '.exe' : ''
  cn = CardanoUp::Utils.cmd "#{bindir}/cardano-node#{exe} version"
  cli = CardanoUp::Utils.cmd "#{bindir}/cardano-cli#{exe} version"
  cw = CardanoUp::Utils.cmd "#{bindir}/cardano-wallet#{exe} version"
  ca = CardanoUp::Utils.cmd "#{bindir}/cardano-address#{exe} version"
  b32 = CardanoUp::Utils.cmd "#{bindir}/bech32#{exe} --version"
  { 'cardano-node' => cn,
    'cardano-cli' => cli,
    'cardano-wallet' => cw,
    'cardano-address' => ca,
    'bech32' => b32 }
end