auto_strip_attributes 2.5.0 → 3.0.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 48197936732130b189671f33be5dd01d1b81330c
4
- data.tar.gz: ce19242658ff02bbceaf8526879a6ada25ab5b7a
2
+ SHA256:
3
+ metadata.gz: bb3998df403526b1e7258ced7b401f9990c989b2121e8659d4ae40300d88bcc3
4
+ data.tar.gz: e644dd91393eacf2d9e15b14d9a63d90abaab7e581fd0d7a656e088eeeaec939
5
5
  SHA512:
6
- metadata.gz: 420d3331984a65b6a4b5caf91fec7986ed3152408e84b0fd256602030dad8ed74be928a1efe448b4ac985bbcd073eb69c7f5b8925322204c9e0135f50a8d3206
7
- data.tar.gz: d5cd9d48fa2aec7dad753a1cca1158003bab2d0b8c88ac114a87577017445346be8ae7fced6cadf476f98150f033f8625c6f27eba5b4ffaf8f975bd5ec385af7
6
+ metadata.gz: fb9915a1b90873dee827cccb6326ff96e8e27dd8f907eafd37942bb5ecd0b6b1efa748d40bff2c6a6b34b54d3df346ec524960329a5b6f2643f030dd731446cd
7
+ data.tar.gz: a077c6f15fe1ed51aea18d3ebfb51aaf60f35a1747469312e2289ffce65a141ba7b5813b96b47a5686ba4ec96388c4f8e13c6cbd2ee0dd6766def1da6fabd186
@@ -0,0 +1,33 @@
1
+ name: Ruby
2
+
3
+ on:
4
+ push:
5
+ branches: [ master ]
6
+ pull_request:
7
+ branches: [ master ]
8
+
9
+ jobs:
10
+ test:
11
+ runs-on: ubuntu-latest
12
+
13
+ strategy:
14
+ fail-fast: false
15
+ matrix:
16
+ include:
17
+ - { ruby-version: '3.1', rails-version: '7.1' }
18
+ - { ruby-version: '3.3', rails-version: '7.2' }
19
+ - { ruby-version: '3.3', rails-version: '8.0' }
20
+ - { ruby-version: '3.4', rails-version: '8.1' }
21
+
22
+ env:
23
+ RAILS_VERSION: ${{ matrix.rails-version }}
24
+
25
+ steps:
26
+ - uses: actions/checkout@v4
27
+ - name: Set up Ruby ${{ matrix.ruby-version }}
28
+ uses: ruby/setup-ruby@v1
29
+ with:
30
+ ruby-version: ${{ matrix.ruby-version }}
31
+ bundler-cache: true
32
+ - name: Run tests
33
+ run: bundle exec rake
data/.gitignore CHANGED
@@ -1,11 +1,11 @@
1
1
  *.gem
2
- .bundle
2
+ .bundle/
3
3
  Gemfile.lock
4
- pkg/*
4
+ pkg/
5
5
 
6
6
  .loadpath
7
7
  .project
8
- .idea
8
+ .idea/
9
9
  .redcar
10
10
 
11
11
  help
data/CHANGELOG.md CHANGED
@@ -1,8 +1,18 @@
1
1
  ## [Master]
2
2
 
3
+ ## 3.0.0 (2026-08-30)
4
+
5
+ - Dropped support for Rails < 7.1 and Ruby < 3.1
6
+ - Added support for Rails 7.1, 7.2, 8.0, 8.1
7
+ - Fixed `MiniTest::Mock` reference (removed in minitest 6) to `Minitest::Mock`
8
+
9
+ ## [2.6]
10
+
11
+ - Support for `array` attributes (thnks to [@sharshenov](https://github.com/holli/auto_strip_attributes/pull/29))
12
+
3
13
  ## [2.5]
4
14
 
5
- - Support for callback options (e.g. if: -> ...) (thnks to [watsonjon](https://github.com/holli/auto_strip_attributes/pull/28)
15
+ - Support for callback options (e.g. if: -> ...) (thnks to [@watsonjon#28](https://github.com/holli/auto_strip_attributes/pull/28))
6
16
 
7
17
  ## [2.4]
8
18
 
data/Gemfile CHANGED
@@ -1,18 +1,15 @@
1
- source "http://rubygems.org"
1
+ source "https://rubygems.org"
2
2
 
3
3
  # Specify your gem's dependencies in auto_strip_attributes.gemspec
4
4
  gemspec
5
5
 
6
+ # Test against a specific Rails minor: RAILS_VERSION=7.2 bundle install
7
+ rails_version = ENV["RAILS_VERSION"]
8
+ if rails_version
9
+ gem "rails", "~> #{rails_version}.0"
10
+ else
11
+ gem "rails"
12
+ end
6
13
 
7
- # For travis testing
8
- # http://schneems.com/post/50991826838/testing-against-multiple-rails-versions
9
- rails_version = ENV["RAILS_VERSION"] || "default"
10
-
11
- case rails_version
12
- when "default"
13
- gem "rails"
14
- else
15
- gem "rails", "~> #{rails_version}"
16
- end
17
-
14
+ gem "minitest", "~> 5.25"
18
15
 
data/README.md CHANGED
@@ -7,18 +7,19 @@ It works by adding a before_validation hook to the record. No other methods are
7
7
 
8
8
  Gem has option to set empty strings to nil or to remove extra spaces inside the string.
9
9
 
10
- [<img src="https://secure.travis-ci.org/holli/auto_strip_attributes.png" />](http://travis-ci.org/holli/auto_strip_attributes)
11
- [![Gem](https://img.shields.io/gem/dt/auto_strip_attributes.svg?maxAge=2592000)](https://rubygems.org/gems/auto_strip_attributes/)
12
- [![Gem](https://img.shields.io/gem/v/auto_strip_attributes.svg?maxAge=2592000)](https://rubygems.org/gems/auto_strip_attributes/)
10
+ [![Downloads](https://img.shields.io/gem/dt/auto_strip_attributes)](https://rubygems.org/gems/auto_strip_attributes/)
11
+ [![Gem](https://img.shields.io/gem/v/auto_strip_attributes)](https://rubygems.org/gems/auto_strip_attributes/)
13
12
 
14
13
  ## Howto / examples
15
14
 
16
15
  Include gem in your Gemfile:
17
16
 
18
17
  ```ruby
19
- gem "auto_strip_attributes", "~> 2.4"
18
+ gem "auto_strip_attributes", "~> 2.6"
20
19
  ```
21
20
 
21
+ Example ActiveRecord usage:
22
+
22
23
  ```ruby
23
24
  class User < ActiveRecord::Base
24
25
 
@@ -31,11 +32,37 @@ class User < ActiveRecord::Base
31
32
  # Won't set to null even if string is blank. " " => ""
32
33
  auto_strip_attributes :email, nullify: false
33
34
 
35
+ # Won't set to null even if array is blank. [" "] => []
36
+ auto_strip_attributes :tags, nullify_array: false
37
+
34
38
  # Use with attributes that are not mapped to a column
35
39
  auto_strip_attributes :password, virtual: true
36
40
  end
37
41
  ```
38
42
 
43
+ Example ActiveModel usage:
44
+
45
+ ```ruby
46
+ class VirtualUser
47
+ include ActiveModel::Validations
48
+ include ActiveModel::Validations::Callbacks
49
+
50
+ extend AutoStripAttributes
51
+
52
+ attr_accessor :email
53
+
54
+ # Use the `virtual` option because attributes are not mapped to a column
55
+ auto_strip_attributes :email, virtual: true
56
+ end
57
+
58
+ virtual_user = VirtualUser.new
59
+ virtual_user.email = " alice@example.com "
60
+
61
+ virtual_user.validate
62
+ virtual_user.email #=> "alice@example.com"
63
+
64
+ ```
65
+
39
66
  # Options
40
67
  ### Default options
41
68
 
@@ -43,6 +70,7 @@ By default the following options are defined (listed in the order of processing)
43
70
 
44
71
  - `: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
72
  - `:nullify` (enabled by default) - replaces empty strings with nil.
73
+ - `:nullify_array` (enabled by default) - replaces empty arrays with nil.
46
74
  - `: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
75
  - `:delete_whitespaces` (disabled by default) - deletes all spaces (U+0020) and tabs (U+0009).
48
76
  - `:convert_non_breaking_spaces` (disabled by default) - converts non-breaking spaces (U+00A0) to normal spaces (U+0020).
@@ -92,7 +120,7 @@ end
92
120
 
93
121
  AutoStripAttributes::Config.setup accepts following options
94
122
 
95
- - :clear => true, to clear all filters
123
+ - :clear_previous => true, to clear all filters
96
124
  - :defaults => true, to set three default filters mentioned above
97
125
 
98
126
 
@@ -103,11 +131,7 @@ AutoStripAttributes::Config.setup accepts following options
103
131
 
104
132
  # Requirements
105
133
 
106
- Gem has been tested with newest Ruby & Rails combination and it probably works also with older versions. See test matrix at https://github.com/holli/auto_strip_attributes/blob/master/.travis.yml
107
-
108
- [<img src="https://secure.travis-ci.org/holli/auto_strip_attributes.png" />](http://travis-ci.org/holli/auto_strip_attributes)
109
-
110
- http://travis-ci.org/#!/holli/auto_strip_attributes
134
+ Gem has been tested with newest Ruby & Rails combination and it probably works also with older versions. See test matrix at https://github.com/holli/auto_strip_attributes/blob/master/.github/workflows/ci.yaml
111
135
 
112
136
  # Support
113
137
 
@@ -11,21 +11,21 @@ Gem::Specification.new do |s|
11
11
  s.summary = "Removes unnecessary whitespaces in attributes. Extension to ActiveRecord or ActiveModel."
12
12
  s.description = "AutoStripAttributes helps to remove unnecessary whitespaces from ActiveRecord or ActiveModel attributes. It's good for removing accidental spaces from user inputs. It works by adding a before_validation hook to the record. It has option to set empty strings to nil or to remove extra spaces inside the string."
13
13
  s.license = "MIT"
14
+ s.required_ruby_version = ">= 3.1"
14
15
 
15
16
  s.rubyforge_project = "auto_strip_attributes"
16
17
 
17
18
  s.files = `git ls-files`.split("\n")
18
- s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
22
 
23
- s.add_runtime_dependency "activerecord", ">= 4.0"
23
+ s.add_runtime_dependency "activerecord", ">= 7.1", "< 9"
24
24
 
25
25
  #s.add_development_dependency "activerecord", ">= 3.0"
26
- s.add_development_dependency "minitest", ">= 2.8.1"
27
- s.add_development_dependency "mocha", "~> 0.14"
28
- s.add_development_dependency 'rake'
26
+ s.add_development_dependency "minitest", ">= 3.0"
27
+ s.add_development_dependency "mocha", "~> 2.1"
28
+ s.add_development_dependency 'rake', '>= 13.0'
29
29
  # s.add_development_dependency 'pry'
30
30
 
31
31
  end
@@ -1,3 +1,3 @@
1
1
  module AutoStripAttributes
2
- VERSION = "2.5.0"
2
+ VERSION = "3.0.0"
3
3
  end
@@ -20,7 +20,13 @@ module AutoStripAttributes
20
20
  end
21
21
  AutoStripAttributes::Config.filters_order.each do |filter_name|
22
22
  next if !options[filter_name]
23
- value = AutoStripAttributes::Config.filters[filter_name].call(value, options[filter_name])
23
+ filter = lambda { |original| AutoStripAttributes::Config.filters[filter_name].call(original, options[filter_name]) }
24
+ value = if value.respond_to?(:is_a?) && value.is_a?(Array)
25
+ array = value.map { |item| filter.call(item) }.compact
26
+ options[:nullify_array] && array.empty? ? nil : array
27
+ else
28
+ filter.call(value)
29
+ end
24
30
  if virtual
25
31
  record.public_send("#{attribute}=", value)
26
32
  else
@@ -55,10 +61,11 @@ class AutoStripAttributes::Config
55
61
  end
56
62
  set_filter(nullify: true) do |value|
57
63
  # We check for blank? and empty? because rails uses empty? inside blank?
58
- # e.g. MiniTest::Mock.new() only responds to .blank? but not empty?, check tests for more info
64
+ # e.g. Minitest::Mock.new() only responds to .blank? but not empty?, check tests for more info
59
65
  # Basically same as value.blank? ? nil : value
60
66
  (value.respond_to?(:'blank?') and value.respond_to?(:'empty?') and value.blank?) ? nil : value
61
67
  end
68
+ set_filter(nullify_array: true) {|value| value}
62
69
  set_filter(squish: false) do |value|
63
70
  value = value.respond_to?(:gsub) ? value.gsub(/[[:space:]]+/, ' ') : value
64
71
  value.respond_to?(:strip) ? value.strip : value
@@ -6,7 +6,7 @@ require 'minitest/autorun'
6
6
  require 'minitest/spec'
7
7
  require "active_record"
8
8
  require "auto_strip_attributes"
9
- require 'mocha/setup'
9
+ require 'mocha/minitest'
10
10
 
11
11
  # if you need debug, add relevant line to auto_strip_attributes.gemspec
12
12
  # s.add_development_dependency 'pry'
@@ -59,14 +59,14 @@ describe AutoStripAttributes do
59
59
  @record = MockRecordBasic.new()
60
60
  @record.boo = " aaa \t"
61
61
  @record.valid?
62
- @record.boo.must_equal " aaa \t"
62
+ assert_equal @record.boo, " aaa \t"
63
63
  end
64
64
 
65
65
  it "should strip when conditional is met" do
66
66
  @record = MockRecordBasic.new()
67
67
  @record.boo = " bbb \t"
68
68
  @record.valid?
69
- @record.boo.must_equal "bbb"
69
+ assert_equal @record.boo, "bbb"
70
70
  end
71
71
  end
72
72
 
@@ -80,21 +80,28 @@ describe AutoStripAttributes do
80
80
  @record = MockRecordBasic.new()
81
81
  @record.foo = " aaa \t"
82
82
  @record.valid?
83
- @record.foo.must_equal "aaa"
83
+ assert_equal @record.foo, "aaa"
84
+ end
85
+
86
+ it "should be ok for strings arrays" do
87
+ @record = MockRecordBasic.new()
88
+ @record.foo = [" aaa \t", " "]
89
+ @record.valid?
90
+ assert_equal @record.foo, ["aaa"]
84
91
  end
85
92
 
86
93
  it "should not delete non breaking spaces" do
87
94
  @record = MockRecordBasic.new()
88
95
  @record.foo = " aaa \t\u00A0"
89
96
  @record.valid?
90
- @record.foo.must_equal "aaa \t\u00A0"
97
+ assert_equal @record.foo, "aaa \t\u00A0"
91
98
  end
92
99
 
93
100
  it "should be ok for normal strings and not squish things" do
94
101
  @record = MockRecordBasic.new()
95
102
  @record.foo = " aaa bbb "
96
103
  @record.valid?
97
- @record.foo.must_equal "aaa bbb"
104
+ assert_equal @record.foo, "aaa bbb"
98
105
  end
99
106
 
100
107
 
@@ -102,7 +109,14 @@ describe AutoStripAttributes do
102
109
  @record = MockRecordBasic.new()
103
110
  @record.foo = " "
104
111
  @record.valid?
105
- @record.foo.must_be_nil
112
+ assert_nil @record.foo
113
+ end
114
+
115
+ it "should set empty strings arrays to nil" do
116
+ @record = MockRecordBasic.new()
117
+ @record.foo = [" "]
118
+ @record.valid?
119
+ assert_nil @record.foo
106
120
  end
107
121
 
108
122
  it "should call strip method to attribute if possible" do
@@ -111,8 +125,7 @@ describe AutoStripAttributes do
111
125
  str_mock.expects(:strip).returns(@stripped_str="stripped_str_here")
112
126
  @record.foo = str_mock
113
127
  @record.valid?
114
- assert true
115
- @record.foo.must_be_same_as @stripped_str
128
+ assert_equal @record.foo, @stripped_str
116
129
 
117
130
  #str_mock.expect :'nil?', false
118
131
  #str_mock.expect :strip, (@stripped_str="stripped_str_here")
@@ -125,7 +138,7 @@ describe AutoStripAttributes do
125
138
  it "should not call strip or nullify method for non strippable attributes" do
126
139
  @record = MockRecordBasic.new()
127
140
 
128
- str_mock = MiniTest::Mock.new() # answers false to str_mock.respond_to?(:strip) and respond_to?(:blank)
141
+ str_mock = Minitest::Mock.new() # answers false to str_mock.respond_to?(:strip) and respond_to?(:blank)
129
142
  # Mock.new is problematic in ruby 1.9 because it responds to blank? but doesn't respond to !
130
143
  # rails blank? method returns !self if an object doesn't respond to :empty?
131
144
  # Now we check in the validator also for :empty? so !self is never called.
@@ -150,7 +163,7 @@ describe AutoStripAttributes do
150
163
  @record = MockRecordWithConvertNBSP.new()
151
164
  @record.foo = " aaa \t\u00A0"
152
165
  @record.valid?
153
- @record.foo.must_equal "aaa"
166
+ assert_equal @record.foo, "aaa"
154
167
  end
155
168
 
156
169
  end
@@ -167,7 +180,30 @@ describe AutoStripAttributes do
167
180
  @record = MockRecordWithNullify.new
168
181
  @record.foo = " "
169
182
  @record.valid?
170
- @record.foo.must_equal ""
183
+ assert_equal @record.foo, ""
184
+ end
185
+
186
+ it "should not set blank strings arrays to nil" do
187
+ @record = MockRecordWithNullify.new()
188
+ @record.foo = [" "]
189
+ @record.valid?
190
+ assert_equal @record.foo, [""]
191
+ end
192
+ end
193
+
194
+ describe "Attribute with nullify_array option" do
195
+ #class MockRecordWithNullifyArray < ActiveRecord::Base
196
+ class MockRecordWithNullifyArray < MockRecordParent
197
+ #column :foo, :string
198
+ attr_accessor :foo
199
+ auto_strip_attributes :foo, nullify_array: false
200
+ end
201
+
202
+ it "should not set blank strings array to nil" do
203
+ @record = MockRecordWithNullifyArray.new
204
+ @record.foo = [" "]
205
+ @record.valid?
206
+ assert_equal @record.foo, []
171
207
  end
172
208
  end
173
209
 
@@ -182,14 +218,14 @@ describe AutoStripAttributes do
182
218
  @record = MockRecordWithSqueeze.new
183
219
  @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 "
184
220
  @record.valid?
185
- @record.foo.must_equal "aaa bbb"
221
+ assert_equal @record.foo, "aaa bbb"
186
222
  end
187
223
 
188
224
  it "should do normal nullify with empty string" do
189
225
  @record = MockRecordWithSqueeze.new
190
226
  @record.foo = " "
191
227
  @record.valid?
192
- @record.foo.must_be_nil
228
+ assert_nil @record.foo
193
229
  end
194
230
  end
195
231
 
@@ -204,7 +240,7 @@ describe AutoStripAttributes do
204
240
  @record = MockRecordWithDelete.new
205
241
  @record.foo = " a \t bbb"
206
242
  @record.valid?
207
- @record.foo.must_equal "abbb"
243
+ assert_equal @record.foo, "abbb"
208
244
  end
209
245
  end
210
246
 
@@ -212,22 +248,31 @@ describe AutoStripAttributes do
212
248
  class MockRecordWithMultipleAttributes < MockRecordParent #< ActiveRecord::Base
213
249
  #column :foo, :string
214
250
  #column :bar, :string
215
- #column :biz, :string
216
- #column :bang, :integer
217
- attr_accessor :foo, :bar, :biz, :bang
218
- auto_strip_attributes :foo, :bar
219
- auto_strip_attributes :biz, {nullify: false, squish: true}
251
+ #column :baz, :string
252
+ #column :qux, :string, array: true
253
+ #column :quux, :string, array: true
254
+ #column :quuz, :string, array: true
255
+ attr_accessor :foo, :bar, :baz, :qux, :quux, :quuz
256
+ auto_strip_attributes :foo, :bar, :qux
257
+ auto_strip_attributes :baz, :quux, {nullify: false, squish: true}
258
+ auto_strip_attributes :quuz, {nullify: true, nullify_array: false}
220
259
  end
221
260
 
222
261
  it "should handle everything ok" do
223
262
  @record = MockRecordWithMultipleAttributes.new
224
263
  @record.foo = " foo\tfoo"
225
264
  @record.bar = " "
226
- @record.biz = " "
265
+ @record.baz = " "
266
+ @record.qux = ["\n"]
267
+ @record.quux = [" foo\tfoo", " "]
268
+ @record.quuz = [" "]
227
269
  @record.valid?
228
- @record.foo.must_equal "foo\tfoo"
229
- @record.bar.must_be_nil
230
- @record.biz.must_equal ""
270
+ assert_equal @record.foo, "foo\tfoo"
271
+ assert_nil @record.bar
272
+ assert_equal @record.baz, ""
273
+ assert_nil @record.qux
274
+ assert_equal @record.quux, ["foo foo", ""]
275
+ assert_equal @record.quuz, []
231
276
  end
232
277
  end
233
278
 
@@ -245,9 +290,9 @@ describe AutoStripAttributes do
245
290
  it "should not call setter again in before_validation" do
246
291
  @record = MockRecordWithCustomSetter.new
247
292
  @record.foo = " foo "
248
- @record.foo.must_equal " foo - foo "
293
+ assert_equal @record.foo, " foo - foo "
249
294
  @record.valid?
250
- @record.foo.must_equal "foo - foo"
295
+ assert_equal @record.foo, "foo - foo"
251
296
  end
252
297
  end
253
298
 
@@ -270,9 +315,9 @@ describe AutoStripAttributes do
270
315
  it "should handle everything ok" do
271
316
  @record = MockVirtualAttribute.new
272
317
  @record.foo = " foo "
273
- @record.foo.must_equal " foo "
318
+ assert_equal @record.foo, " foo "
274
319
  @record.valid?
275
- @record.foo.must_equal "foo"
320
+ assert_equal @record.foo, "foo"
276
321
  end
277
322
  end
278
323
 
@@ -284,7 +329,7 @@ describe AutoStripAttributes do
284
329
  it "should have default filters set in right order" do
285
330
  AutoStripAttributes::Config.setup(clear_previous: true)
286
331
  filters_order = AutoStripAttributes::Config.filters_order
287
- filters_order.must_equal [:convert_non_breaking_spaces, :strip, :nullify, :squish, :delete_whitespaces]
332
+ assert_equal filters_order, [:convert_non_breaking_spaces, :strip, :nullify, :nullify_array, :squish, :delete_whitespaces]
288
333
  end
289
334
 
290
335
  it "should reset filters to defaults when :clear is true" do
@@ -295,7 +340,7 @@ describe AutoStripAttributes do
295
340
  end
296
341
  AutoStripAttributes::Config.setup(clear_previous: true)
297
342
  filters_order = AutoStripAttributes::Config.filters_order
298
- filters_order.must_equal [:convert_non_breaking_spaces, :strip, :nullify, :squish, :delete_whitespaces]
343
+ assert_equal filters_order, [:convert_non_breaking_spaces, :strip, :nullify, :nullify_array, :squish, :delete_whitespaces]
299
344
  end
300
345
 
301
346
  it "should remove all filters when :clear is true and :defaults is false" do
@@ -306,7 +351,7 @@ describe AutoStripAttributes do
306
351
  end
307
352
  AutoStripAttributes::Config.setup(clear_previous: true, defaults: false)
308
353
  filter_order = AutoStripAttributes::Config.filters_order
309
- filter_order.must_equal []
354
+ assert_equal filter_order, []
310
355
 
311
356
  # returning to original state
312
357
  AutoStripAttributes::Config.setup(clear_previous: true)
@@ -328,14 +373,14 @@ describe AutoStripAttributes do
328
373
  filters_order = AutoStripAttributes::Config.filters_order
329
374
  filters_enabled = AutoStripAttributes::Config.filters_enabled
330
375
 
331
- filters_order.must_equal [:convert_non_breaking_spaces, :strip, :nullify, :squish, :delete_whitespaces, :test]
376
+ assert_equal filters_order, [:convert_non_breaking_spaces, :strip, :nullify, :nullify_array, :squish, :delete_whitespaces, :test]
332
377
  assert Proc === filters_block[:test]
333
- filters_enabled[:test].must_equal true
378
+ assert_equal filters_enabled[:test], true
334
379
 
335
380
  @record = MockRecordWithCustomFilter.new
336
381
  @record.foo = " FOO "
337
382
  @record.valid?
338
- @record.foo.must_equal "foo"
383
+ assert_equal @record.foo, "foo"
339
384
 
340
385
  # returning to original state
341
386
  AutoStripAttributes::Config.setup(clear_previous: true)
@@ -365,7 +410,7 @@ describe AutoStripAttributes do
365
410
  @record = CustomOptionsMockRecord.new
366
411
  @record.foo = " abcdefghijklmnopqrstijklmn"
367
412
  @record.valid?
368
- @record.foo.must_equal "abcd…"
413
+ assert_equal @record.foo, "abcd…"
369
414
  end
370
415
  end
371
416
 
@@ -397,21 +442,21 @@ describe AutoStripAttributes do
397
442
  @record = ComplexFirstMockRecord.new
398
443
  @record.foo = " FOO "
399
444
  @record.valid?
400
- @record.foo.must_equal "FOO"
445
+ assert_equal @record.foo, "FOO"
401
446
  end
402
447
 
403
448
  it "should use extra filters when given" do
404
449
  @record = ComplexFirstMockRecord.new
405
450
  @record.bar_downcase = " BAR "
406
451
  @record.valid?
407
- @record.bar_downcase.must_equal "bar"
452
+ assert_equal @record.bar_downcase, "bar"
408
453
  end
409
454
 
410
455
  it "should use extra filters when given and also respect given other configs" do
411
456
  @record = ComplexFirstMockRecord.new
412
457
  @record.bar_downcase = " "
413
458
  @record.valid?
414
- @record.bar_downcase.must_equal ""
459
+ assert_equal @record.bar_downcase, ""
415
460
  end
416
461
  end
417
462
 
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.5.0
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Olli Huotari
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-09-06 00:00:00.000000000 Z
11
+ date: 2026-09-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -16,56 +16,62 @@ dependencies:
16
16
  requirements:
17
17
  - - ">="
18
18
  - !ruby/object:Gem::Version
19
- version: '4.0'
19
+ version: '7.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '9'
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - ">="
25
28
  - !ruby/object:Gem::Version
26
- version: '4.0'
29
+ version: '7.1'
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '9'
27
33
  - !ruby/object:Gem::Dependency
28
34
  name: minitest
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - ">="
32
38
  - !ruby/object:Gem::Version
33
- version: 2.8.1
39
+ version: '3.0'
34
40
  type: :development
35
41
  prerelease: false
36
42
  version_requirements: !ruby/object:Gem::Requirement
37
43
  requirements:
38
44
  - - ">="
39
45
  - !ruby/object:Gem::Version
40
- version: 2.8.1
46
+ version: '3.0'
41
47
  - !ruby/object:Gem::Dependency
42
48
  name: mocha
43
49
  requirement: !ruby/object:Gem::Requirement
44
50
  requirements:
45
51
  - - "~>"
46
52
  - !ruby/object:Gem::Version
47
- version: '0.14'
53
+ version: '2.1'
48
54
  type: :development
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
51
57
  requirements:
52
58
  - - "~>"
53
59
  - !ruby/object:Gem::Version
54
- version: '0.14'
60
+ version: '2.1'
55
61
  - !ruby/object:Gem::Dependency
56
62
  name: rake
57
63
  requirement: !ruby/object:Gem::Requirement
58
64
  requirements:
59
65
  - - ">="
60
66
  - !ruby/object:Gem::Version
61
- version: '0'
67
+ version: '13.0'
62
68
  type: :development
63
69
  prerelease: false
64
70
  version_requirements: !ruby/object:Gem::Requirement
65
71
  requirements:
66
72
  - - ">="
67
73
  - !ruby/object:Gem::Version
68
- version: '0'
74
+ version: '13.0'
69
75
  description: AutoStripAttributes helps to remove unnecessary whitespaces from ActiveRecord
70
76
  or ActiveModel attributes. It's good for removing accidental spaces from user inputs.
71
77
  It works by adding a before_validation hook to the record. It has option to set
@@ -76,8 +82,8 @@ executables: []
76
82
  extensions: []
77
83
  extra_rdoc_files: []
78
84
  files:
85
+ - ".github/workflows/ci.yaml"
79
86
  - ".gitignore"
80
- - ".travis.yml"
81
87
  - CHANGELOG.md
82
88
  - Gemfile
83
89
  - README.md
@@ -92,7 +98,7 @@ homepage: https://github.com/holli/auto_strip_attributes
92
98
  licenses:
93
99
  - MIT
94
100
  metadata: {}
95
- post_install_message:
101
+ post_install_message:
96
102
  rdoc_options: []
97
103
  require_paths:
98
104
  - lib
@@ -100,16 +106,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
100
106
  requirements:
101
107
  - - ">="
102
108
  - !ruby/object:Gem::Version
103
- version: '0'
109
+ version: '3.1'
104
110
  required_rubygems_version: !ruby/object:Gem::Requirement
105
111
  requirements:
106
112
  - - ">="
107
113
  - !ruby/object:Gem::Version
108
114
  version: '0'
109
115
  requirements: []
110
- rubyforge_project: auto_strip_attributes
111
- rubygems_version: 2.6.14
112
- signing_key:
116
+ rubygems_version: 3.5.22
117
+ signing_key:
113
118
  specification_version: 4
114
119
  summary: Removes unnecessary whitespaces in attributes. Extension to ActiveRecord
115
120
  or ActiveModel.
data/.travis.yml DELETED
@@ -1,14 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- cache: bundler
4
- rvm:
5
- - 2.2.9
6
- - 2.3.1
7
- - 2.4.4
8
- - 2.5.1
9
- env:
10
- - "RAILS_VERSION=4.2"
11
- - "RAILS_VERSION=5.0"
12
- - "RAILS_VERSION=5.1"
13
- - "RAILS_VERSION=5.2"
14
-