code_terminator 0.4.6 → 0.4.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/exercises/issue12.html +1 -0
- data/lib/code_terminator/html.rb +36 -23
- data/lib/code_terminator/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6cde8d8d5a13de445c2bb97a0f5c530ab3213eaf
|
4
|
+
data.tar.gz: 5e943a9a25b0b3df4b4d7b35797b9667849178d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 768a6094ce3b967205a3f34004126bb796cd444e6def5f25d6d492c7c0fc10a0b6ce41bf5a128dac1b39a2235a117e96a795830f7a755bdcfe19337fc4d50872
|
7
|
+
data.tar.gz: 3b8795c1de1e23842660dc77b66a3ec443d7912da101a76a1e041ac8cb33da6ee028faa8a44e2d7200e6cd6a6846950e9725153387559c7a7bd925b7e99ccf38
|
@@ -0,0 +1 @@
|
|
1
|
+
<footer><a href='#'>index</a><p>Please contact: </p><a href='mailto:joe@email.com'>joe@email.com</a></footer>
|
data/lib/code_terminator/html.rb
CHANGED
@@ -54,13 +54,15 @@ class CodeTerminator::Html
|
|
54
54
|
reader = Nokogiri::HTML(File.open(source))
|
55
55
|
end
|
56
56
|
reader = remove_empty_text(reader)
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
57
|
+
if !reader.at('body').nil?
|
58
|
+
reader.at('body').attribute_nodes.each do |element_attribute|
|
59
|
+
node[:parent] = "html"
|
60
|
+
node[:tag] = "body"
|
61
|
+
node[:attribute] = element_attribute.name if !element_attribute.name.nil?
|
62
|
+
node[:value] = element_attribute.value if !element_attribute.value.nil?
|
63
|
+
@elements << node
|
64
|
+
end
|
65
|
+
end
|
64
66
|
|
65
67
|
if !reader.at('head').nil?
|
66
68
|
reader.at('head').children.each do |child|
|
@@ -89,25 +91,26 @@ class CodeTerminator::Html
|
|
89
91
|
add_children(child) if child.children.any?
|
90
92
|
end
|
91
93
|
end
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
node = Hash.new
|
96
|
-
node[:parent] = "body"
|
97
|
-
node[:tag] = child.name
|
98
|
-
node[:content] = child.text if child.text?
|
99
|
-
@elements << node
|
100
|
-
else
|
101
|
-
child.attribute_nodes.each do |element_attribute|
|
94
|
+
if !reader.at('body').nil?
|
95
|
+
reader.at('body').children.each do |child|
|
96
|
+
if child.attribute_nodes.empty?
|
102
97
|
node = Hash.new
|
103
98
|
node[:parent] = "body"
|
104
99
|
node[:tag] = child.name
|
105
|
-
node[:
|
106
|
-
node[:value] = element_attribute.value if !element_attribute.value.nil?
|
100
|
+
node[:content] = child.text if child.text?
|
107
101
|
@elements << node
|
102
|
+
else
|
103
|
+
child.attribute_nodes.each do |element_attribute|
|
104
|
+
node = Hash.new
|
105
|
+
node[:parent] = "body"
|
106
|
+
node[:tag] = child.name
|
107
|
+
node[:attribute] = element_attribute.name if !element_attribute.name.nil?
|
108
|
+
node[:value] = element_attribute.value if !element_attribute.value.nil?
|
109
|
+
@elements << node
|
110
|
+
end
|
108
111
|
end
|
112
|
+
add_children(child) if child.children.any?
|
109
113
|
end
|
110
|
-
add_children(child) if child.children.any?
|
111
114
|
end
|
112
115
|
@elements
|
113
116
|
end
|
@@ -256,7 +259,7 @@ class CodeTerminator::Html
|
|
256
259
|
exist_in_body = Array.new
|
257
260
|
|
258
261
|
error333 = nil
|
259
|
-
|
262
|
+
|
260
263
|
elements.each do |e|
|
261
264
|
|
262
265
|
item = e[:tag]
|
@@ -382,12 +385,22 @@ class CodeTerminator::Html
|
|
382
385
|
end
|
383
386
|
|
384
387
|
def remove_empty_text (reader)
|
385
|
-
reader.at('
|
388
|
+
if !reader.at('head').nil?
|
389
|
+
reader.at('head').children.each do |child|
|
386
390
|
if !child.text.nil?
|
387
|
-
child.remove if child.content.to_s.squish.empty?
|
391
|
+
child.remove if child.content.to_s.squish.empty? && child.class == Nokogiri::XML::Text
|
388
392
|
end
|
389
393
|
check_children(child) if child.children.any?
|
390
394
|
end
|
395
|
+
end
|
396
|
+
if !reader.at('body').nil?
|
397
|
+
reader.at('body').children.each do |child|
|
398
|
+
if !child.text.nil?
|
399
|
+
child.remove if child.content.to_s.squish.empty? && child.class == Nokogiri::XML::Text
|
400
|
+
end
|
401
|
+
check_children(child) if child.children.any?
|
402
|
+
end
|
403
|
+
end
|
391
404
|
reader
|
392
405
|
end
|
393
406
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: code_terminator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evelin Ponce
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-10-
|
11
|
+
date: 2016-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- bin/setup
|
157
157
|
- code_terminator.gemspec
|
158
158
|
- exe/code_terminator
|
159
|
+
- exercises/issue12.html
|
159
160
|
- exercises/new.html
|
160
161
|
- exercises/new2.html
|
161
162
|
- exercises/test.css
|