Class: Btspm::AppStartup

Inherits:
Object
  • Object
show all
Defined in:
lib/btspm/app_startup.rb

Instance Method Summary collapse

Constructor Details

#initialize(config_file_path:, environment:) ⇒ AppStartup

Returns a new instance of AppStartup.



4
5
6
7
# File 'lib/btspm/app_startup.rb', line 4

def initialize(config_file_path:, environment:)
  @config_path = config_file_path
  @env = environment
end

Instance Method Details

#establish_env_variables_hashObject



9
10
11
12
13
14
15
16
17
18
# File 'lib/btspm/app_startup.rb', line 9

def establish_env_variables_hash
  Rails.logger.info '***** Loading Environment Specific Properties *****'
  Rails.logger.info "config_file_path=#{config_path}"
  env_yaml_path = Rails.root.join(config_path) # The path to the .yml file
  env_yaml = ERB.new(env_yaml_path.read).result # Read the file and evaluate the ERB
  full_hash = YAML.load(env_yaml) # Parse the resulting YAML
  env_hash = full_hash[env]
  Rails.logger.info "ENV_PROPS has been loaded for Rails.env=#{env}"
  env_hash
end