type-humanizer 0.0.3 → 0.0.4

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: aeaef0b54d823153c2202e8cbf9a3536c9864ed8
4
- data.tar.gz: bcf0b0123f80d1ef0239c579bb005e4ce7f87778
3
+ metadata.gz: 8234590cd5eb3a2667605c9a37d3e24497d6cfa2
4
+ data.tar.gz: fe8f6dfe78e92561b7af34adc361e9258fb2a735
5
5
  SHA512:
6
- metadata.gz: 958cc0661fdb64d0e41fb096ef9533165cbc450659c12cb8d35b1d3e25a4cffe80346aaa1964bc966f4e6a11ad2a031ad4039733709f6ce62f5289973d47c5c0
7
- data.tar.gz: 926ed3f3c450341309c36ce0265f8a213482ba0f9201e5e56bb40bf030c9e8c559875eeae3be70b4be5a5ce6042a0e79f3aca0c63e96281c01242a0bdc1e2cb6
6
+ metadata.gz: 97a65c366989542fe891bc8c606e9718ad45337712ffe19fbdd76a22e495b4eff9a60dab4837bde3cd88ea6544b3e137acb9092bc4847a1bb0c7d13586694877
7
+ data.tar.gz: 3534e41be93911461e59a7882b1581b872ff52a7b96d8f97db84be439ca316ba1b90c853dc533344c82283ed0a94ab8d336e1a3309a8e265bfee0c622c38d3a0
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Humanizer
2
2
 
3
- A library for humazing and sanitizing array and hash
3
+ A library for *humazing* and *sanitizing* `Array` and `Hash`
4
4
 
5
5
  ## Installation
6
6
 
@@ -22,7 +22,9 @@ Or install it yourself as:
22
22
 
23
23
  ### Humanizing
24
24
 
25
- We can humanize `Array` and `Hash`
25
+ *First, lets humanize some data*
26
+
27
+ We can humanize an `Array` and a `Hash`
26
28
 
27
29
  To do that, we just call `Humanizer::Human#from`
28
30
 
@@ -35,9 +37,13 @@ Humanizer::Human.from { :foo => 'bar', :boo => 'baz' }
35
37
  ```
36
38
 
37
39
  ### Sanitizing
38
- Again, we can sanitize `Array` and `Hash`
39
40
 
40
- This time we need the `Humanizer::Sanitize` class
41
+ *Now lets sanitize it*
42
+
43
+ Again, we can sanitize an `Array` and a `Hash`
44
+
45
+ For this we need the `Humanizer::Sanitize` class
46
+
41
47
  ```ruby
42
48
  sanitizer = Humanizer::Sanitize.new
43
49
 
@@ -53,17 +59,15 @@ We can also sanitize a hash of params.. This could be some Rails params
53
59
  All we need to do is pass the params and specify which params should be sanitized to what type
54
60
 
55
61
  ```ruby
56
- params = { friends: 'Jack, Jill', favorites: 'drink: Coffee, fruit: Bananas' }
62
+ params = { friends: 'Jack, Jill', favorites: 'drink: Coffee, fruit: Banana' }
57
63
 
58
64
  Humanizer::Sanitize.params params, friends: :array, favorites: :hash
59
65
  => { :friends => ["Jack", "Jill"], :favorites => { "drink" => "Coffee", "fruit" => "Banana" } }
60
66
  ```
61
67
 
62
-
63
-
64
68
  ## Contributing
65
69
 
66
- 1. Fork it ( https://github.com/[my-github-username]/humanizer/fork )
70
+ 1. Fork it ( https://github.com/askehansen/humanizer/fork )
67
71
  2. Create your feature branch (`git checkout -b my-new-feature`)
68
72
  3. Commit your changes (`git commit -am 'Add some feature'`)
69
73
  4. Push to the branch (`git push origin my-new-feature`)
data/lib/humanizer.rb CHANGED
@@ -41,7 +41,7 @@ module Humanizer
41
41
 
42
42
  class Human
43
43
  def self.from(value)
44
- type = String(value).class.downcase
44
+ type = value.class.to_s.downcase
45
45
  human = Human.new
46
46
 
47
47
  human.send "from_#{type}", value
@@ -62,5 +62,9 @@ module Humanizer
62
62
 
63
63
  value.join(', ')
64
64
  end
65
+
66
+ def method_missing(name, *args)
67
+ args[0]
68
+ end
65
69
  end
66
70
  end
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
data/test/human_test.rb CHANGED
@@ -15,4 +15,9 @@ class HumanTest < Test::Unit::TestCase
15
15
  assert_equal 'foo: bar, boo: baz', humanizer.from_hash({ foo: :bar, boo: :baz })
16
16
  assert_equal '', humanizer.from_hash(nil)
17
17
  end
18
+
19
+ def test_human_from
20
+ assert_equal 'foo', Humanizer::Human.from('foo')
21
+ assert_equal nil, Humanizer::Human.from(nil)
22
+ end
18
23
  end
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.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen