Sha256: 546b730c283de946b6d2bd82e69b2590b93a0f59c58ce6084f3670f7ab8f158d

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

module Cryptum
  # This module is used to Accept User Input at Session Initiation
  module Option
    # Common module to consume YAML config and determine which environment to use.
    module Environment
      # Initialize Cryptum Session Environment
      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

      # Display Usage for this Module
      public_class_method def self.help
        constants.sort
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
cryptum-0.0.389 lib/cryptum/option/environment.rb
cryptum-0.0.388 lib/cryptum/option/environment.rb
cryptum-0.0.387 lib/cryptum/option/environment.rb