konfig-config 2.1.0 → 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 607bd53ea2e3e6a9e7cdf483dfe532f99459e8a322e59315296b9befe2dfcc12
4
- data.tar.gz: 2874b799bf9ae8770abd7ad7989415f31ff807c92995e2470c736d39d6c9a4fd
3
+ metadata.gz: d5d08d47345c70e6c981e4ded9efc63b6f7d487d95cab858b9d382d54e71867d
4
+ data.tar.gz: b3f60ed43db9edd6e9adc7f8530052e30c23712f2865c9486a85c87b25c321f9
5
5
  SHA512:
6
- metadata.gz: 011a5a161270a6a5481eef45785ebcf8ac12f7b280de8e0f0cc33c034cc3d1efd5370381efe54dfc352de147bfd9e91b6cffdd53f0511e9f161d2cd891abab78
7
- data.tar.gz: 6bd02077bdd358bc0050cf32a3e7c552c8ac9433f01481a572d7737b75c4fb58d22791d03b275c53bdb703064d4f60e0fd37ffb59b8d9533ed9e54080de97264
6
+ metadata.gz: 2802f9dd009b74286ad3667da4b8a8f86a9ad874a7167931b5e87e8a3ea6f997aaab042883df2ecca1da61954fb76820b50ce1febaff4954c1cef0a3a68b9198
7
+ data.tar.gz: a1b01a125081dea459f98f4f738991b8d718706c1922fe60b8966e1d614457029827c73dfe61dd6aa36d23f6060bdf2812553e6d2acb3b3303694dfe99136f03
@@ -7,7 +7,8 @@ module Konfig
7
7
 
8
8
  attr_reader :name
9
9
  attr_reader :type
10
- attr_accessor :default
10
+ attr_writer :default
11
+ attr_accessor :transform_default
11
12
  attr_accessor :description
12
13
  attr_accessor :array
13
14
  attr_accessor :transformer
@@ -18,6 +19,7 @@ module Konfig
18
19
  self.type = type
19
20
  @default = default
20
21
  @description = description
22
+ @transform_default = false
21
23
  @transformer = transformer
22
24
  end
23
25
 
@@ -32,6 +34,12 @@ module Konfig
32
34
  @type = type
33
35
  end
34
36
 
37
+ def default
38
+ return [] if @default.nil? && array?
39
+
40
+ @default
41
+ end
42
+
35
43
  def array?
36
44
  @array == true
37
45
  end
@@ -30,7 +30,7 @@ module Konfig
30
30
  @attributes.each_with_object({}) do |(name, attribute), hash|
31
31
  attribute_path = path + [name]
32
32
  if source.nil?
33
- hash[name] = attribute.default
33
+ hash[name] = attribute.transform(attribute.default)
34
34
  else
35
35
  begin
36
36
  source_value = source.get(attribute_path, attribute: attribute)
@@ -13,7 +13,8 @@ module Konfig
13
13
  @source = ::YAML.safe_load(source)
14
14
  end
15
15
 
16
- def get(path, _attribute: nil)
16
+ # rubocop:disable Lint/UnusedMethodArgument
17
+ def get(path, attribute: nil)
17
18
  source = @source
18
19
  path.each do |p|
19
20
  raise ValueNotPresentError unless source.key?(p.to_s)
@@ -22,6 +23,7 @@ module Konfig
22
23
  end
23
24
  source
24
25
  end
26
+ # rubocop:enable Lint/UnusedMethodArgument
25
27
 
26
28
  end
27
29
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: konfig-config
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.1.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Adam Cooke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-04-04 00:00:00.000000000 Z
11
+ date: 2024-03-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: hashie
@@ -62,7 +62,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
62
62
  requirements:
63
63
  - - ">="
64
64
  - !ruby/object:Gem::Version
65
- version: '2.6'
65
+ version: '2.7'
66
66
  required_rubygems_version: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - ">="