complex_config 0.11.0 → 0.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: c1e16fcfcf116bb2445f1d8fb1fc677197da1d8c
4
- data.tar.gz: '06978e3eb0ed46f22947227102a38bf3e9ab6c41'
3
+ metadata.gz: f00c1e6723f460cadcdb4e628f8770101db83723
4
+ data.tar.gz: 133f3d106b681fae18fa001f9bbf4386770d6ebd
5
5
  SHA512:
6
- metadata.gz: 2d60eea98b9281b66ab1e7c92a9ac3c5ac137cb3d756fc25c159e4cf3ddbde84c2139d8727246699c8f354995615043b40e9b48d43eb2ed914520bff52f11c15
7
- data.tar.gz: 8a6bdda64bded3126bdc64cbbe8e38b62c6d86721cb2902cce97b03a6a49216de76971164cfc57da0da63bd4ae54d10ace59264920997e0e7d67d4f253d16fd5
6
+ metadata.gz: 703e77e3fd176f17a40f1840941c19e74af32411ed2fb518193fa76b495a9977212fc6eab567a4d93a4a6dc1478bc5c2af12194a333fe702acac95474051104a
7
+ data.tar.gz: b27c4493969d30fa486dd87c2237f5c6f0f3e98cb197e5def3a18928126c05b1857231b019875d7e307ebbc6b3329be9930a9a693d096d3eed2a9916c25dc7dc
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.11.0
1
+ 0.11.1
@@ -1,9 +1,9 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: complex_config 0.11.0 ruby lib
2
+ # stub: complex_config 0.11.1 ruby lib
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "complex_config".freeze
6
- s.version = "0.11.0"
6
+ s.version = "0.11.1"
7
7
 
8
8
  s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
9
9
  s.require_paths = ["lib".freeze]
@@ -57,22 +57,31 @@ class ComplexConfig::Provider
57
57
  end
58
58
 
59
59
  def config(pathname, name = nil)
60
- data =
61
- if enc_pathname = pathname.to_s + '.enc' and File.exist?(enc_pathname)
62
- key = key(pathname)
63
- text = IO.binread(enc_pathname)
64
- # TODO merge with pathname w/o .enc
65
- ComplexConfig::Encryption.new(key).decrypt(text)
66
- else
67
- IO.binread(pathname)
60
+ datas = []
61
+ if File.exist?(pathname)
62
+ datas << IO.binread(pathname)
63
+ end
64
+ if enc_pathname = pathname.to_s + '.enc' and File.exist?(enc_pathname)
65
+ key = key(pathname)
66
+ text = IO.binread(enc_pathname)
67
+ datas << ComplexConfig::Encryption.new(key).decrypt(text)
68
+ end
69
+ datas.empty? and raise ComplexConfig::ConfigurationFileMissing,
70
+ "configuration file #{pathname.inspect} is missing"
71
+ results = datas.map { |d| evaluate(pathname, d) }
72
+ hashes = results.map { |r| ::YAML.load(r, pathname) }
73
+ settings = ComplexConfig::Settings.build(name, hashes.first)
74
+ hashes[1..-1]&.each { |h| settings.attributes_update(h) }
75
+ if shared = settings.shared?
76
+ shared = shared.to_h
77
+ settings.each do |key, value|
78
+ if value.is_a? ComplexConfig::Settings
79
+ value.attributes_update(shared)
80
+ end
68
81
  end
69
- result = evaluate(pathname, data)
70
- hash = ::YAML.load(result, pathname)
71
- ComplexConfig::Settings.build(name, hash).tap do |settings|
72
- deep_freeze? and settings.deep_freeze
73
82
  end
74
- rescue ::Errno::ENOENT => e
75
- raise ComplexConfig::ComplexConfigError.wrap(:ConfigurationFileMissing, e)
83
+ deep_freeze? and settings.deep_freeze
84
+ settings
76
85
  rescue ::Psych::SyntaxError => e
77
86
  raise ComplexConfig::ComplexConfigError.wrap(:ConfigurationSyntaxError, e)
78
87
  end
@@ -69,6 +69,13 @@ class ComplexConfig::Settings < BasicObject
69
69
  @table.values
70
70
  end
71
71
 
72
+ def attributes_update(other)
73
+ unless other.is_a? self.class
74
+ other = self.class.from_hash(other)
75
+ end
76
+ @table.update(other.table)
77
+ end
78
+
72
79
  def replace_attributes(hash)
73
80
  @table = self.class.from_hash(hash).table
74
81
  self
@@ -1,6 +1,6 @@
1
1
  module ComplexConfig
2
2
  # ComplexConfig version
3
- VERSION = '0.11.0'
3
+ VERSION = '0.11.1'
4
4
  VERSION_ARRAY = VERSION.split('.').map(&:to_i) # :nodoc:
5
5
  VERSION_MAJOR = VERSION_ARRAY[0] # :nodoc:
6
6
  VERSION_MINOR = VERSION_ARRAY[1] # :nodoc:
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: complex_config
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.11.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Florian Frank