activecleaner 0.3.0 → 0.3.1

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: f568e263b920da28be6897d33c390ba37d100d02
4
- data.tar.gz: 6649a5b52ece6e7181a8c3d8bc635c3e671dd5d7
3
+ metadata.gz: 158e7ce1e853b39bf241a0bfbe3d50b7e583b18e
4
+ data.tar.gz: 5d6da62887b63399be53d73c00e5dda6a77f008c
5
5
  SHA512:
6
- metadata.gz: 09c356b188281b08dd78d2c9d99622234c0be6d2be3f795a9dce25c7e27c527f3e5880cf60f4f125bad8f648e319658aeab9d810c47cf7e7b97f1467122e3cc0
7
- data.tar.gz: 26fcaef9a2105e5df417ec0a8c1440d56b1792acfac489bbd2606fdc1464333dcbb83296cf6f4084abcc61398920cd0cb10244f7a308d4ddfcd1b5187810bc5a
6
+ metadata.gz: 7ae1bd28121eb544095c27f801b6d20b15cef8e3b0f790ac6153728b178acd84b4d35ac182a27c34bce1559f41358e967f0a5dfd0a60d7e3810a715388bb2659
7
+ data.tar.gz: 3e04e8552411cd72504bb451fa76c822b48443bac2f299473efe3bf623ba3207ea0115e802be5812321bc6dbe781b6421fd03e32fe08a68ba7459c569d3245c4
@@ -4,7 +4,8 @@ module ActiveCleaner
4
4
  class MarkdownCleaner < BaseCleaner
5
5
 
6
6
  def clean_value(old_value, record=nil)
7
- unless old_value.nil?
7
+ case old_value
8
+ when String
8
9
  value = old_value.dup
9
10
 
10
11
  value.strip!
@@ -25,6 +26,8 @@ module ActiveCleaner
25
26
  value.gsub!(/__SPACE__/, " ")
26
27
 
27
28
  value
29
+ else
30
+ old_value
28
31
  end
29
32
  end
30
33
 
@@ -4,13 +4,16 @@ module ActiveCleaner
4
4
  class StringCleaner < BaseCleaner
5
5
 
6
6
  def clean_value(old_value, record=nil)
7
- unless old_value.nil?
7
+ case old_value
8
+ when String
8
9
  value = old_value.dup
9
10
 
10
11
  value.strip!
11
12
  value.gsub!(/\s+/, " ")
12
13
 
13
14
  value
15
+ else
16
+ old_value
14
17
  end
15
18
  end
16
19
 
@@ -4,7 +4,8 @@ module ActiveCleaner
4
4
  class TextCleaner < BaseCleaner
5
5
 
6
6
  def clean_value(old_value, record=nil)
7
- unless old_value.nil?
7
+ case old_value
8
+ when String
8
9
  value = old_value.dup
9
10
 
10
11
  value.strip!
@@ -23,6 +24,8 @@ module ActiveCleaner
23
24
  value.gsub!(/__NEW_LINE__/, "\n")
24
25
 
25
26
  value
27
+ else
28
+ old_value
26
29
  end
27
30
  end
28
31
 
@@ -4,8 +4,11 @@ module ActiveCleaner
4
4
  class Utf8mb3Cleaner < BaseCleaner
5
5
 
6
6
  def clean_value(old_value, record=nil)
7
- unless old_value.nil?
7
+ case old_value
8
+ when String
8
9
  old_value.each_char.select { |char| char.bytesize < 4 }.join('')
10
+ else
11
+ old_value
9
12
  end
10
13
  end
11
14
 
@@ -2,7 +2,7 @@
2
2
  module ActiveCleaner
3
3
  module Version
4
4
 
5
- STRING = '0.3.0'
5
+ STRING = '0.3.1'
6
6
 
7
7
  end
8
8
  end
@@ -7,6 +7,13 @@ describe ActiveCleaner::MarkdownCleaner do
7
7
 
8
8
  describe "#clean_value" do
9
9
 
10
+ it "doesn't touch non string value" do
11
+ expect(cleaner.clean_value(nil)).to eq(nil)
12
+ expect(cleaner.clean_value(true)).to eq(true)
13
+ expect(cleaner.clean_value(false)).to eq(false)
14
+ expect(cleaner.clean_value(10)).to eq(10)
15
+ end
16
+
10
17
  it "doesn't touch legit value" do
11
18
  body = ""
12
19
  body << "= Title =\n"
@@ -7,6 +7,13 @@ describe ActiveCleaner::StringCleaner do
7
7
 
8
8
  describe "#clean_value" do
9
9
 
10
+ it "doesn't touch non string value" do
11
+ expect(cleaner.clean_value(nil)).to eq(nil)
12
+ expect(cleaner.clean_value(true)).to eq(true)
13
+ expect(cleaner.clean_value(false)).to eq(false)
14
+ expect(cleaner.clean_value(10)).to eq(10)
15
+ end
16
+
10
17
  it "doesn't touch legit value" do
11
18
  expect(cleaner.clean_value("A good title!")).to eq("A good title!")
12
19
  end
@@ -7,6 +7,13 @@ describe ActiveCleaner::TextCleaner do
7
7
 
8
8
  describe "#clean_value" do
9
9
 
10
+ it "doesn't touch non string value" do
11
+ expect(cleaner.clean_value(nil)).to eq(nil)
12
+ expect(cleaner.clean_value(true)).to eq(true)
13
+ expect(cleaner.clean_value(false)).to eq(false)
14
+ expect(cleaner.clean_value(10)).to eq(10)
15
+ end
16
+
10
17
  it "doesn't touch legit value" do
11
18
  [
12
19
  "Lorem ipsum dolor sit amet.",
@@ -7,6 +7,13 @@ describe ActiveCleaner::Utf8mb3Cleaner do
7
7
 
8
8
  describe "#clean_value" do
9
9
 
10
+ it "doesn't touch non string value" do
11
+ expect(cleaner.clean_value(nil)).to eq(nil)
12
+ expect(cleaner.clean_value(true)).to eq(true)
13
+ expect(cleaner.clean_value(false)).to eq(false)
14
+ expect(cleaner.clean_value(10)).to eq(10)
15
+ end
16
+
10
17
  it "doesn't touch legit value" do
11
18
  expect(cleaner.clean_value("A good title!")).to eq("A good title!")
12
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activecleaner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Maxime Garcia
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-16 00:00:00.000000000 Z
11
+ date: 2014-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -19,7 +19,7 @@ dependencies:
19
19
  version: '3.1'
20
20
  - - "<"
21
21
  - !ruby/object:Gem::Version
22
- version: '4.2'
22
+ version: '5'
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
@@ -29,7 +29,7 @@ dependencies:
29
29
  version: '3.1'
30
30
  - - "<"
31
31
  - !ruby/object:Gem::Version
32
- version: '4.2'
32
+ version: '5'
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: activesupport
35
35
  requirement: !ruby/object:Gem::Requirement
@@ -39,7 +39,7 @@ dependencies:
39
39
  version: '3.1'
40
40
  - - "<"
41
41
  - !ruby/object:Gem::Version
42
- version: '4.2'
42
+ version: '5'
43
43
  type: :runtime
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
@@ -49,7 +49,7 @@ dependencies:
49
49
  version: '3.1'
50
50
  - - "<"
51
51
  - !ruby/object:Gem::Version
52
- version: '4.2'
52
+ version: '5'
53
53
  - !ruby/object:Gem::Dependency
54
54
  name: rspec
55
55
  requirement: !ruby/object:Gem::Requirement
@@ -118,17 +118,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
118
118
  version: 1.3.6
119
119
  requirements: []
120
120
  rubyforge_project:
121
- rubygems_version: 2.4.2
121
+ rubygems_version: 2.4.1
122
122
  signing_key:
123
123
  specification_version: 4
124
124
  summary: Clean the fields in your models
125
125
  test_files:
126
- - spec/cases/simple_spec.rb
127
- - spec/cases/inherit_spec.rb
128
- - spec/cases/nilify_spec.rb
129
- - spec/lib/active_cleaner/text_cleaner_spec.rb
130
126
  - spec/lib/active_cleaner/utf8mb4_cleaner_spec.rb
131
127
  - spec/lib/active_cleaner/string_cleaner_spec.rb
128
+ - spec/lib/active_cleaner/text_cleaner_spec.rb
132
129
  - spec/lib/active_cleaner/markdown_cleaner_spec.rb
133
130
  - spec/lib/active_cleaner_spec.rb
134
131
  - spec/spec_helper.rb
132
+ - spec/cases/inherit_spec.rb
133
+ - spec/cases/simple_spec.rb
134
+ - spec/cases/nilify_spec.rb