paranoid_starlight 1.3.0 → 1.4.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -122,15 +122,16 @@ module ParanoidStarlight
122
122
  end
123
123
  end
124
124
 
125
- def clean_text(inattr, outattr = '')
125
+ def clean_string(inattr, outattr = '')
126
126
  basic_converter(self, inattr, outattr) do |text|
127
- text.to_s.strip.gsub(/\s{2,}/, ' ')
127
+ text.to_s.strip.gsub(/\n/, ' ').gsub(/\s+/, ' ')
128
128
  end
129
129
  end
130
130
 
131
- def clean_whitespaces(inattr, outattr = '')
131
+ def remove_whitespaces(inattr, outattr = '')
132
132
  basic_converter(self, inattr, outattr) do |text|
133
- text.to_s.gsub(/\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
 
@@ -1,3 +1,3 @@
1
1
  module ParanoidStarlight
2
- VERSION = "1.3.0"
2
+ VERSION = "1.4.0"
3
3
  end
@@ -132,13 +132,26 @@ describe ParanoidStarlight::Converters do
132
132
  end
133
133
  end
134
134
 
135
- describe 'clean_text (for attributes)' do
136
- before { @test = Fangirl.new; @test.text = " Some \ttext. \t" }
137
- it 'should clean text of unneccessary characters' do
138
- @test.clean_text(:text)
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.3.0
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-18 00:00:00.000000000 Z
12
+ date: 2012-12-23 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel