HtmlCodeCleaner 0.0.1 → 0.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/HtmlCodeCleaner.rb +31 -4
- data/test/test_hcc.rb +3 -3
- metadata +5 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dabb9906289938ac0a08ff460fd8ed60eb7d6737
|
4
|
+
data.tar.gz: fd8484eb4bfac09ca85bcfe7d24981f652e3f33f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 041f0dcaea6bbbeba1aeea3206c26da7b387767d320b1e4afc3b26347586d48fc7e897d7cd75dd9d076d0f0e15b2b652bf9d48989d813c11b04b6d7b9c35f1bf
|
7
|
+
data.tar.gz: 4e4bf9d219b8e3ffca8b985bf7a61211c0ccb91cb227ac2a975723cc06003eebcf155403c3e0370d9ff7f448192b17dd915d0318bfd3c00898044aab917f6ec4
|
data/lib/HtmlCodeCleaner.rb
CHANGED
@@ -1,10 +1,15 @@
|
|
1
|
-
|
1
|
+
# HtmlCodeCleaner
|
2
|
+
#
|
3
|
+
# This class has a single dictionary of html code and its corresponding symbol.
|
4
|
+
# The code takes a string as input, and removes any html code and inserts the corresponding symbol.
|
5
|
+
# The output is a string.
|
6
|
+
#
|
2
7
|
class HtmlCodeCleaner
|
3
|
-
|
4
8
|
# removes character codes from string
|
5
9
|
# must be defined in the dictionary
|
6
10
|
def self.clean_string(string)
|
7
11
|
if (string != nil)
|
12
|
+
# This is the dictionary containing the html code and it's replacement symbol.
|
8
13
|
dict = [ ['!',"!"],
|
9
14
|
['"','"'],
|
10
15
|
['#','#'],
|
@@ -200,10 +205,32 @@ class HtmlCodeCleaner
|
|
200
205
|
['ü',"ü"],
|
201
206
|
['ý',"ý"],
|
202
207
|
['þ',"þ"],
|
203
|
-
['ÿ',"ÿ"]
|
208
|
+
['ÿ',"ÿ"],
|
209
|
+
['Œ',"Œ"],
|
210
|
+
['œ',"œ"],
|
211
|
+
['Š',"Š"],
|
212
|
+
['š',"š"],
|
213
|
+
['Ÿ',"Ÿ"],
|
214
|
+
['ƒ',"ƒ"],
|
215
|
+
['–',"–"],
|
216
|
+
['—',"—"],
|
217
|
+
['‘',"‘"],
|
218
|
+
['’',"’"],
|
219
|
+
['‚',"‚"],
|
220
|
+
['“',"“"],
|
221
|
+
['”',"”"],
|
222
|
+
['„',"„"],
|
223
|
+
['†',"†"],
|
224
|
+
['‡',"‡"],
|
225
|
+
['•',"•"],
|
226
|
+
['…',"…"],
|
227
|
+
['‰',"‰"],
|
228
|
+
['€',"€"],
|
229
|
+
['™',"™"] ]
|
230
|
+
# Parse the string of the html code and make the replacement
|
204
231
|
dict.each { |x| string = string.gsub(x.first, x.last) }
|
232
|
+
# return the string
|
205
233
|
string
|
206
234
|
end
|
207
235
|
end
|
208
|
-
|
209
236
|
end
|
data/test/test_hcc.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
require 'test/unit'
|
2
|
-
require 'HtmlCodeCleaner'
|
3
1
|
require 'minitest/autorun'
|
2
|
+
require 'HtmlCodeCleaner'
|
3
|
+
|
4
4
|
|
5
|
-
class HtmlCodeCleanerTest < Test
|
5
|
+
class HtmlCodeCleanerTest < Minitest::Test
|
6
6
|
def test_1
|
7
7
|
assert_equal "X", HtmlCodeCleaner.clean_string("X")
|
8
8
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: HtmlCodeCleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Michael Hiland
|
@@ -10,7 +10,8 @@ bindir: bin
|
|
10
10
|
cert_chain: []
|
11
11
|
date: 2014-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
|
-
description: Parse a string of html
|
13
|
+
description: Parse a string of the html number, replace code with the corresponding
|
14
|
+
symbol
|
14
15
|
email: g2c9@ugrad.cs.ubc.ca
|
15
16
|
executables: []
|
16
17
|
extensions: []
|
@@ -19,7 +20,7 @@ files:
|
|
19
20
|
- Rakefile
|
20
21
|
- lib/HtmlCodeCleaner.rb
|
21
22
|
- test/test_hcc.rb
|
22
|
-
homepage:
|
23
|
+
homepage: https://github.com/mhiland/HtmlCodeCleaner
|
23
24
|
licenses:
|
24
25
|
- GPL-3.0
|
25
26
|
metadata: {}
|
@@ -45,3 +46,4 @@ specification_version: 3
|
|
45
46
|
summary: Replace Html code with symbol
|
46
47
|
test_files:
|
47
48
|
- test/test_hcc.rb
|
49
|
+
has_rdoc:
|