auto_strip_attributes 2.2.0 → 2.3.0

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: 624c9f6db12d0350cb1a4185eafa37c992b310f1
4
- data.tar.gz: b6ef7f53808cd252c8bdea23f83935fff4533751
3
+ metadata.gz: e7f41d4c8204a70a3b6fc653418a3369d737fbdd
4
+ data.tar.gz: b20036dddc63af1f43273efec0328801bd116896
5
5
  SHA512:
6
- metadata.gz: 6cc0bf5cdced2dba776f05e6ca9290e19f3a3e8df4822595c5163e62fa6f8840231907125b7d3f00d4e5be51e0835d2aa1baa63bb9db29964e27e8df83a7c70b
7
- data.tar.gz: 8ad8b23e63c8451fd6c14a95f44ec26273c7a73f52984a2e1f3ef6d3d42568e94aa3ddf50bb7b872f011576b6745ac664ff6a947dd3d26f54ed4d097a4bad9a1
6
+ metadata.gz: 2add7072f56073876aaedb9cfd2ebbb30323edcbb4a3693660c1193a37cc27c779ea1f771526b82a13299f4aeb637b3833630707ecfbdf00f96f27ff33c67d83
7
+ data.tar.gz: de8aa50ac43b6bec22a230dca3403311279d4ee57cb9c8e71a03c1b52e8037e24d664d5aafff47ead7b2f754917edc098a9e492498928eae81a4eecacc7e89c5
@@ -2,9 +2,10 @@ language: ruby
2
2
  sudo: false
3
3
  cache: bundler
4
4
  rvm:
5
- - 2.2.5
5
+ - 2.2.9
6
6
  - 2.3.1
7
- - 2.4.0
7
+ - 2.4.3
8
+ - 2.5.0
8
9
  env:
9
10
  - "RAILS_VERSION=4.2"
10
11
  - "RAILS_VERSION=5.0"
@@ -1,5 +1,9 @@
1
1
  ## [Master]
2
2
 
3
+ ## [2.3] - 2018-02-06
4
+
5
+ - Replacing all utf8 characters in squish (thnks to [@nasa42](https://github.com/holli/auto_strip_attributes/pull/24))
6
+
3
7
  ## [2.2] - 2016-07-28
4
8
 
5
9
  - Added 'virtual'-option (thnks to [@nasa42](https://github.com/holli/auto_strip_attributes/pull/23))
data/README.md CHANGED
@@ -16,7 +16,7 @@ Gem has option to set empty strings to nil or to remove extra spaces inside the
16
16
  Include gem in your Gemfile:
17
17
 
18
18
  ```ruby
19
- gem "auto_strip_attributes", "~> 2.2"
19
+ gem "auto_strip_attributes", "~> 2.3"
20
20
  ```
21
21
 
22
22
  ```ruby
@@ -26,10 +26,10 @@ class User < ActiveRecord::Base
26
26
  auto_strip_attributes :nick, :comment
27
27
 
28
28
  # Squeezes spaces inside the string: "James Bond " => "James Bond"
29
- auto_strip_attributes :name, :squish => true
29
+ auto_strip_attributes :name, squish: true
30
30
 
31
31
  # Won't set to null even if string is blank. " " => ""
32
- auto_strip_attributes :email, :nullify => false
32
+ auto_strip_attributes :email, nullify: false
33
33
 
34
34
  # Use with attributes that are not mapped to a column
35
35
  auto_strip_attributes :password, virtual: true
@@ -41,12 +41,12 @@ end
41
41
 
42
42
  By default the following options are defined (listed in the order of processing):
43
43
 
44
- - :strip (enabled by default) - removes whitespaces from the beginning and the end of string
45
- - :nullify (enabled by default) - replaces empty strings with nil
46
- - :squish (disabled by default) - replaces extra whitespaces (including tabs) with one space
47
- - :delete_whitespaces (disabled by default) - delete all whitespaces (including tabs)
48
- - :convert_non_breaking_spaces (disabled by default) - converts non-breaking spaces to normal spaces (Unicode U+00A0)
49
- - :virtual (disabled by default) - By default `auto_strip_attributes` doesn't work with non-persistent attributes (e.g., attributes that are created with `attr_accessor`). This is to avoid calling their custom getter/setter methods. Use this option with non-persistent attributes.
44
+ - `:strip` (enabled by default) - removes whitespaces from the beginning and the end of string. Works exactly same as `String#strip`, i.e., may not strip non-ASCII whitespaces.
45
+ - `:nullify` (enabled by default) - replaces empty strings with nil.
46
+ - `:squish` (disabled by default) - replaces all consecutive Unicode whitespace characters (including tabs and new lines) with single space (U+0020). Works exactly same as Rails `String#squish`
47
+ - `:delete_whitespaces` (disabled by default) - deletes all spaces (U+0020) and tabs (U+0009).
48
+ - `:convert_non_breaking_spaces` (disabled by default) - converts non-breaking spaces (U+00A0) to normal spaces (U+0020).
49
+ - `:virtual` (disabled by default) - By default `auto_strip_attributes` doesn't work with non-persistent attributes (e.g., attributes that are created with `attr_accessor`). This is to avoid calling their custom getter/setter methods. Use this option with non-persistent attributes.
50
50
 
51
51
  ### Custom Filters
52
52
 
@@ -67,7 +67,8 @@ class AutoStripAttributes::Config
67
67
  (value.respond_to?(:'blank?') and value.respond_to?(:'empty?') and value.blank?) ? nil : value
68
68
  end
69
69
  set_filter :squish => false do |value|
70
- value.respond_to?(:gsub) ? value.gsub(/\s+/, ' ') : value
70
+ value = value.respond_to?(:gsub) ? value.gsub(/[[:space:]]+/, ' ') : value
71
+ value.respond_to?(:strip) ? value.strip : value
71
72
  end
72
73
  set_filter :delete_whitespaces => false do |value|
73
74
  value.respond_to?(:delete) ? value.delete(" \t") : value
@@ -1,3 +1,3 @@
1
1
  module AutoStripAttributes
2
- VERSION = "2.2.0"
2
+ VERSION = "2.3.0"
3
3
  end
@@ -154,12 +154,13 @@ describe AutoStripAttributes do
154
154
  class MockRecordWithSqueeze < MockRecordParent #< ActiveRecord::Base
155
155
  #column :foo, :st
156
156
  attr_accessor :foo
157
- auto_strip_attributes :foo, :squish => true
157
+ # test that `:squish => true` implies `:strip => true`
158
+ auto_strip_attributes :foo, :squish => true, :strip => false
158
159
  end
159
160
 
160
161
  it "should squish string also form inside" do
161
162
  @record = MockRecordWithSqueeze.new
162
- @record.foo = " aaa\t\n bbb"
163
+ @record.foo = " aaa \u0009 \u000A \u000B \u000C \u000D \u0020 \u0085 \u00A0 \u1680 \u2000 \u2001 \u2002 \u2003 \u2004 \u2005 \u2006 \u2007 \u2008 \u2009 \u200A \u2028 \u2029 \u202F \u205F \u3000 bbb \u00A0 "
163
164
  @record.valid?
164
165
  @record.foo.must_equal "aaa bbb"
165
166
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: auto_strip_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 2.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olli Huotari
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-23 00:00:00.000000000 Z
11
+ date: 2018-02-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -108,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
108
108
  version: '0'
109
109
  requirements: []
110
110
  rubyforge_project: auto_strip_attributes
111
- rubygems_version: 2.6.12
111
+ rubygems_version: 2.6.14
112
112
  signing_key:
113
113
  specification_version: 4
114
114
  summary: Removes unnecessary whitespaces in attributes. Extension to ActiveRecord