Class: Forcer::ActionOptionsService

Inherits:
Object
  • Object
show all
Defined in:
lib/utilities/action_options_service.rb

Class Method Summary collapse

Class Method Details

.load_config_file(old_options = {}) ⇒ Object

attempts to read salesforce org information from yaml



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/utilities/action_options_service.rb', line 7

def self.load_config_file(old_options = {})
  p "attempting to load configuration.yml"
  options = {}
  old_options.each do |k, v|
    options.store(k.to_sym, v)
  end

  config_file_path = File.join(Dir.pwd, "/configuration.yml")
  return options unless File.exists?(config_file_path)

  dest = options[:dest]
  configuration = YAML.load_file(config_file_path).to_hash

  return options if configuration[dest].nil?

  configuration[dest].each do |key, value|
    options.store(key.to_sym, value.to_s)  unless value.to_s.empty?
  end
  options[:host] = "https://#{options[:host]}" unless options[:host].include?("http")

  return options
end