strip_attributes 1.9.1 → 1.9.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45ea7e1316e058313b4aa362722d1b3eced15ed144b1c9576ef01834181d9733
4
- data.tar.gz: f38bd5fb9ac513e5a72cedaee5caf43e72d2e08c89d1fa9e234f7f30b798b961
3
+ metadata.gz: e1f5a0320df5a7bdf5e4b54823d4d377d90c2e42243d548d98106d462818074b
4
+ data.tar.gz: e08452bcd46e297a856dcaa16f938dcdfaa4978dcf8438e8aa0e2cb4cbf89f1e
5
5
  SHA512:
6
- metadata.gz: ec101c79b0d25e128b848e233fbc614b87e6bf8ea6e1a8650d1863808cbb862f650ff516b89e569d0e491d3b49cdd995a24c8f37bae2875cc5ad581ef7f31aa3
7
- data.tar.gz: 28ceffbb9193abd64abf82bf2e22ff5a492d88255209a627e7e3d03c701bc2a98b370de0d5b7c16ed2cc6c803f3fb3903bceca1b36784dd85f4d44b76c91960d
6
+ metadata.gz: 8db784d24f9d7e38fc28dce00708223964eb770d0931bcac8ce2e954ce83e74a0f6525f8dac3e01e8670c62c3ba8b8650760caa4e857d71e99fa67653157efa2
7
+ data.tar.gz: 9451bb01daefe3b3d2624dae4cc0ee010d166eb26f959fcf822fcb1a095cbc0608f9f31461b75367f210301a3b72945a94d48c5f287b4544c38e5183ce76105d
@@ -58,6 +58,8 @@ module StripAttributes
58
58
  end
59
59
 
60
60
  def self.strip_string(value, options = {})
61
+ return value unless value.is_a?(String)
62
+
61
63
  allow_empty = options[:allow_empty]
62
64
  collapse_spaces = options[:collapse_spaces]
63
65
  replace_newlines = options[:replace_newlines]
@@ -1,3 +1,3 @@
1
1
  module StripAttributes
2
- VERSION = "1.9.1"
2
+ VERSION = "1.9.2"
3
3
  end
@@ -61,6 +61,17 @@ class ReplaceNewLinesAndDuplicateSpaces < Tableless
61
61
  strip_attributes replace_newlines: true, collapse_spaces: true
62
62
  end
63
63
 
64
+ class CoexistWithOtherObjects < Tableless
65
+ attr_accessor :arr, :hsh, :str
66
+ strip_attributes
67
+ def initialize
68
+ @arr, @hsh, @str = [], {}, "foo "
69
+ end
70
+ def attributes
71
+ {arr: arr, hsh: hsh, str: str}
72
+ end
73
+ end
74
+
64
75
  class CoexistWithOtherValidations < Tableless
65
76
  attribute :number, type: Integer
66
77
 
@@ -242,6 +253,14 @@ class StripAttributesTest < Minitest::Test
242
253
  assert_equal "", record.bang
243
254
  end
244
255
 
256
+ def test_should_allow_other_empty_objects
257
+ record = CoexistWithOtherObjects.new
258
+ record.valid?
259
+ assert_equal [], record.arr
260
+ assert_equal({}, record.hsh)
261
+ assert_equal "foo", record.str
262
+ end
263
+
245
264
  def test_should_coexist_with_other_validations
246
265
  record = CoexistWithOtherValidations.new
247
266
  record.number = 1000.1
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: strip_attributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.9.1
4
+ version: 1.9.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan McGeary
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-14 00:00:00.000000000 Z
11
+ date: 2020-02-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel