config_default 0.6.0 → 0.6.2

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: c578e209fd98c0060e802f2b3f1eb4bada4fd25b4e3f5b323d2af82844839932
4
- data.tar.gz: c0a5e708f9a6cdbf3e9b8410acdf3bee5a62f50a9ee96e9ec770f4ca19bce21e
3
+ metadata.gz: 52f0736f97782e152e389cbd1be631230bc8cafd7c2271c1499cd61234ad8c60
4
+ data.tar.gz: 34ff7b8184c350f8cb9d2ea3412a6032206d44dabedfd42fd3d5c8f2401fe985
5
5
  SHA512:
6
- metadata.gz: ac456e007e54f9355c42b2e28f36087e2b93168102be181fae4bfc3b86997419b41ebff87fc5aa5b5ba107a07dd710df3f89cef973c447a1331f24cacb8e2521
7
- data.tar.gz: 6416a64655e45aceaa5f811be55f4ad1fb2434778775895f4e3a8105f9f88bd6825f92acb2a2068c11360b04f5985423850229d3a9d556347e0b2af4bd1e7799
6
+ metadata.gz: 9df4052f0df98a43e498dd4711f83e6521f4b857f103af47018d48d8bef1c890f0ae4537cc87fe38d243f07aecf1e8f7818dc585fd08e742564f5e555112ce6b
7
+ data.tar.gz: 0b15006d8debe471b852a12d4228864fbd869455866fda3a735a11ce2c588c222bef179ae311afbae328060a1ff414ab83ffaffbde39cfd16e6609d4de690396
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- config_default (0.6.0)
4
+ config_default (0.6.2)
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)
@@ -27,6 +27,11 @@ class ConfigDefault::Struct
27
27
  true
28
28
  end
29
29
 
30
+ def inspect
31
+ "#<ConfigDefault::Struct @attributes=#{to_hash} " \
32
+ "@recursive=#{@recursive} @allow_nil=#{@allow_nil}>"
33
+ end
34
+
30
35
  def to_hash
31
36
  dup = @attributes.dup
32
37
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ConfigDefault
4
- VERSION = "0.6.0"
4
+ VERSION = "0.6.2"
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,13 +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
- ActiveSupport::ConfigurationFile.parse(file_name)
60
- rescue Errno::ENOENT
61
- {}
62
- end
63
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.0
4
+ version: 0.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stepan Kirushkin