Sha256: 18d83ba0f718e8059d8209d24c9aa3388b0bb664ab77bde6e713e340ad6bad86

Contents?: true

Size: 1.37 KB

Versions: 75

Compression:

Stored size: 1.37 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
        puts "USAGE:
          #{self}.get(option_choice: option_choice)
        "
      end
    end
  end
end

Version data entries

75 entries across 75 versions & 1 rubygems

Version Path
cryptum-0.0.466 lib/cryptum/option/environment.rb
cryptum-0.0.465 lib/cryptum/option/environment.rb
cryptum-0.0.464 lib/cryptum/option/environment.rb
cryptum-0.0.463 lib/cryptum/option/environment.rb
cryptum-0.0.462 lib/cryptum/option/environment.rb
cryptum-0.0.461 lib/cryptum/option/environment.rb
cryptum-0.0.460 lib/cryptum/option/environment.rb
cryptum-0.0.459 lib/cryptum/option/environment.rb
cryptum-0.0.458 lib/cryptum/option/environment.rb
cryptum-0.0.457 lib/cryptum/option/environment.rb
cryptum-0.0.456 lib/cryptum/option/environment.rb
cryptum-0.0.455 lib/cryptum/option/environment.rb
cryptum-0.0.454 lib/cryptum/option/environment.rb
cryptum-0.0.453 lib/cryptum/option/environment.rb
cryptum-0.0.452 lib/cryptum/option/environment.rb
cryptum-0.0.451 lib/cryptum/option/environment.rb
cryptum-0.0.450 lib/cryptum/option/environment.rb
cryptum-0.0.449 lib/cryptum/option/environment.rb
cryptum-0.0.448 lib/cryptum/option/environment.rb
cryptum-0.0.447 lib/cryptum/option/environment.rb