Module: Cryptum::Option::Environment

Defined in:
lib/cryptum/option/environment.rb

Overview

Common module to consume YAML config and determine which environment to use.

Class Method Summary collapse

Class Method Details

.get(opts = {}) ⇒ Object

Initialize Cryptum Session Environment



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/cryptum/option/environment.rb', line 9

public_class_method def self.get(opts = {})
  option_choice = opts[:option_choice]

  yaml_conf_file = "#{option_choice.session_root}/etc/coinbase_pro.yaml"
  yaml_conf = YAML.load_file(
    yaml_conf_file,
    symbolize_names: true
  )

  env = yaml_conf[:prod]
  env[:env] = :prod
  env = yaml_conf[:sandbox] if option_choice.sandbox
  env[:env] = :sandbox if option_choice.sandbox

  open_ai_yaml_conf_file = "#{option_choice.session_root}/etc/open_ai.yaml"
  if File.exist?(open_ai_yaml_conf_file)
    open_ai_yaml_conf = YAML.load_file(
      open_ai_yaml_conf_file,
      symbolize_names: true
    )
    env[:open_ai_bearer_token] = open_ai_yaml_conf[:bearer_token]
  end

  env
rescue Interrupt, StandardError => e
  Cryptum::Log.append(level: :error, msg: e, which_self: self)
end

.helpObject

Display Usage for this Module



38
39
40
41
42
# File 'lib/cryptum/option/environment.rb', line 38

public_class_method def self.help
  puts "USAGE:
    #{self}.get(option_choice: option_choice)
  "
end