dorian-arguments 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/dorian/arguments.rb +6 -10
  4. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e02f141d6bfdd389868a2971a9b0f36ed727fa78ab18b9b4715498ac55818d0b
4
- data.tar.gz: 83b5ca9c05d4089c553f928bf9f21d86a2d4465bb89d1a448b5261b3dee3c768
3
+ metadata.gz: 31d8f3ef5198b3dc9ce418928e840ed5c82f7f3691964e4c1d34d96be9846951
4
+ data.tar.gz: 7494ebf6c746f4207e21cf79846d24e59c19d3824382e70215c64aeeac8a60b7
5
5
  SHA512:
6
- metadata.gz: 92b8cf10de0ea112586d59ee491ccbed78183c3457e60361c4dd9ca76fe7c2cc5400ce5cb209d2e683767d7b7f8ee7326473967b9c169a432d561253192b7449
7
- data.tar.gz: 165bf376d5bd39c13ca104d32b098bdad23153714ca9c486f3290ddd977b02088bf84f4bfafefe2c80710d55c4bcf94fa11cb8af5841b6dc43e0edff24a3174a
6
+ metadata.gz: d32f303df1fa9814866beb211aa8ee6bd90c37d34524d9820a716d768c2230b21799fc90bb472db9c2bf810a45363891475a72d58ce2855e21eeb2d07962b727
7
+ data.tar.gz: 0e12a036b21735bf712a35a9f96b328d65679f1d69185dac528de4a5eded68e1f7a3b4cbed1062c57ffd4ccf623b563a6b41a4f0bb06e7bf96798d2c78ad3112
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.0.0
1
+ 1.0.1
@@ -22,13 +22,7 @@ class Dorian
22
22
 
23
23
  TYPES = [BOOLEAN, STRING, NUMBER, INTEGER, DECIMAL]
24
24
 
25
- DEFAULTS = {
26
- BOOLEAN => "false",
27
- STRING => "",
28
- NUMBER => "0",
29
- INTEGER => "0",
30
- DECIMAL => "0"
31
- }
25
+ DEFAULT = nil
32
26
 
33
27
  MATCHES = {
34
28
  BOOLEAN => /^(true|false)$/i,
@@ -99,7 +93,9 @@ class Dorian
99
93
  end
100
94
 
101
95
  def cast(type, value)
102
- if type == BOOLEAN
96
+ if value.nil?
97
+ nil
98
+ elsif type == BOOLEAN
103
99
  BOOLEANS.fetch(value.downcase)
104
100
  elsif type == INTEGER
105
101
  value.to_i
@@ -135,7 +131,7 @@ class Dorian
135
131
  def normalize(value)
136
132
  if value.is_a?(Hash)
137
133
  type = value[:type]&.to_s || DEFAULT_TYPE
138
- default = value[:default]&.to_s || DEFAULTS.fetch(type)
134
+ default = value[:default]&.to_s || DEFAULT
139
135
  aliases =
140
136
  Array.wrap(
141
137
  value[:alias]&.to_s || value[:aliases]&.map(&:to_s) ||
@@ -143,7 +139,7 @@ class Dorian
143
139
  )
144
140
  else
145
141
  type = value.to_s
146
- default = DEFAULTS.fetch(type)
142
+ default = DEFAULT
147
143
  aliases = DEFAULT_ALIASES
148
144
  end
149
145
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dorian-arguments
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dorian Marié