type-humanizer 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +2 -2
- data/lib/humanizer.rb +1 -1
- data/lib/humanizer/version.rb +1 -1
- data/lib/type-humanizer.rb +1 -0
- data/test/human_test.rb +18 -0
- data/test/sanitize_test.rb +27 -0
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 94441bb261b664b050d691e742937cee4a660084
|
4
|
+
data.tar.gz: b6f767ada57a7405fc9cb6463b727a9f4ce0573b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
data/lib/humanizer/version.rb
CHANGED
@@ -0,0 +1 @@
|
|
1
|
+
require 'humanizer'
|
data/test/human_test.rb
ADDED
@@ -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.
|
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
|