Sha256: b3fd5e4dca0dd30df06bfb3748a44cdf5399b624fda947e43fa5266eb73ee460

Contents?: true

Size: 1.25 KB

Versions: 4

Compression:

Stored size: 1.25 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 StandardError => e
        raise e
      end

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
cryptum-0.0.386 lib/cryptum/option/environment.rb
cryptum-0.0.385 lib/cryptum/option/environment.rb
cryptum-0.0.384 lib/cryptum/option/environment.rb
cryptum-0.0.383 lib/cryptum/option/environment.rb