type-humanizer 0.0.1 → 0.0.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
  SHA1:
3
- metadata.gz: 4cfd1da8951baadd6d5eb4dac66e01a44c664fe8
4
- data.tar.gz: d95730489082d1932207c5367a7833a7d41d0460
3
+ metadata.gz: 94441bb261b664b050d691e742937cee4a660084
4
+ data.tar.gz: b6f767ada57a7405fc9cb6463b727a9f4ce0573b
5
5
  SHA512:
6
- metadata.gz: 62676bacdcebd55e8ce3653ff3f2727deace35f3fb7f6545a747340152be0e8799531c14950a57328b26027023899e853e376940a751f1038ecb39dcaf24b2b7
7
- data.tar.gz: 4f50525a9024a27b8eb7490b61a62b475a09e8035387791ab94e89fbb953a8bb9eb841225392fdd42219f9c8ea150338f29a62aac9754114496abf4b3414959d
6
+ metadata.gz: 47db09f56abe66f98180bc7a3b31eec13ea5fa2857d943d376f4503abc29213a40343ef20a501c8345fe8b06ad33eeda997e6decf53fe6f53434d3023b39706e
7
+ data.tar.gz: a9141a44c408ac5f77fb3be381f315fa08b6ced19fda5c4688c969c563cdb72976b55148b63ccc4fa4172d4e6f7cb28ed17943dd71c921e8880cf5163254a727
data/README.md CHANGED
@@ -6,7 +6,7 @@ TODO: Write a gem description
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem 'humanizer'
9
+ gem 'type-humanizer'
10
10
 
11
11
  And then execute:
12
12
 
@@ -14,7 +14,7 @@ And then execute:
14
14
 
15
15
  Or install it yourself as:
16
16
 
17
- $ gem install humanizer
17
+ $ gem install type-humanizer
18
18
 
19
19
  ## Usage
20
20
 
data/lib/humanizer.rb CHANGED
@@ -29,7 +29,7 @@ module Humanizer
29
29
  params = Hash(params)
30
30
  options = Hash(options)
31
31
 
32
- sanitizer = Humanizer::Sanitize.new
32
+ sanitizer = Sanitize.new
33
33
 
34
34
  options.each do |param, type|
35
35
  params[param] = sanitizer.from params[param], to: type
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "0.0.1"
2
+ VERSION = "0.0.2"
3
3
  end
@@ -0,0 +1 @@
1
+ require 'humanizer'
@@ -0,0 +1,18 @@
1
+ require 'test/unit'
2
+ require 'humanizer'
3
+
4
+ class HumanTest < Test::Unit::TestCase
5
+ def test_humanize_array
6
+ humanizer = Humanizer::Human.new
7
+
8
+ assert_equal 'a, b, c', humanizer.from_array(['a, b, c'])
9
+ assert_equal '', humanizer.from_array(nil)
10
+ end
11
+
12
+ def test_humanize_hash
13
+ humanizer = Humanizer::Human.new
14
+
15
+ assert_equal 'foo: bar, boo: baz', humanizer.from_hash({ foo: :bar, boo: :baz })
16
+ assert_equal '', humanizer.from_hash(nil)
17
+ end
18
+ end
@@ -0,0 +1,27 @@
1
+ require 'test/unit'
2
+ require 'humanizer'
3
+
4
+ class SanitizeTest < Test::Unit::TestCase
5
+ def test_sanitize_array
6
+ sanitizer = Humanizer::Sanitize.new
7
+
8
+ assert_equal ['a', 'b', 'c'], sanitizer.to_array('a, b, c')
9
+ assert_equal [], sanitizer.to_array(nil)
10
+ end
11
+
12
+ def test_sanitize_hash
13
+ sanitizer = Humanizer::Sanitize.new
14
+
15
+ assert_equal({ 'foo' => 'bar', 'boo' => 'baz' }, sanitizer.to_hash('foo: bar, boo: baz'))
16
+ assert_equal({}, sanitizer.to_hash(nil))
17
+ end
18
+
19
+ def test_sanitize_params
20
+ sanitizer = Humanizer::Sanitize.new
21
+
22
+ params = { foo: 'b, a, r', boo: 'val: baz', 'boo' => 'b, a, z' }
23
+ params = Humanizer::Sanitize.params params, foo: :array, boo: :hash, 'boo' => :array
24
+
25
+ assert_equal({foo: ['b', 'a', 'r'], boo: { 'val' => 'baz' }, 'boo' => ['b', 'a', 'z'] }, params)
26
+ end
27
+ 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.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen
@@ -53,6 +53,9 @@ files:
53
53
  - humanizer.gemspec
54
54
  - lib/humanizer.rb
55
55
  - lib/humanizer/version.rb
56
+ - lib/type-humanizer.rb
57
+ - test/human_test.rb
58
+ - test/sanitize_test.rb
56
59
  homepage: https://github.com/askehansen/humanizer
57
60
  licenses:
58
61
  - MIT
@@ -77,4 +80,6 @@ rubygems_version: 2.2.2
77
80
  signing_key:
78
81
  specification_version: 4
79
82
  summary: Humanize and sanitize array and hash
80
- test_files: []
83
+ test_files:
84
+ - test/human_test.rb
85
+ - test/sanitize_test.rb