normalizr 0.0.2 → 0.0.3

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: 1a1ea6ea124dcfb9150f5baa5014afd7c48d22a6
4
- data.tar.gz: 8edcc27a488527db1fcee49f784011c4432f47f3
3
+ metadata.gz: 001866efe62b5690380583e71cd63a7db0f8b50e
4
+ data.tar.gz: 5569ab0e1c9379bfae5bb5c5a3f085839dffd4dc
5
5
  SHA512:
6
- metadata.gz: ea84b47043932b32f5fb5f23ec1c8cda39c20765e355ead63adda7d7eb462322c11c5a0b5bc12a22a72db0ce615c4d230949d3d47898fc084e794c2d8358506e
7
- data.tar.gz: 97ae21ee80ba0b1bc824ca36e5005225736feab1341bb0648a1821052ccf9d605c1292c8d8a114ea5446b3467e9a620502eee31478a3096a0cc8c037628cabc0
6
+ metadata.gz: dd87e9aa36aa9da01e264b5097e00fdc6af7f576c116c5d640078eaa40de6e57127e838b0f8bc1e1773fb3dcd5c928c4dc238aa5c4d9627fb117a1a417311168
7
+ data.tar.gz: 54a92ab8ec8a31523f8eb8bbf8b3322aefaf58b2d5b999659258dcaf35dbe36bff3bbe7cfe9f5783393f2dda079366a1ead640c6649670bec5edd4f27abd282b
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ### 0.0.3 / 2014-08-22
2
+
3
+ * Fixed issue when some built-in normalizers modify passed-in parameters
4
+
1
5
  ### 0.0.2 / 2014-08-22
2
6
 
3
7
  * Rename `#do` method to `#normalize`
@@ -16,13 +16,16 @@ Normalizr.configure do
16
16
  end
17
17
 
18
18
  add :control_chars do |value|
19
- value.gsub!(/[[:cntrl:]&&[^[:space:]]]/, '') if String === value
20
- value
19
+ if String === value
20
+ value.gsub(/[[:cntrl:]&&[^[:space:]]]/, '')
21
+ else
22
+ value
23
+ end
21
24
  end
22
25
 
23
26
  add :phone do |value|
24
27
  if String === value
25
- value.gsub!(/[^0-9]+/, '')
28
+ value = value.gsub(/[^0-9]+/, '')
26
29
  value unless value.empty?
27
30
  else
28
31
  value
@@ -31,25 +34,27 @@ Normalizr.configure do
31
34
 
32
35
  add :squish do |value|
33
36
  if String === value
34
- value.strip!
35
- value.gsub!(/\s+/, ' ')
37
+ value.strip.gsub(/\s+/, ' ')
38
+ else
39
+ value
36
40
  end
37
- value
38
41
  end
39
42
 
40
43
  add :whitespace do |value|
41
44
  if String === value
42
- value.gsub!(/[^\S\n]+/, ' ')
43
- value.gsub!(/\s?\n\s?/, "\n")
44
- value.strip!
45
+ value.gsub(/[^\S\n]+/, ' ').gsub(/\s?\n\s?/, "\n").strip
46
+ else
47
+ value
45
48
  end
46
- value
47
49
  end
48
50
 
49
51
  [:capitalize, :downcase, :strip, :upcase].each do |name|
50
52
  add name do |value|
51
- value.send(:"#{name}!") if String === value
52
- value
53
+ if String === value
54
+ value.send(:"#{name}")
55
+ else
56
+ value
57
+ end
53
58
  end
54
59
  end
55
60
  end
@@ -1,3 +1,3 @@
1
1
  module Normalizr
2
- VERSION = '0.0.2'
2
+ VERSION = '0.0.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: normalizr
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dimko