Class: Dotsync::ConfigMerger

Inherits:
Object
  • Object
show all
Defined in:
lib/dotsync/utils/config_merger.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config_hash, config_path) ⇒ ConfigMerger

Returns a new instance of ConfigMerger.



13
14
15
16
17
# File 'lib/dotsync/utils/config_merger.rb', line 13

def initialize(config_hash, config_path)
  @config = config_hash
  @config_path = config_path
  @include_path = nil
end

Instance Attribute Details

#include_pathObject (readonly)

Returns the value of attribute include_path.



7
8
9
# File 'lib/dotsync/utils/config_merger.rb', line 7

def include_path
  @include_path
end

Class Method Details

.resolve(config_hash, config_path) ⇒ Object



9
10
11
# File 'lib/dotsync/utils/config_merger.rb', line 9

def self.resolve(config_hash, config_path)
  new(config_hash, config_path).resolve
end

Instance Method Details

#resolveObject



19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/dotsync/utils/config_merger.rb', line 19

def resolve
  return @config unless @config.key?("include")

  validate_include_value!
  @include_path = resolve_include_path
  validate_include_exists!

  base_config = load_base_config
  validate_no_chained_includes!(base_config)

  merged = deep_merge(base_config, overlay)
  merged
end