king_konf 0.3.1 → 0.3.2

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: 545014c7184c51ce8ee6f2ce007d46421654599624a1423c28bb2fd34fe8d607
4
- data.tar.gz: 2213d1e4f21082535d2af4ee6423037da2002fca60c65bbaa5dd2be46dd05042
3
+ metadata.gz: cae3a1bc68bd4338074153f909aed61508c57843bd88201ffdb28c8151858a34
4
+ data.tar.gz: da575e0537725a6989483a557c17fe9a33d7d3e326b75b34db41ac04eab3dd0f
5
5
  SHA512:
6
- metadata.gz: ddb78c49ef8da922d5d03c5cd2da6888bcdd2d15a60ce10ffa843c0b6e3512a29eee4ef83aee33db2b426798524740c77e2f9d771baa0c7c1e3c51a6619fa7a6
7
- data.tar.gz: '009c44e61c6176a57b05be827659bcb1164677924d4095a0222a54de6d2c0272b462f9931cc95eb5cc86ddaf9d27e9784fca750951ac2d67f1cc1be633fa2566'
6
+ metadata.gz: 1453e59b7cd31f5cade7b35f39f42cac78b44f99fa51e956daa034f81fbc84156c78e189151c8c1fb6fa84f1747f7a473286583fab5f4a7b3b336995f56944b7
7
+ data.tar.gz: b4e0eec7353d8c65bfe12d929bc3b38ac1905f5ccd0a07652d7beba12087b966b4bb297e68b948a141115137a5b6623aa716a2601c342665e48b18fdf327bebd
@@ -41,6 +41,8 @@ module KingKonf
41
41
  case value
42
42
  when ""
43
43
  nil
44
+ when/^\d*\.\d+$/
45
+ value.to_f
44
46
  when/^\d*$/
45
47
  value.to_i
46
48
  else
@@ -1,19 +1,21 @@
1
1
  module KingKonf
2
2
  # Decodes specially formatted duration strings.
3
3
  module DurationDecoder
4
+ UNITS = {
5
+ "ms" => 0.001,
6
+ "s" => 1,
7
+ "m" => 60,
8
+ "h" => 60 * 60,
9
+ "d" => 60 * 60 * 24,
10
+ "w" => 60 * 60 * 24 * 7,
11
+ }
12
+
4
13
  # Either a number or a time unit.
5
- PART = /(\d+|[wdhms])/
14
+ PART = /(\d+|#{UNITS.keys.join('|')})/
6
15
 
7
16
  # One or more parts, possibly separated by whitespace.
8
17
  VALID_DURATION = /^(#{PART}\s*)+$/
9
18
 
10
- UNITS = {
11
- "s" => 1,
12
- "m" => 60,
13
- "h" => 60 * 60,
14
- "d" => 60 * 60 * 24,
15
- "w" => 60 * 60 * 24 * 7,
16
- }
17
19
 
18
20
  def self.decode(value)
19
21
  if value !~ VALID_DURATION
@@ -1,3 +1,3 @@
1
1
  module KingKonf
2
- VERSION = "0.3.1"
2
+ VERSION = "0.3.2"
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.1
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel Schierbeck