type-humanizer 0.0.5 → 0.0.6

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
  SHA1:
3
- metadata.gz: 932eefec305385b9fe187bab904371d7712d5aeb
4
- data.tar.gz: 3c002bb987a3f129c8cfa13c28b6196c6ce68683
3
+ metadata.gz: 95fb6483b07c584b7b2ecfe0b3415d8eeacf853e
4
+ data.tar.gz: 8ca66071e123187dbb06e2433c82652e94ba16f5
5
5
  SHA512:
6
- metadata.gz: 3ca27a11f0e5c7ee35a5d700aba0644188a0b0409d2a9b87432727cd1ecc362d4d6daeee14833f8bb7d732fdcc92b12f7532d0b0cf9b5f5cf614db508e0f734b
7
- data.tar.gz: 360fe7b993b48a4e16e08c6681bca11fe54fbaaafd0cd189c2a72fd605611ab4feec173e8e113343a81961e991980aadbc25522e73cc4af223467ec453359363
6
+ metadata.gz: cfea1608bdbbe55b68b10e6b386adf506ee2ae503acfa820bc15961aabc12138cb970e23697e76eb056c72e4da584781eedea2e27cfa224ac1257f721213a8ba
7
+ data.tar.gz: d473a020e0f0b968a23974c8dfe00b1cb382d2a6e3914a068d2257cb15746267fa2fe38badd9bd4f8d031c03f4c9af4d6914cd78157d500f0bb0324139046830
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "0.0.5"
2
+ VERSION = "0.0.6"
3
3
  end
data/lib/humanizer.rb CHANGED
@@ -5,6 +5,8 @@ module Humanizer
5
5
  def to_array(value)
6
6
  value = String(value)
7
7
 
8
+ return nil if value.empty?
9
+
8
10
  array = String(value).split ','
9
11
  array.map &:strip
10
12
  end
@@ -12,6 +14,8 @@ module Humanizer
12
14
  def to_hash(value)
13
15
  value = String(value)
14
16
  hash = {}
17
+
18
+ return nil if value.empty?
15
19
 
16
20
  value.split(',').each do |key_val|
17
21
  k, v = key_val.split(':')
@@ -6,14 +6,17 @@ class SanitizeTest < Test::Unit::TestCase
6
6
  sanitizer = Humanizer::Sanitize.new
7
7
 
8
8
  assert_equal ['a', 'b', 'c'], sanitizer.to_array('a, b, c')
9
- assert_equal [], sanitizer.to_array(nil)
9
+ assert_equal ['a'], sanitizer.to_array('a')
10
+ assert_equal nil, sanitizer.to_array('')
11
+ assert_equal nil, sanitizer.to_array(nil)
10
12
  end
11
13
 
12
14
  def test_sanitize_hash
13
15
  sanitizer = Humanizer::Sanitize.new
14
16
 
15
17
  assert_equal({ 'foo' => 'bar', 'boo' => 'baz' }, sanitizer.to_hash('foo: bar, boo: baz'))
16
- assert_equal({}, sanitizer.to_hash(nil))
18
+ assert_equal(nil, sanitizer.to_hash(''))
19
+ assert_equal(nil, sanitizer.to_hash(nil))
17
20
  end
18
21
 
19
22
  def test_sanitize_params
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type-humanizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen