Class: DerivativeRodeo::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/derivative_rodeo/configuration.rb

Overview

This class is responsible for the consistent configuration of the “application” that leverages the DerivativeRodeo.

This configuration helps set defaults for storage locations and generators.

Instance Attribute Summary collapse

AWS S3 Configuration collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ Configuration

Returns a new instance of Configuration.

Yields:

  • (_self)

Yield Parameters:



51
52
53
54
55
56
57
58
59
60
# File 'lib/derivative_rodeo/configuration.rb', line 51

def initialize
  @logger = if defined?(Rails)
              Rails.logger
            else
              # By default, minimize the chatter of the specs.  Add ENV['DEBUG'] to expose the
              # chatter.
              Logger.new($stderr, level: Logger::FATAL)
            end
  yield self if block_given?
end

Instance Attribute Details

#loggerLogger

Returns:

  • (Logger)


64
65
66
# File 'lib/derivative_rodeo/configuration.rb', line 64

def logger
  @logger
end

Class Method Details

.aws_config(prefix:, name:, default: nil) ⇒ Object

Allows AWS configuration to be set via environment variables by declairing them in the configuration class as follows:

Examples:


aws_config prefix: 's3', name: 'region', default: 'us-east-1'

Parameters:

  • prefix (String)
  • name (String)
  • default (String) (defaults to: nil)

    (optional)



25
26
27
28
# File 'lib/derivative_rodeo/configuration.rb', line 25

def self.aws_config(prefix:, name:, default: nil)
  aws_config_getter(prefix: prefix, name: name, default: default)
  aws_config_setter(prefix: prefix, name: name)
end

Instance Method Details

#s3String

Note:

The order we use is:

  • ‘config.aws_s3_<variable_name> = value`

  • ‘AWS_S3_<variable_name>`

  • ‘AWS_<variable_name>`

  • ‘AWS_DEFAULT_<variable_name>`

  • default

Various AWS items for StorageLocations::S3Location. These can be set from the ENV or the configuration block

Returns:

  • (String)


82
# File 'lib/derivative_rodeo/configuration.rb', line 82

aws_config prefix: 's3', name: 'region', default: 'us-east-1'