code_terminator 0.4.6 → 0.4.7

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d023b54f3d9e4807758e10c9d8c9c1ad512d1feb
4
- data.tar.gz: 81cc874ddd8da35b5ca80ac60cb6c8ad811ef544
3
+ metadata.gz: 6cde8d8d5a13de445c2bb97a0f5c530ab3213eaf
4
+ data.tar.gz: 5e943a9a25b0b3df4b4d7b35797b9667849178d8
5
5
  SHA512:
6
- metadata.gz: c75b3ff7b196f630bd6fa95f83bc1b7f480e4c34f932747c744a4729dd979003d9cecf49d05a306dc187b13f04f056420b70b529d0b3c7affda954e94440382a
7
- data.tar.gz: c94d216cd485c7f5f5e09e471aeb78f4c6f8a104c9bf2badb39f2bb04ac70b6185b6641783576d9ef3252984e1c4e96d15c56dff8b4727f8ac289f69352bc71c
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>
@@ -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
- reader.at('body').attribute_nodes.each do |element_attribute|
58
- node[:parent] = "html"
59
- node[:tag] = "body"
60
- node[:attribute] = element_attribute.name if !element_attribute.name.nil?
61
- node[:value] = element_attribute.value if !element_attribute.value.nil?
62
- @elements << node
63
- end
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
- reader.at('body').children.each do |child|
94
- if child.attribute_nodes.empty?
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[:attribute] = element_attribute.name if !element_attribute.name.nil?
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('html').children.each do |child|
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
 
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.4.6"
2
+ VERSION = "0.4.7"
3
3
  end
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.6
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-03 00:00:00.000000000 Z
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