paranoid_starlight 1.3.0 → 1.4.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.
data/lib/paranoid_starlight.rb
CHANGED
@@ -122,15 +122,16 @@ module ParanoidStarlight
|
|
122
122
|
end
|
123
123
|
end
|
124
124
|
|
125
|
-
def
|
125
|
+
def clean_string(inattr, outattr = '')
|
126
126
|
basic_converter(self, inattr, outattr) do |text|
|
127
|
-
text.to_s.strip.gsub(/\
|
127
|
+
text.to_s.strip.gsub(/\n/, ' ').gsub(/\s+/, ' ')
|
128
128
|
end
|
129
129
|
end
|
130
130
|
|
131
|
-
def
|
131
|
+
def remove_whitespaces(inattr, outattr = '')
|
132
132
|
basic_converter(self, inattr, outattr) do |text|
|
133
|
-
text.to_s.
|
133
|
+
array = text.to_s.strip.split("\n")
|
134
|
+
array.map {|line| line.gsub(/\s/, '')}.join("\n")
|
134
135
|
end
|
135
136
|
end
|
136
137
|
|
@@ -132,13 +132,26 @@ describe ParanoidStarlight::Converters do
|
|
132
132
|
end
|
133
133
|
end
|
134
134
|
|
135
|
-
describe '
|
136
|
-
before { @test = Fangirl.new; @test.text = " Some \
|
137
|
-
it 'should
|
138
|
-
@test.
|
135
|
+
describe 'clean_string (for attributes)' do
|
136
|
+
before { @test = Fangirl.new; @test.text = " Some \t\ntext.\n \t" }
|
137
|
+
it 'should get words with spaces' do
|
138
|
+
@test.clean_string(:text)
|
139
139
|
@test.text.should == "Some text."
|
140
140
|
end
|
141
141
|
end
|
142
|
+
|
143
|
+
describe 'remove_whitespaces (for attributes)' do
|
144
|
+
before do
|
145
|
+
@test = Fangirl.new;
|
146
|
+
@test.text = " Some \ttext. \t\n\n\n Hello\t\tworld."
|
147
|
+
end
|
148
|
+
|
149
|
+
it 'should clean text of unwanted characters' do
|
150
|
+
@test.remove_whitespaces(:text)
|
151
|
+
@test.text.should == "Sometext.\n\n\nHelloworld."
|
152
|
+
end
|
153
|
+
end
|
154
|
+
|
142
155
|
end
|
143
156
|
|
144
157
|
describe 'ParanoidStarlight::Validations' do
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paranoid_starlight
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-12-
|
12
|
+
date: 2012-12-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|