Class: Secretive::Loader

Inherits:
Object
  • Object
show all
Defined in:
lib/secretive/loader.rb

Class Method Summary collapse

Class Method Details

.environmentalize!(yaml_file, scope = nil) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
# File 'lib/secretive/loader.rb', line 4

def environmentalize!(yaml_file, scope=nil)
  unless File.exists?(yaml_file)
    warn "secretive attempted to initialize, but #{yaml_file} does not exist."
    return
  end

  vars = YAML.load(File.open(yaml_file))
  return unless vars.present?

  convert_to_env_vars(vars)
  convert_to_env_vars(vars.fetch(scope)) if scope.present?
end

.for_heroku(yaml_file, scope = nil) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/secretive/loader.rb', line 17

def for_heroku(yaml_file, scope=nil)
  vars = YAML.load(File.open(yaml_file))

  heroku_string = convert_vars_to_string(vars)
  heroku_string += convert_vars_to_string(vars.fetch(scope)) if scope.present?
  heroku_string
end