type-humanizer 0.0.8 → 0.0.9

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: 7e62a47993578fd2ecda417137aa71c78a1ce7cb
4
- data.tar.gz: 95063fe73e609ab6bd9dbee10c1ea52a3080e576
3
+ metadata.gz: 41dbc478ebd072b4c345a8dd3349dd9decb43dc5
4
+ data.tar.gz: f9df6d9dc52c489d50f1044bee1c84335273b7d0
5
5
  SHA512:
6
- metadata.gz: a666c3950077611a2c2e0b2c2f8ea511a470826b791280af6bc02f44d2cd225ec73688e5389eed35c6fd49913aba235bf95e8946f71e6465d5abe79ba31e9e7f
7
- data.tar.gz: 67b02ddd7e559745f77f1383d59a2b474eea4c74cf393b756b202f802f4c3515a45647cbcebf3297c8a506f066111ef865c8c1ca196cf17c5c947d179c6f40c6
6
+ metadata.gz: da463f4743ac06a4d0affd6ab6dde13dfdd27ce2ce2512b892927be6e961729b77e1ae07642aa1efb3362936fd68c4cdf66b34196e296a62ea6639741f30ff7f
7
+ data.tar.gz: 0067155cf2a9b8c88d91e671ff66ac40f75470c1b2df67ee131c93b3f1641a1b6a6450d81e972415303cf6c120742496943bcd7273fc901bb686049d57beb961
data/README.md CHANGED
@@ -65,6 +65,19 @@ Humanizer::Sanitize.params params, friends: :array, favorites: :hash
65
65
  => { :friends => ["Jack", "Jill"], :favorites => { "drink" => "Coffee", "fruit" => "Banana" } }
66
66
  ```
67
67
 
68
+ ## Configuration
69
+
70
+ You can configure the delimeters by creating an initializer:
71
+
72
+ ```ruby
73
+ Humanizer.configure do |config|
74
+ # These are the default values
75
+ config.array_delimeter = ', '
76
+ config.hash_delimeter = ', '
77
+ config.key_val_delimeter = ': '
78
+ end
79
+ ```
80
+
68
81
  ## Contributing
69
82
 
70
83
  1. Fork it ( https://github.com/askehansen/humanizer/fork )
data/lib/humanizer.rb CHANGED
@@ -71,17 +71,17 @@ module Humanizer
71
71
  def from_array(value)
72
72
  value = Array(value)
73
73
 
74
- value.join Humanizer.config.array_delimeter
74
+ value.join "#{Humanizer.config.array_delimeter} "
75
75
  end
76
76
 
77
77
  def from_hash(value)
78
78
  value = Hash(value)
79
79
 
80
80
  value = value.map do |k, v|
81
- "#{k}#{Humanizer.config.key_val_delimeter}#{v}"
81
+ "#{k}#{Humanizer.config.key_val_delimeter} #{v}"
82
82
  end
83
83
 
84
- value.join(Humanizer.config.hash_delimeter)
84
+ value.join("#{Humanizer.config.hash_delimeter} ")
85
85
  end
86
86
 
87
87
  def method_missing(name, *args)
@@ -3,9 +3,9 @@ module Humanizer
3
3
  attr_accessor :array_delimeter, :hash_delimeter, :key_val_delimeter
4
4
 
5
5
  def initialize
6
- @hash_delimeter = ', '
7
- @array_delimeter = ', '
8
- @key_val_delimeter = ': '
6
+ @hash_delimeter = ','
7
+ @array_delimeter = ','
8
+ @key_val_delimeter = ':'
9
9
  end
10
10
  end
11
11
  end
@@ -1,3 +1,3 @@
1
1
  module Humanizer
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -6,6 +6,9 @@ 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 ['d', 'e', 'f'], sanitizer.to_array('d,e,f')
10
+ assert_equal ['1', '2', '3'], sanitizer.to_array('1, 2, 3')
11
+ assert_equal ['4', '5', '6'], sanitizer.to_array('4,5,6')
9
12
  assert_equal ['a'], sanitizer.to_array('a')
10
13
  assert_equal nil, sanitizer.to_array('')
11
14
  assert_equal nil, sanitizer.to_array(nil)
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: type-humanizer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aske Hansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-08 00:00:00.000000000 Z
11
+ date: 2014-09-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -77,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
77
77
  version: '0'
78
78
  requirements: []
79
79
  rubyforge_project:
80
- rubygems_version: 2.2.2
80
+ rubygems_version: 2.4.1
81
81
  signing_key:
82
82
  specification_version: 4
83
83
  summary: Humanize and sanitize array and hash