Class: Forcer::ActionOptionsService
- Inherits:
-
Object
- Object
- Forcer::ActionOptionsService
- Defined in:
- lib/utilities/action_options_service.rb
Class Method Summary collapse
-
.add_exclude_paths(options = {}) ⇒ Object
add absolute paths to exclude_…
-
.clone_options(old_options = {}) ⇒ Object
Thor restricts options modification.
-
.get_config_file_path(options = {}) ⇒ Object
defines which configuration.yml to use for authentication.
-
.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.
-
.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.
- .verify_config_folder(options = {}) ⇒ Object
Class Method Details
.add_exclude_paths(options = {}) ⇒ Object
add absolute paths to exclude_… files from focer_config directory
85 86 87 88 89 90 91 92 93 |
# File 'lib/utilities/action_options_service.rb', line 85 def add_exclude_paths( = {}) return if ([:configs].nil?) exclude_components_path = File.join([:configs], "/exclude_components.yml") [:exclude_components] = exclude_components_path if File.exists?(exclude_components_path) exclude_xml_path = File.join([:configs], "/exclude_xml_nodes.yml") [:exclude_xml] = exclude_xml_path if File.exists?(exclude_xml_path) end |
.clone_options(old_options = {}) ⇒ Object
Thor restricts options modification. Therefore have to clone hash “options”
26 27 28 29 30 31 32 33 |
# File 'lib/utilities/action_options_service.rb', line 26 def ( = {}) = {} .each do |k, v| .store(k.to_sym, v) end return end |
.get_config_file_path(options = {}) ⇒ Object
defines which configuration.yml to use for authentication. Preference is to save configuration.yml in folder ‘forcer_config’ which itself should be placed in project git repo directory
69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/utilities/action_options_service.rb', line 69 def get_config_file_path( = {}) config_file_path = File.join([:configs], "/configuration.yml") if File.exists?(config_file_path) p "CONFIGURATION.YML with org details FOUND in CONFIG FOLDER" [: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 config_file_path 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 |
# File 'lib/utilities/action_options_service.rb', line 9 def self.load_config( = {}) = () verify_config_folder() load_login_info() add_exclude_paths() return 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
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/utilities/action_options_service.rb', line 48 def load_login_info( = {}) config_file_path = get_config_file_path() # don't raise exception and let user enter all necessary information return unless File.exists?(config_file_path) destination_org = [:dest] configuration = YAML.load_file(config_file_path).to_hash return if configuration[destination_org].nil? configuration[destination_org].each do |key, value| .store(key.to_sym, value.to_s) unless value.to_s.empty? end [:host] = "https://#{options[:host]}" unless [:host].include?("http") end |
.verify_config_folder(options = {}) ⇒ Object
35 36 37 38 39 40 41 42 43 44 |
# File 'lib/utilities/action_options_service.rb', line 35 def verify_config_folder( = {}) if [:configs].nil? || !(Dir.exists?(File.([:configs], __FILE__))) p "config folder not specified or not found" [:configs] = Dir.pwd + "/forcer_config" p "config folder in CURRENT DIRECTORY ? => #{Dir.exists?(options[:configs])}" else p "specified config folder FOUND" [:configs] = File.([:configs], __FILE__) end end |