king_konf 0.3.0 → 0.3.1

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: a1627c1be992905aafc33d3af345e53506aedfccfc00fba4c525150addc21709
4
- data.tar.gz: a96fdbe1265f0f05c05a4cd35e0f2ac48c880b05380971e3112bd81e1a74f7f2
3
+ metadata.gz: 545014c7184c51ce8ee6f2ce007d46421654599624a1423c28bb2fd34fe8d607
4
+ data.tar.gz: 2213d1e4f21082535d2af4ee6423037da2002fca60c65bbaa5dd2be46dd05042
5
5
  SHA512:
6
- metadata.gz: d16e6e0f81812138d41deb63a662a804a08b67d7fc4ad3803739c6227dd707d678e9cd7dbf64a5752e2f7c1e707983daf36d474777ed8242b6cbc80f3399ad20
7
- data.tar.gz: a8d59948190f2b4c26b88ed5c0a24075ca7d53ef5739b7260e1e41885a3ea7bbbc4d53c48b6c8891e3b6c44638aee0555bbb04e7c1bb27334cef67aeb1f4b379
6
+ metadata.gz: ddb78c49ef8da922d5d03c5cd2da6888bcdd2d15a60ce10ffa843c0b6e3512a29eee4ef83aee33db2b426798524740c77e2f9d771baa0c7c1e3c51a6619fa7a6
7
+ data.tar.gz: '009c44e61c6176a57b05be827659bcb1164677924d4095a0222a54de6d2c0272b462f9931cc95eb5cc86ddaf9d27e9784fca750951ac2d67f1cc1be633fa2566'
@@ -5,16 +5,18 @@ module KingKonf
5
5
  attr_reader :name, :type, :default, :description, :allowed_values, :options
6
6
 
7
7
  def initialize(name:, type:, default: nil, description: "", required: false, allowed_values: nil, options: {})
8
- @name, @type, @default = name, type, default
8
+ @name, @type = name, type
9
9
  @description = description
10
10
  @required = required
11
11
  @allowed_values = allowed_values
12
12
  @options = options
13
+ @default = cast(default)
13
14
  end
14
15
 
15
16
  def cast(value)
16
17
  case @type
17
18
  when :float then value.to_f
19
+ when :duration then value.is_a?(String) ? Decoder.duration(value) : value
18
20
  else value
19
21
  end
20
22
  end
@@ -29,6 +31,7 @@ module KingKonf
29
31
  when :list then value.is_a?(Array)
30
32
  when :integer then value.is_a?(Integer) || value.nil?
31
33
  when :float then value.is_a?(Float) || value.is_a?(Integer) || value.nil?
34
+ when :duration then value.is_a?(Float) || value.is_a?(Integer) || value.is_a?(String) || value.nil?
32
35
  when :boolean then value == true || value == false
33
36
  when :symbol then value.is_a?(Symbol)
34
37
  else raise "invalid type #{@type}"
@@ -1,3 +1,3 @@
1
1
  module KingKonf
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: king_konf
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck