pretty_strings 0.5.0 → 0.6.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.
- checksums.yaml +4 -4
- data/lib/pretty_strings/version.rb +1 -1
- data/lib/pretty_strings.rb +20 -1
- data/spec/pretty_strings_spec.rb +50 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 14488ecfa37d13ce82863cd7c4b35eec305eca56
|
4
|
+
data.tar.gz: 86c5455874af4250a880b0388ee6a3da4d47e6e3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1325f4405b55cab911d8808ba3d0a08521e61eecb6ef38bd1e64ad615632299974ddb3a541294a081602f75817af5aa7bc45fea0fd73bc09d3e11e20536b2a21
|
7
|
+
data.tar.gz: a71fbc3bea6a24eef7e8bbdcb4274f4af9f361f464421f654b6c5753dab57c2f8e23dbc03f3b375e291eddb2a4c58c542364a53a819302fa7d908c033b9efd13
|
data/lib/pretty_strings.rb
CHANGED
@@ -15,6 +15,7 @@ module PrettyStrings
|
|
15
15
|
remove_newlines(
|
16
16
|
replace_tabs(
|
17
17
|
remove_bracketed_code(
|
18
|
+
remove_twb_tags(
|
18
19
|
scan_for_code(
|
19
20
|
escape_text(
|
20
21
|
sanitize_text(
|
@@ -23,7 +24,7 @@ module PrettyStrings
|
|
23
24
|
sanitize_text(
|
24
25
|
replace_bracket_with_symbol(
|
25
26
|
text
|
26
|
-
))))))))))))).squeeze(" ").strip
|
27
|
+
)))))))))))))).squeeze(" ").strip
|
27
28
|
end
|
28
29
|
|
29
30
|
private
|
@@ -51,6 +52,24 @@ module PrettyStrings
|
|
51
52
|
text.gsub!(/⚘/, '{') || text
|
52
53
|
end
|
53
54
|
|
55
|
+
def remove_twb_tags(text)
|
56
|
+
remove_twb_tags_post(
|
57
|
+
remove_twb_tags_post(
|
58
|
+
remove_twb_tags_post(
|
59
|
+
remove_twb_tags_post(
|
60
|
+
remove_twb_tags_pre(text)))))
|
61
|
+
end
|
62
|
+
|
63
|
+
def remove_twb_tags_post(text)
|
64
|
+
text.gsub!(/({\\\S+ )([^{}}]*)(})/, '\2') || text
|
65
|
+
text.gsub!('\sectd\\linex0\\headery708\\footery708\\colsx708\\endnhere\\sectlinegrid360\\sectdefaultcl\\sftnbj ', '') || text
|
66
|
+
end
|
67
|
+
|
68
|
+
def remove_twb_tags_pre(text)
|
69
|
+
text.gsub!(/\{\\super \d+}/, '') || text
|
70
|
+
text.gsub!(/\{\\\*\\fldinst [^{}]*}/, '') || text
|
71
|
+
end
|
72
|
+
|
54
73
|
def remove_consecutive_dots(text)
|
55
74
|
text.gsub!(/\.{5,}/, '') || text
|
56
75
|
end
|
data/spec/pretty_strings_spec.rb
CHANGED
@@ -149,4 +149,54 @@ describe PrettyStrings do
|
|
149
149
|
text = "hello <h1>This is HTML</h1>."
|
150
150
|
expect(PrettyStrings::Cleaner.new(text).pretty).to eq("hello This is HTML.")
|
151
151
|
end
|
152
|
+
|
153
|
+
it "prettifies example #030" do
|
154
|
+
text = 'Para obtener noticias actualizadas, visite nuestro {\field {\*\fldinst HYPERLINK "http://example.com/default.aspx?clientid=-1"}{\cs37\ul\cf2 {\fldrslt newsroom}}}\sectd\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sftnbj o suscríbase a nuestro {\field {\*\fldinst HYPERLINK "http://example.com/content/newsfeeds.aspx" \\t "_blank"}{\cs37\ul\cf2 {\fldrslt news feed}}}\sectd\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sftnbj .'
|
155
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq("Para obtener noticias actualizadas, visite nuestro newsroom o suscríbase a nuestro news feed.")
|
156
|
+
end
|
157
|
+
|
158
|
+
it "prettifies example #031" do
|
159
|
+
text = 'For ongoing news, please visit our {\field {\*\fldinst HYPERLINK "http://example.com/default.aspx?clientid=-1"}{\cs37\ul\cf2 {\fldrslt newsroom}}}\sectd\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sftnbj or subscribe to our {\field {\*\fldinst HYPERLINK "http://example.com/content/newsfeeds.aspx" \\t "_blank"}{\cs37\ul\cf2 {\fldrslt news feed}}}\sectd\linex0\headery708\footery708\colsx708\endnhere\sectlinegrid360\sectdefaultcl\sftnbj .'
|
160
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq("For ongoing news, please visit our newsroom or subscribe to our news feed.")
|
161
|
+
end
|
162
|
+
|
163
|
+
it "prettifies example #032" do
|
164
|
+
text = 'Tenemos el agrado de dirigirnos a ustedes a fin de formularles una oferta para la utilización de Pallets (según se define en el punto 1.1 (xi) {\i infra), }vinculados al negocio de las gaseosas, sujeta a las siguientes cláusulas y condiciones (la "{\ul Oferta}").'
|
165
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('Tenemos el agrado de dirigirnos a ustedes a fin de formularles una oferta para la utilización de Pallets (según se define en el punto 1.1 (xi) infra), vinculados al negocio de las gaseosas, sujeta a las siguientes cláusulas y condiciones (la "Oferta").')
|
166
|
+
end
|
167
|
+
|
168
|
+
it "prettifies example #033" do
|
169
|
+
text = '"{\ul Alquiler}": {\expndtw-1 es la suma en pesos básica diaria que el Participante debe abonar a CHEP }durante ei tiempo que cada Pallet permanece en poder del Participante, según se detalla en el Anexo VIII.'
|
170
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('"Alquiler": es la suma en pesos básica diaria que el Participante debe abonar a CHEP durante ei tiempo que cada Pallet permanece en poder del Participante, según se detalla en el Anexo VIII.')
|
171
|
+
end
|
172
|
+
|
173
|
+
it "prettifies example #034" do
|
174
|
+
text = 'Pacific Islander, Asian, African, Hispanice, {\highlight7 Pacific islander} or Native American ancestry'
|
175
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('Pacific Islander, Asian, African, Hispanice, Pacific islander or Native American ancestry')
|
176
|
+
end
|
177
|
+
|
178
|
+
it "prettifies example #035" do
|
179
|
+
text = 'STIMULATORS OF INSULIN RELEASE (Insulin Secretagogues) \endash increase insulin secretion from the pancreas{\super 1}'
|
180
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('STIMULATORS OF INSULIN RELEASE (Insulin Secretagogues) \endash increase insulin secretion from the pancreas')
|
181
|
+
end
|
182
|
+
|
183
|
+
it "prettifies example #036" do
|
184
|
+
text = '{\f32 náuseas, jaqueca, hipoglucemia (cuando se usa con secretagogos de la insulina)} '
|
185
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('náuseas, jaqueca, hipoglucemia (cuando se usa con secretagogos de la insulina)')
|
186
|
+
end
|
187
|
+
|
188
|
+
it "prettifies example #037" do
|
189
|
+
text = '{\f32 goteo nasal, infección del tracto respiratorio superior, reacciones alérgicas severas raramente} {\f32 (inflamación de la lengua, garganta, rostro o cuerpo; sarpullido severo)\~}'
|
190
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('goteo nasal, infección del tracto respiratorio superior, reacciones alérgicas severas raramente (inflamación de la lengua, garganta, rostro o cuerpo; sarpullido severo)\~')
|
191
|
+
end
|
192
|
+
|
193
|
+
it "prettifies example #038" do
|
194
|
+
text = '{\field {\*\fldinst HYPERLINK "" \\l "RANGE!a1c" }{\cs10 {\fldrslt A1c*}}}'
|
195
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('A1c*')
|
196
|
+
end
|
197
|
+
|
198
|
+
it "prettifies example #039" do
|
199
|
+
text = 'The two most important pieces of information for the carbohydrate controlled diet is the {\cs11\b\cf17 serving size} and the grams of {\cs11\b\cf17 total carbohydrate}.'
|
200
|
+
expect(PrettyStrings::Cleaner.new(text).pretty).to eq('The two most important pieces of information for the carbohydrate controlled diet is the serving size and the grams of total carbohydrate.')
|
201
|
+
end
|
152
202
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pretty_strings
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kevin S. Dias
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-03-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|