activecleaner 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 54ad3d4c2a454cfb2e8237abb6399bab45d5448c
4
+ data.tar.gz: 3bf151d63ce0286fa4819a2ce1a25e61a62a3047
5
+ SHA512:
6
+ metadata.gz: 46a2b65f759e7d9501de3795637707e9a5de27375185526e7fc55c6bb9cd270f880b498e0e6817f3ac414d68449407734f5976b9107bbb8727b28585f01c13d8
7
+ data.tar.gz: 7a7d84b9e7ff1e68733b13e1b4c995f85f07f001a2a77de562c2ef501ae76aae9cdc222c0fc6eeafb2337645c9a76602f353feab9b2955ea4ab319b2ff81cb6e
data/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # ActiveCleaner
2
2
 
3
+ [![Gem Version](https://badge.fury.io/rb/activecleaner.svg)](http://badge.fury.io/rb/activecleaner) [![Build Status](https://travis-ci.org/maximeg/activecleaner.svg?branch=master)](https://travis-ci.org/maximeg/activecleaner)
4
+
3
5
  `ActiveCleaner` is a set of helpers that helps you in cleaning user-typed content in your ActiveModel depending models (ActiveRecord, Mongoid...)
4
6
 
5
7
  Extra spaces mean extra storage. And it could ruin your indexes and your sortings.
@@ -22,8 +24,8 @@ end
22
24
  ### Cleaners included
23
25
 
24
26
  * `:string` (StringCleaner, the default one) : cleans all the space characters. It turns `" A \n \t title \t "` into `"A title"`.
25
- * `:text` (TextCleaner) : like `:string`, but preserves new lines (with a max of 2 successive new lines). Usefull when the field is rendered with the `simple_format` Rails helper.
26
- * `:markdown` (MarkdownCleaner) : like `:text`, but preserves spaces in the begining of lines (the indentation). Usefull for... markdown!
27
+ * `:text` (TextCleaner) : like `:string`, but preserves new lines (with a max of 2 successive new lines). useful when the field is rendered with the `simple_format` Rails helper.
28
+ * `:markdown` (MarkdownCleaner) : like `:text`, but preserves spaces in the beginning of lines (the indentation). useful for... markdown!
27
29
 
28
30
 
29
31
 
@@ -91,6 +93,6 @@ You can also use `guard` to run the specs during dev.
91
93
  * Maxime Garcia [emaxime.com](http://emaxime.com) [@maximegarcia](http://twitter.com/maximegarcia)
92
94
 
93
95
 
94
- [License](https://github.com/maximeg/activecleaner/blob/master/LCENSE)
96
+ [License](https://github.com/maximeg/activecleaner/blob/master/LICENSE)
95
97
  \- [Report a bug](https://github.com/maximeg/activecleaner/issues)
96
- [![Continuous Integration status](https://secure.travis-ci.org/maximeg/activecleaner.png)](http://travis-ci.org/maximeg/activecleaner)
98
+ \- [Rubygems page](https://rubygems.org/gems/activecleaner)
@@ -2,7 +2,7 @@
2
2
  module ActiveCleaner
3
3
  module Version
4
4
 
5
- STRING = '0.1.0'
5
+ STRING = '0.2.0'
6
6
 
7
7
  end
8
8
  end
@@ -31,14 +31,16 @@ describe "Case: an ad and his inherited car ad" do
31
31
 
32
32
  subject { Ad._cleaners }
33
33
 
34
- it { should have(2).fields_to_clean }
34
+ it "has 2 cleaners" do
35
+ expect(subject.length).to eq(2)
36
+ end
35
37
 
36
38
  it "includes a StringCleaner for #title" do
37
- subject[:title].first.should eq(ActiveCleaner::StringCleaner.new(:title))
39
+ expect(subject[:title].first).to eq(ActiveCleaner::StringCleaner.new(:title))
38
40
  end
39
41
 
40
42
  it "includes a StringCleaner for #name" do
41
- subject[:name].first.should eq(ActiveCleaner::StringCleaner.new(:name))
43
+ expect(subject[:name].first).to eq(ActiveCleaner::StringCleaner.new(:name))
42
44
  end
43
45
 
44
46
  end # describe
@@ -47,40 +49,40 @@ describe "Case: an ad and his inherited car ad" do
47
49
 
48
50
  subject { CarAd._cleaners }
49
51
 
50
- it { should have(3).fields_to_clean }
52
+ it "has 3 cleaners" do
53
+ expect(subject.length).to eq(3)
54
+ end
51
55
 
52
56
  it "includes a StringCleaner for #title" do
53
- subject[:title].first.should eq(ActiveCleaner::StringCleaner.new(:title))
57
+ expect(subject[:title].first).to eq(ActiveCleaner::StringCleaner.new(:title))
54
58
  end
55
59
 
56
60
  it "includes a StringCleaner for #name" do
57
- subject[:name].first.should eq(ActiveCleaner::StringCleaner.new(:name))
61
+ expect(subject[:name].first).to eq(ActiveCleaner::StringCleaner.new(:name))
58
62
  end
59
63
 
60
64
  it "includes a TextCleaner for #body" do
61
- subject[:body].first.should eq(ActiveCleaner::TextCleaner.new(:body))
65
+ expect(subject[:body].first).to eq(ActiveCleaner::TextCleaner.new(:body))
62
66
  end
63
67
 
64
68
  end # describe
65
69
 
66
70
  context "considering a car ad" do
67
71
 
68
- before do
69
- @car_ad = CarAd.new
70
- end
72
+ let(:subject) { CarAd.new }
71
73
 
72
74
  describe "#title, marked as to clean with no type" do
73
75
 
74
76
  it "is untouched when legit" do
75
- @car_ad.title = "A good title!"
76
- @car_ad.valid?
77
- @car_ad.title.should eq "A good title!"
77
+ subject.title = "A good title!"
78
+ subject.valid?
79
+ expect(subject.title).to eq("A good title!")
78
80
  end
79
81
 
80
82
  it "is cleaned as a string" do
81
- @car_ad.title = " A \n good \t title! "
82
- @car_ad.valid?
83
- @car_ad.title.should eq "A good title!"
83
+ subject.title = " A \n good \t title! "
84
+ subject.valid?
85
+ expect(subject.title).to eq("A good title!")
84
86
  end
85
87
 
86
88
  end # describe
@@ -88,15 +90,15 @@ describe "Case: an ad and his inherited car ad" do
88
90
  describe "#name, marked as to clean as a string" do
89
91
 
90
92
  it "is untouched when legit" do
91
- @car_ad.name = "John Doe"
92
- @car_ad.valid?
93
- @car_ad.name.should eq "John Doe"
93
+ subject.name = "John Doe"
94
+ subject.valid?
95
+ expect(subject.name).to eq("John Doe")
94
96
  end
95
97
 
96
98
  it "is cleaned as a string" do
97
- @car_ad.name = " \t John \n Doe "
98
- @car_ad.valid?
99
- @car_ad.name.should eq "John Doe"
99
+ subject.name = " \t John \n Doe "
100
+ subject.valid?
101
+ expect(subject.name).to eq("John Doe")
100
102
  end
101
103
 
102
104
  end # describe
@@ -104,15 +106,15 @@ describe "Case: an ad and his inherited car ad" do
104
106
  describe "#body, marked as to clean as a text" do
105
107
 
106
108
  it "is untouched when legit" do
107
- @car_ad.body = "Lorem ipsum\ndolor sit amet.\n\nLorem."
108
- @car_ad.valid?
109
- @car_ad.body.should eq "Lorem ipsum\ndolor sit amet.\n\nLorem."
109
+ subject.body = "Lorem ipsum\ndolor sit amet.\n\nLorem."
110
+ subject.valid?
111
+ expect(subject.body).to eq("Lorem ipsum\ndolor sit amet.\n\nLorem.")
110
112
  end
111
113
 
112
114
  it "is cleaned as a text" do
113
- @car_ad.body = "Lorem \t ipsum \t \n dolor \t sit \t amet.\n\n\nLorem."
114
- @car_ad.valid?
115
- @car_ad.body.should eq "Lorem ipsum\ndolor sit amet.\n\nLorem."
115
+ subject.body = "Lorem \t ipsum \t \n dolor \t sit \t amet.\n\n\nLorem."
116
+ subject.valid?
117
+ expect(subject.body).to eq("Lorem ipsum\ndolor sit amet.\n\nLorem.")
116
118
  end
117
119
 
118
120
  end # describe
@@ -26,40 +26,40 @@ describe "Case: a simple post with nulify" do
26
26
 
27
27
  subject { OptimizedPost._cleaners }
28
28
 
29
- it { should have(3).fields_to_clean }
29
+ it "has 3 cleaners" do
30
+ expect(subject.length).to eq(3)
31
+ end
30
32
 
31
33
  it "includes a StringCleaner for #title" do
32
- subject[:title].first.should eq(ActiveCleaner::StringCleaner.new(:title, nilify: true))
34
+ expect(subject[:title].first).to eq(ActiveCleaner::StringCleaner.new(:title, nilify: true))
33
35
  end
34
36
 
35
37
  it "includes a StringCleaner for #name" do
36
- subject[:name].first.should eq(ActiveCleaner::StringCleaner.new(:name, nilify: true))
38
+ expect(subject[:name].first).to eq(ActiveCleaner::StringCleaner.new(:name, nilify: true))
37
39
  end
38
40
 
39
41
  it "includes a TextCleaner for #body" do
40
- subject[:body].first.should eq(ActiveCleaner::TextCleaner.new(:body, nilify: true))
42
+ expect(subject[:body].first).to eq(ActiveCleaner::TextCleaner.new(:body, nilify: true))
41
43
  end
42
44
 
43
45
  end # describe
44
46
 
45
47
  context "considering a post" do
46
48
 
47
- before do
48
- @post = OptimizedPost.new
49
- end
49
+ let(:subject) { OptimizedPost.new }
50
50
 
51
51
  describe "#title, marked as to clean with no type" do
52
52
 
53
53
  it "is untouched when legit" do
54
- @post.title = "A good title!"
55
- @post.valid?
56
- @post.title.should eq "A good title!"
54
+ subject.title = "A good title!"
55
+ subject.valid?
56
+ expect(subject.title).to eq("A good title!")
57
57
  end
58
58
 
59
59
  it "is nulified" do
60
- @post.title = " \n \t "
61
- @post.valid?
62
- @post.title.should be_nil
60
+ subject.title = " \n \t "
61
+ subject.valid?
62
+ expect(subject.title).to be_nil
63
63
  end
64
64
 
65
65
  end # describe
@@ -67,15 +67,15 @@ describe "Case: a simple post with nulify" do
67
67
  describe "#name, marked as to clean as a string" do
68
68
 
69
69
  it "is untouched when legit" do
70
- @post.name = "John Doe"
71
- @post.valid?
72
- @post.name.should eq "John Doe"
70
+ subject.name = "John Doe"
71
+ subject.valid?
72
+ expect(subject.name).to eq("John Doe")
73
73
  end
74
74
 
75
75
  it "is nulified" do
76
- @post.title = " \n \t "
77
- @post.valid?
78
- @post.title.should be_nil
76
+ subject.title = " \n \t "
77
+ subject.valid?
78
+ expect(subject.title).to be_nil
79
79
  end
80
80
 
81
81
  end # describe
@@ -83,15 +83,15 @@ describe "Case: a simple post with nulify" do
83
83
  describe "#body, marked as to clean as a text" do
84
84
 
85
85
  it "is untouched when legit" do
86
- @post.body = "Lorem ipsum\ndolor sit amet.\n\nLorem."
87
- @post.valid?
88
- @post.body.should eq "Lorem ipsum\ndolor sit amet.\n\nLorem."
86
+ subject.body = "Lorem ipsum\ndolor sit amet.\n\nLorem."
87
+ subject.valid?
88
+ expect(subject.body).to eq("Lorem ipsum\ndolor sit amet.\n\nLorem.")
89
89
  end
90
90
 
91
91
  it "is nulified" do
92
- @post.title = " \n \t "
93
- @post.valid?
94
- @post.title.should be_nil
92
+ subject.title = " \n \t "
93
+ subject.valid?
94
+ expect(subject.title).to be_nil
95
95
  end
96
96
 
97
97
  end # describe
@@ -26,40 +26,40 @@ describe "Case: a simple post" do
26
26
 
27
27
  subject { Post._cleaners }
28
28
 
29
- it { should have(3).fields_to_clean }
29
+ it "has 3 cleaners" do
30
+ expect(subject.length).to eq(3)
31
+ end
30
32
 
31
33
  it "includes a StringCleaner for #title" do
32
- subject[:title].first.should eq(ActiveCleaner::StringCleaner.new(:title))
34
+ expect(subject[:title].first).to eq(ActiveCleaner::StringCleaner.new(:title))
33
35
  end
34
36
 
35
37
  it "includes a StringCleaner for #name" do
36
- subject[:name].first.should eq(ActiveCleaner::StringCleaner.new(:name))
38
+ expect(subject[:name].first).to eq(ActiveCleaner::StringCleaner.new(:name))
37
39
  end
38
40
 
39
41
  it "includes a TextCleaner for #body" do
40
- subject[:body].first.should eq(ActiveCleaner::TextCleaner.new(:body))
42
+ expect(subject[:body].first).to eq(ActiveCleaner::TextCleaner.new(:body))
41
43
  end
42
44
 
43
45
  end # describe
44
46
 
45
47
  context "considering a post" do
46
48
 
47
- before do
48
- @post = Post.new
49
- end
49
+ let(:subject) { Post.new }
50
50
 
51
51
  describe "#title, marked as to clean with no type" do
52
52
 
53
53
  it "is untouched when legit" do
54
- @post.title = "A good title!"
55
- @post.valid?
56
- @post.title.should eq "A good title!"
54
+ subject.title = "A good title!"
55
+ subject.valid?
56
+ expect(subject.title).to eq("A good title!")
57
57
  end
58
58
 
59
59
  it "is cleaned as a string" do
60
- @post.title = " A \n good \t title! "
61
- @post.valid?
62
- @post.title.should eq "A good title!"
60
+ subject.title = " A \n good \t title! "
61
+ subject.valid?
62
+ expect(subject.title).to eq("A good title!")
63
63
  end
64
64
 
65
65
  end # describe
@@ -67,15 +67,15 @@ describe "Case: a simple post" do
67
67
  describe "#name, marked as to clean as a string" do
68
68
 
69
69
  it "is untouched when legit" do
70
- @post.name = "John Doe"
71
- @post.valid?
72
- @post.name.should eq "John Doe"
70
+ subject.name = "John Doe"
71
+ subject.valid?
72
+ expect(subject.name).to eq("John Doe")
73
73
  end
74
74
 
75
75
  it "is cleaned as a string" do
76
- @post.name = " \t John \n Doe "
77
- @post.valid?
78
- @post.name.should eq "John Doe"
76
+ subject.name = " \t John \n Doe "
77
+ subject.valid?
78
+ expect(subject.name).to eq("John Doe")
79
79
  end
80
80
 
81
81
  end # describe
@@ -83,15 +83,15 @@ describe "Case: a simple post" do
83
83
  describe "#body, marked as to clean as a text" do
84
84
 
85
85
  it "is untouched when legit" do
86
- @post.body = "Lorem ipsum\ndolor sit amet.\n\nLorem."
87
- @post.valid?
88
- @post.body.should eq "Lorem ipsum\ndolor sit amet.\n\nLorem."
86
+ subject.body = "Lorem ipsum\ndolor sit amet.\n\nLorem."
87
+ subject.valid?
88
+ expect(subject.body).to eq("Lorem ipsum\ndolor sit amet.\n\nLorem.")
89
89
  end
90
90
 
91
91
  it "is cleaned as a text" do
92
- @post.body = "Lorem \t ipsum \t \n dolor \t sit \t amet.\n\n\nLorem."
93
- @post.valid?
94
- @post.body.should eq "Lorem ipsum\ndolor sit amet.\n\nLorem."
92
+ subject.body = "Lorem \t ipsum \t \n dolor \t sit \t amet.\n\n\nLorem."
93
+ subject.valid?
94
+ expect(subject.body).to eq("Lorem ipsum\ndolor sit amet.\n\nLorem.")
95
95
  end
96
96
 
97
97
  end # describe
@@ -3,9 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  describe ActiveCleaner::MarkdownCleaner do
5
5
 
6
- before do
7
- @cleaner = ActiveCleaner::MarkdownCleaner.new(:body)
8
- end
6
+ let(:cleaner) { ActiveCleaner::MarkdownCleaner.new(:body) }
9
7
 
10
8
  describe "#clean_value" do
11
9
 
@@ -27,7 +25,7 @@ describe ActiveCleaner::MarkdownCleaner do
27
25
  body << "\n"
28
26
  body << "A third paragraph."
29
27
 
30
- @cleaner.clean_value(body).should eq body
28
+ expect(cleaner.clean_value(body)).to eq(body)
31
29
  end
32
30
 
33
31
  it "empties string full of spaces" do
@@ -38,28 +36,28 @@ describe ActiveCleaner::MarkdownCleaner do
38
36
  "\n",
39
37
  " \t\n \t\n \t\n \t\n",
40
38
  ].each do |title|
41
- @cleaner.clean_value(title).should eq ""
39
+ expect(cleaner.clean_value(title)).to eq("")
42
40
  end
43
41
  end
44
42
 
45
43
  it "cleans repeted spaces" do
46
- @cleaner.clean_value("Lorem ipsum \ndolor sit amet.").should eq "Lorem ipsum\ndolor sit amet."
47
- @cleaner.clean_value("Lorem \t ipsum \t \ndolor \t sit \t amet.").should eq "Lorem ipsum\ndolor sit amet."
44
+ expect(cleaner.clean_value("Lorem ipsum \ndolor sit amet.")).to eq("Lorem ipsum\ndolor sit amet.")
45
+ expect(cleaner.clean_value("Lorem \t ipsum \t \ndolor \t sit \t amet.")).to eq("Lorem ipsum\ndolor sit amet.")
48
46
  end
49
47
 
50
48
  context "considering the spaces in the beggining of lines" do
51
49
  it "preserves them" do
52
- @cleaner.clean_value("Lorem ipsum\n dolor sit amet.").should eq "Lorem ipsum\n dolor sit amet."
50
+ expect(cleaner.clean_value("Lorem ipsum\n dolor sit amet.")).to eq("Lorem ipsum\n dolor sit amet.")
53
51
  end
54
52
  it "clears line full of spaces" do
55
- @cleaner.clean_value("Lorem ipsum \n \n dolor sit amet.").should eq "Lorem ipsum\n\n dolor sit amet."
53
+ expect(cleaner.clean_value("Lorem ipsum \n \n dolor sit amet.")).to eq("Lorem ipsum\n\n dolor sit amet.")
56
54
  end
57
55
  end
58
56
 
59
57
  it "keeps two max succeeding new line" do
60
- @cleaner.clean_value("Lorem ipsum\n\n\ndolor sit amet.").should eq "Lorem ipsum\n\ndolor sit amet."
61
- @cleaner.clean_value("Lorem ipsum\n\n\n\ndolor sit amet.").should eq "Lorem ipsum\n\ndolor sit amet."
62
- @cleaner.clean_value("Lorem ipsum\n \n \n \ndolor sit amet.").should eq "Lorem ipsum\n\ndolor sit amet."
58
+ expect(cleaner.clean_value("Lorem ipsum\n\n\ndolor sit amet.")).to eq("Lorem ipsum\n\ndolor sit amet.")
59
+ expect(cleaner.clean_value("Lorem ipsum\n\n\n\ndolor sit amet.")).to eq("Lorem ipsum\n\ndolor sit amet.")
60
+ expect(cleaner.clean_value("Lorem ipsum\n \n \n \ndolor sit amet.")).to eq("Lorem ipsum\n\ndolor sit amet.")
63
61
  end
64
62
 
65
63
  end
@@ -3,14 +3,12 @@ require 'spec_helper'
3
3
 
4
4
  describe ActiveCleaner::StringCleaner do
5
5
 
6
- before do
7
- @cleaner = ActiveCleaner::StringCleaner.new(:title)
8
- end
6
+ let(:cleaner) { ActiveCleaner::StringCleaner.new(:title) }
9
7
 
10
8
  describe "#clean_value" do
11
9
 
12
10
  it "doesn't touch legit value" do
13
- @cleaner.clean_value("A good title!").should eq "A good title!"
11
+ expect(cleaner.clean_value("A good title!")).to eq("A good title!")
14
12
  end
15
13
 
16
14
  it "empties string full of spaces" do
@@ -21,23 +19,23 @@ describe ActiveCleaner::StringCleaner do
21
19
  "\n",
22
20
  " \t\n \t\n \t\n \t\n",
23
21
  ].each do |title|
24
- @cleaner.clean_value(title).should eq ""
22
+ expect(cleaner.clean_value(title)).to eq("")
25
23
  end
26
24
  end
27
25
 
28
26
  it "cleans leading and trailing spaces" do
29
- @cleaner.clean_value(" A good title! ").should eq "A good title!"
27
+ expect(cleaner.clean_value(" A good title! ")).to eq("A good title!")
30
28
  end
31
29
  it "cleans leading and trailing tabs" do
32
- @cleaner.clean_value("\tA good title!\t").should eq "A good title!"
30
+ expect(cleaner.clean_value("\tA good title!\t")).to eq("A good title!")
33
31
  end
34
32
  it "cleans leading and trailing lines" do
35
- @cleaner.clean_value("\nA good title!\n").should eq "A good title!"
33
+ expect(cleaner.clean_value("\nA good title!\n")).to eq("A good title!")
36
34
  end
37
35
 
38
36
  it "cleans repeted spaces" do
39
- @cleaner.clean_value("A good title!").should eq "A good title!"
40
- @cleaner.clean_value("A \n good \t title!").should eq "A good title!"
37
+ expect(cleaner.clean_value("A good title!")).to eq("A good title!")
38
+ expect(cleaner.clean_value("A \n good \t title!")).to eq("A good title!")
41
39
  end
42
40
 
43
41
  end
@@ -3,9 +3,7 @@ require 'spec_helper'
3
3
 
4
4
  describe ActiveCleaner::TextCleaner do
5
5
 
6
- before do
7
- @cleaner = ActiveCleaner::TextCleaner.new(:text)
8
- end
6
+ let(:cleaner) { ActiveCleaner::TextCleaner.new(:text) }
9
7
 
10
8
  describe "#clean_value" do
11
9
 
@@ -15,7 +13,7 @@ describe ActiveCleaner::TextCleaner do
15
13
  "Lorem ipsum\ndolor sit amet.",
16
14
  "Lorem ipsum\n\ndolor sit amet.",
17
15
  ].each do |text|
18
- @cleaner.clean_value(text).should eq text
16
+ expect(cleaner.clean_value(text)).to eq(text)
19
17
  end
20
18
  end
21
19
 
@@ -27,28 +25,28 @@ describe ActiveCleaner::TextCleaner do
27
25
  "\n",
28
26
  " \t\n \t\n \t\n \t\n",
29
27
  ].each do |title|
30
- @cleaner.clean_value(title).should eq ""
28
+ expect(cleaner.clean_value(title)).to eq("")
31
29
  end
32
30
  end
33
31
 
34
32
  it "cleans leading and trailing spaces" do
35
- @cleaner.clean_value(" Lorem ipsum\ndolor sit amet. ").should eq "Lorem ipsum\ndolor sit amet."
33
+ expect(cleaner.clean_value(" Lorem ipsum\ndolor sit amet. ")).to eq("Lorem ipsum\ndolor sit amet.")
36
34
  end
37
35
  it "cleans leading and trailing tabs" do
38
- @cleaner.clean_value("\tLorem ipsum\ndolor sit amet.\t").should eq "Lorem ipsum\ndolor sit amet."
36
+ expect(cleaner.clean_value("\tLorem ipsum\ndolor sit amet.\t")).to eq("Lorem ipsum\ndolor sit amet.")
39
37
  end
40
38
  it "cleans leading and trailing lines" do
41
- @cleaner.clean_value("\nLorem ipsum\ndolor sit amet.\n").should eq "Lorem ipsum\ndolor sit amet."
39
+ expect(cleaner.clean_value("\nLorem ipsum\ndolor sit amet.\n")).to eq("Lorem ipsum\ndolor sit amet.")
42
40
  end
43
41
 
44
42
  it "cleans repeted spaces" do
45
- @cleaner.clean_value("Lorem ipsum \n dolor sit amet.").should eq "Lorem ipsum\ndolor sit amet."
46
- @cleaner.clean_value("Lorem \t ipsum \t \n dolor \t sit \t amet.").should eq "Lorem ipsum\ndolor sit amet."
43
+ expect(cleaner.clean_value("Lorem ipsum \n dolor sit amet.")).to eq("Lorem ipsum\ndolor sit amet.")
44
+ expect(cleaner.clean_value("Lorem \t ipsum \t \n dolor \t sit \t amet.")).to eq("Lorem ipsum\ndolor sit amet.")
47
45
  end
48
46
 
49
47
  it "keeps two max succeeding new line" do
50
- @cleaner.clean_value("Lorem ipsum\n\n\ndolor sit amet.").should eq "Lorem ipsum\n\ndolor sit amet."
51
- @cleaner.clean_value("Lorem ipsum\n\n\n\ndolor sit amet.").should eq "Lorem ipsum\n\ndolor sit amet."
48
+ expect(cleaner.clean_value("Lorem ipsum\n\n\ndolor sit amet.")).to eq("Lorem ipsum\n\ndolor sit amet.")
49
+ expect(cleaner.clean_value("Lorem ipsum\n\n\n\ndolor sit amet.")).to eq("Lorem ipsum\n\ndolor sit amet.")
52
50
  end
53
51
 
54
52
  end
metadata CHANGED
@@ -1,115 +1,124 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activecleaner
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.0
4
+ version: 0.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Maxime Garcia
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2013-01-30 00:00:00.000000000 Z
11
+ date: 2014-08-19 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
14
+ name: activemodel
15
15
  requirement: !ruby/object:Gem::Requirement
16
- none: false
17
16
  requirements:
18
- - - ~>
17
+ - - ">="
19
18
  - !ruby/object:Gem::Version
20
19
  version: '3.1'
20
+ - - "<"
21
+ - !ruby/object:Gem::Version
22
+ version: '4.2'
23
+ type: :runtime
24
+ prerelease: false
21
25
  version_requirements: !ruby/object:Gem::Requirement
22
- none: false
23
26
  requirements:
24
- - - ~>
27
+ - - ">="
25
28
  - !ruby/object:Gem::Version
26
29
  version: '3.1'
27
- prerelease: false
28
- type: :runtime
29
- name: activemodel
30
+ - - "<"
31
+ - !ruby/object:Gem::Version
32
+ version: '4.2'
30
33
  - !ruby/object:Gem::Dependency
34
+ name: activesupport
31
35
  requirement: !ruby/object:Gem::Requirement
32
- none: false
33
36
  requirements:
34
- - - ~>
37
+ - - ">="
35
38
  - !ruby/object:Gem::Version
36
39
  version: '3.1'
40
+ - - "<"
41
+ - !ruby/object:Gem::Version
42
+ version: '4.2'
43
+ type: :runtime
44
+ prerelease: false
37
45
  version_requirements: !ruby/object:Gem::Requirement
38
- none: false
39
46
  requirements:
40
- - - ~>
47
+ - - ">="
41
48
  - !ruby/object:Gem::Version
42
49
  version: '3.1'
43
- prerelease: false
44
- type: :runtime
45
- name: activesupport
50
+ - - "<"
51
+ - !ruby/object:Gem::Version
52
+ version: '4.2'
46
53
  - !ruby/object:Gem::Dependency
54
+ name: rspec
47
55
  requirement: !ruby/object:Gem::Requirement
48
- none: false
49
56
  requirements:
50
- - - ! '>='
57
+ - - "~>"
51
58
  - !ruby/object:Gem::Version
52
- version: '0'
59
+ version: '3.0'
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: 3.0.0
63
+ type: :development
64
+ prerelease: false
53
65
  version_requirements: !ruby/object:Gem::Requirement
54
- none: false
55
66
  requirements:
56
- - - ! '>='
67
+ - - "~>"
57
68
  - !ruby/object:Gem::Version
58
- version: '0'
59
- prerelease: false
60
- type: :development
61
- name: rspec
62
- description: ! ' ActiveCleaner is a set of helpers that helps you in cleaning user-typed
63
- content in your ActiveModel depending models (ActiveRecord, Mongoid...)
64
-
65
- '
69
+ version: '3.0'
70
+ - - ">="
71
+ - !ruby/object:Gem::Version
72
+ version: 3.0.0
73
+ description: |2
74
+ ActiveCleaner is a set of helpers that helps you in cleaning user-typed content in your ActiveModel depending models (ActiveRecord, Mongoid...)
66
75
  email:
67
76
  - maxime.garcia@free.fr
68
77
  executables: []
69
78
  extensions: []
70
79
  extra_rdoc_files: []
71
80
  files:
72
- - README.md
73
81
  - LICENSE
82
+ - README.md
74
83
  - lib/active_cleaner.rb
75
- - lib/active_cleaner/markdown_cleaner.rb
76
- - lib/active_cleaner/version.rb
77
84
  - lib/active_cleaner/base_cleaner.rb
78
85
  - lib/active_cleaner/helper_methods.rb
86
+ - lib/active_cleaner/markdown_cleaner.rb
79
87
  - lib/active_cleaner/string_cleaner.rb
80
88
  - lib/active_cleaner/text_cleaner.rb
89
+ - lib/active_cleaner/version.rb
81
90
  - lib/activecleaner.rb
91
+ - spec/cases/inherit_spec.rb
92
+ - spec/cases/nilify_spec.rb
93
+ - spec/cases/simple_spec.rb
94
+ - spec/lib/active_cleaner/markdown_cleaner_spec.rb
82
95
  - spec/lib/active_cleaner/string_cleaner_spec.rb
83
96
  - spec/lib/active_cleaner/text_cleaner_spec.rb
84
- - spec/lib/active_cleaner/markdown_cleaner_spec.rb
85
97
  - spec/lib/active_cleaner_spec.rb
86
98
  - spec/spec_helper.rb
87
- - spec/cases/inherit_spec.rb
88
- - spec/cases/simple_spec.rb
89
- - spec/cases/nilify_spec.rb
90
99
  homepage: http://github.com/maximeg/activecleaner
91
- licenses: []
100
+ licenses:
101
+ - MIT
102
+ metadata: {}
92
103
  post_install_message:
93
104
  rdoc_options: []
94
105
  require_paths:
95
106
  - lib
96
107
  required_ruby_version: !ruby/object:Gem::Requirement
97
- none: false
98
108
  requirements:
99
- - - ! '>='
109
+ - - ">="
100
110
  - !ruby/object:Gem::Version
101
- version: '0'
111
+ version: '1.9'
102
112
  required_rubygems_version: !ruby/object:Gem::Requirement
103
- none: false
104
113
  requirements:
105
- - - ! '>='
114
+ - - ">="
106
115
  - !ruby/object:Gem::Version
107
- version: '0'
116
+ version: 1.3.6
108
117
  requirements: []
109
118
  rubyforge_project:
110
- rubygems_version: 1.8.25
119
+ rubygems_version: 2.4.1
111
120
  signing_key:
112
- specification_version: 3
121
+ specification_version: 4
113
122
  summary: Clean the fields in your models
114
123
  test_files:
115
124
  - spec/lib/active_cleaner/string_cleaner_spec.rb