Class: Sanctum::GetConfig::ConfigMerge
- Inherits:
-
Object
- Object
- Sanctum::GetConfig::ConfigMerge
- Defined in:
- lib/sanctum/get_config/config_merge.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
readonly
Returns the value of attribute config_file.
-
#force ⇒ Object
readonly
Returns the value of attribute force.
-
#targets ⇒ Object
readonly
Returns the value of attribute targets.
Instance Method Summary collapse
- #check_targets(targets, config_options) ⇒ Object
- #final_options ⇒ Object
-
#initialize(config_file:, targets:, force:) ⇒ ConfigMerge
constructor
A new instance of ConfigMerge.
- #merge_options(default_options, config_options, env_options, cli_options) ⇒ Object
Constructor Details
#initialize(config_file:, targets:, force:) ⇒ ConfigMerge
Returns a new instance of ConfigMerge.
14 15 16 17 18 |
# File 'lib/sanctum/get_config/config_merge.rb', line 14 def initialize(config_file: , targets: , force: ) @config_file = config_file @targets = targets.split(/\,/).map(&:strip) unless targets.nil? @force = force end |
Instance Attribute Details
#config_file ⇒ Object (readonly)
Returns the value of attribute config_file.
12 13 14 |
# File 'lib/sanctum/get_config/config_merge.rb', line 12 def config_file @config_file end |
#force ⇒ Object (readonly)
Returns the value of attribute force.
12 13 14 |
# File 'lib/sanctum/get_config/config_merge.rb', line 12 def force @force end |
#targets ⇒ Object (readonly)
Returns the value of attribute targets.
12 13 14 |
# File 'lib/sanctum/get_config/config_merge.rb', line 12 def targets @targets end |
Instance Method Details
#check_targets(targets, config_options) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/sanctum/get_config/config_merge.rb', line 38 def check_targets(targets, ) tmp_array = Array.new sync = [:sync] targets.each do |t| sync.each do |h| tmp_array << h if h[:name] == t end end if tmp_array.empty? valid_targets = sync.map{|h| h[:name]} raise "Please specify at least one valid target\n Valid targets are #{valid_targets}" end [:sync] = tmp_array end |
#final_options ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/sanctum/get_config/config_merge.rb', line 20 def # default_options will search for config_file or take the path specified via cli = DefaultOptions.new(config_file).run = ConfigFile.new([:config_file]).run = Env.new.run = {cli: {targets: targets, force: force }} # Check that targets specified via commandline actually exist in config_file and update config_options[:sync] array = check_targets(targets, ) unless targets.nil? (, , , ) end |
#merge_options(default_options, config_options, env_options, cli_options) ⇒ Object
34 35 36 |
# File 'lib/sanctum/get_config/config_merge.rb', line 34 def (, , , ) .deep_merge().deep_merge().deep_merge() end |