Class: Forcer::ActionOptionsService

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

Class Method Summary collapse

Class Method Details

.add_exclude_paths(options = {}) ⇒ Object

add absolute paths to exclude_… files from focer_config directory



63
64
65
66
67
68
69
70
71
72
# File 'lib/utilities/action_options_service.rb', line 63

def add_exclude_paths(options = {})

  if !(options[:configs].nil?) && File.exists?(File.join(options[:configs], "/exclude_components.yml"))
    options[:exclude_components] = File.join(options[:configs], "/exclude_components.yml")
  end

  if !(options[:configs].nil?) && File.exists?(File.join(options[:configs], "/exclude_xml_nodes.yml"))
    options[:exclude_xml] = File.join(options[:configs], "/exclude_xml_nodes.yml")
  end
end

.load_config(old_options = {}) ⇒ Object

attempts to load configuration files from directory ‘forcer_config’ directory can include ‘configuration.yml’, ‘exclude_components.yml’, ‘exclude_xml_nodes.yml’ if directory not found tries to load only configuration.yml from local directory



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

def self.load_config(old_options = {})
  options = {}
  old_options.each do |k, v|
    options.store(k.to_sym, v)
  end

  if options[:configs].nil? || !(Dir.exists?(File.expand_path(options[:configs], __FILE__)))
    p "config folder not specified or not found"
    options[:configs] = Dir.pwd + "/forcer_config"
    p "config folder in CURRENT DIRECTORY ? => #{Dir.exists?(options[:configs])}"
  else
    p "specified config folder FOUND"
    options[:configs] = File.expand_path(options[:configs], __FILE__)
  end

  (options)

  add_exclude_paths(options)

  return options
end

.load_login_info(options = {}) ⇒ Object

attempts to read salesforce org information from forcer_config/configuration.yml if forcer_config/configuration.yml not found, then try configuration.yml in current directory



37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/utilities/action_options_service.rb', line 37

def (options = {})

  if !(options[:configs].nil?) && File.exists?(File.join(options[:configs], "/configuration.yml"))
    p "CONFIGURATION.YML with org details FOUND in CONFIG FOLDER"
    config_file_path = File.join(options[:configs], "/configuration.yml")
    options[:login_info_path] = config_file_path
  else
    p "loading CONFIGURATION.YML from CURRENT DIRECTORY"
    config_file_path = File.join(Dir.pwd, "/configuration.yml")
  end

  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")
end