config_default 0.6.1 → 0.6.3

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
  SHA256:
3
- metadata.gz: 0715dde68acb41cbce06739bf59d95a8fc15c0f882556a3b5b3fd5af9fa9a805
4
- data.tar.gz: 1599a3a0330d63aaf1c1b9d1124af66998512c0fe3bb63ef2ae7a5fa868f04d9
3
+ metadata.gz: f5a61fb3d158ea76b892a10aa89b807002afc43b9515e7f73e48e90a0f66a6dd
4
+ data.tar.gz: 8de424262c037327175c2fefe5e760fed3cf0cc0bfadba98c839954b222c13c0
5
5
  SHA512:
6
- metadata.gz: c9cc0825b07b80e0b80d140011a0989b060eaa599f6831f5c8b272a5ed3db2e8d5f055fee9966983e6be553d6af9cbaf09af65bd80cedf095687707a86f7060f
7
- data.tar.gz: f9f929d87567663ac6c9b2bd0535af270d98e685ddd7f825c7ff4b3b31f9859ff2caa8f8c4cd653b756a252ba564ad9756dfd9245a3429b03305d22f636b9d75
6
+ metadata.gz: c01a40ddb60363147413fb767a3575e48c0a0174dc870da0ff15a5a5372193fdee1a04d680e82143227fb4633033777137cda720c200e0545daf062675baa674
7
+ data.tar.gz: 1c150a29eb09f26539c6e137d6e27186d4c0977b44263d44fa4a58040a6f458350fb11e4dc38afa50229d7452e7007962eebe65ed5c1ca81a06f8c540ea21522
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- config_default (0.6.1)
4
+ config_default (0.6.3)
5
5
  activesupport (>= 6)
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class ConfigDefault::Struct
4
- RESERVED_METHODS = %i[method_missing respond_to_missing? to_hash].freeze
4
+ RESERVED_METHODS = %i[method_missing respond_to_missing? inspect to_hash to_s].freeze
5
5
 
6
6
  def initialize(attributes, recursive: false, allow_nil: false)
7
7
  @attributes = ActiveSupport::HashWithIndifferentAccess.new(attributes)
@@ -23,8 +23,9 @@ class ConfigDefault::Struct
23
23
  super
24
24
  end
25
25
 
26
- def respond_to_missing?(*_args)
27
- true
26
+ def inspect
27
+ "#<ConfigDefault::Struct @attributes=#{to_hash} " \
28
+ "@recursive=#{@recursive} @allow_nil=#{@allow_nil}>"
28
29
  end
29
30
 
30
31
  def to_hash
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConfigDefault
4
- VERSION = "0.6.1"
4
+ VERSION = "0.6.3"
5
5
  end
@@ -26,15 +26,22 @@ module ConfigDefault
26
26
  end
27
27
 
28
28
  def hash(name, key: Rails.env, symbolize_keys: false, deep_symbolize_keys: false)
29
- default_config = read_file("#{name}.#{config.postfix}")
30
- config = read_file(name)
29
+ path1 = File.join(config.config_path, "#{name}.#{config.postfix}.yml")
30
+ path2 = File.join(config.config_path, "#{name}.yml")
31
+
32
+ unless File.exist?(path1) || File.exist?(path2)
33
+ raise Errno::ENOENT.new("#{path1} && #{path2}")
34
+ end
35
+
36
+ config1 = File.exist?(path1) ? ActiveSupport::ConfigurationFile.parse(path1) : {}
37
+ config2 = File.exist?(path2) ? ActiveSupport::ConfigurationFile.parse(path2) : {}
31
38
 
32
39
  if key
33
- default_config = default_config[key] || {}
34
- config = config[key] || {}
40
+ config1 = config1[key] || {}
41
+ config2 = config2[key] || {}
35
42
  end
36
43
 
37
- data = default_config.deep_merge(config)
44
+ data = config1.deep_merge(config2)
38
45
 
39
46
  if deep_symbolize_keys
40
47
  data.deep_symbolize_keys
@@ -51,11 +58,4 @@ module ConfigDefault
51
58
  struct.class_eval(&block) if block
52
59
  struct
53
60
  end
54
-
55
- private
56
-
57
- def read_file(name)
58
- file_name = File.join(config.config_path, "#{name}.yml")
59
- File.exist?(file_name) ? ActiveSupport::ConfigurationFile.parse(file_name) : {}
60
- end
61
61
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: config_default
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.1
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stepan Kirushkin