code_terminator 0.4.2 → 0.4.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7177362c6cee8109e2f869b99ca5a0c07d2954c9
4
- data.tar.gz: d1c124bc905bebaabd772771247187501158441c
3
+ metadata.gz: 963990e195930cd44a896fe71259a0e839e33467
4
+ data.tar.gz: 8a7ac60305f230aad3ce55545d666c0e1ea96b3e
5
5
  SHA512:
6
- metadata.gz: f975b0bde83f64db37059515dff9c6cf535c5084f9730774089e48f30ec719bfb6a2c5de05a9fe6634a1712c0ae3a5fe7a332298308cbd45353b883a0fd161f9
7
- data.tar.gz: 9b386ed846e6b325349870db1f14c63a39b3e8a108e622c748df0a3d0a6a094c0ddb5b308ec3546968d01d544bb52402e0ae337b16ca24dad053ba23b70b750d
6
+ metadata.gz: 5da555f989ed1d5988ab5588dbbaff5fd3c4e9f1e19b8df4039b8917b7eb55b2c2dd7f032e66d20089b7e14744697d44d23c904eb4de9d43569c0d85c3733106
7
+ data.tar.gz: cdd89add04958a303c88ca80663f839326d0833d5da038049c49abeec12b8e20b92e13c2ebe7464ccb92b1f0acac23944202becaabf1b9e995c2cf6524b2048a
data/exercises/new.html CHANGED
@@ -1 +1,6 @@
1
- <h1>hola evelin</h1>
1
+ <head>
2
+ <script type="text/javascript">var hola = "hello";</script>
3
+ </head>
4
+ <body>
5
+ <h1>hola evelin</h1>
6
+ </body>
data/exercises/test.css CHANGED
@@ -1,2 +1,2 @@
1
1
  body {
2
- background-color: yellow; }
2
+ background-color: lightblue; }
data/exercises/test.html CHANGED
@@ -1 +1 @@
1
- <body><h2>hola test</h2><div><h2>html</h2></div><div><h2>css</h2></div></body>
1
+ <body><h2>hola test</h2><p></p></body>
@@ -61,6 +61,33 @@ class CodeTerminator::Html
61
61
  node[:value] = element_attribute.value if !element_attribute.value.nil?
62
62
  @elements << node
63
63
  end
64
+
65
+ reader.at('head').children.each do |child|
66
+ if child.attribute_nodes.empty?
67
+ node = Hash.new
68
+ node[:parent] = "head"
69
+ node[:tag] = child.name
70
+ node[:content] = child.text if !child.text.nil?
71
+ @elements << node
72
+ else
73
+ child.attribute_nodes.each do |element_attribute|
74
+ node = Hash.new
75
+ node[:parent] = "head"
76
+ if child.name == "#cdata-section"
77
+ node[:tag] = "text"
78
+ else
79
+ node[:tag] = child.name
80
+ end
81
+ # node[:tag] = ( ? "text", child.name)
82
+ node[:content] = child.text if !child.text.nil?
83
+ node[:attribute] = element_attribute.name if !element_attribute.name.nil?
84
+ node[:value] = element_attribute.value if !element_attribute.value.nil?
85
+ @elements << node
86
+ end
87
+ end
88
+ add_children(child) if child.children.any?
89
+ end
90
+
64
91
  reader.at('body').children.each do |child|
65
92
  if child.attribute_nodes.empty?
66
93
  node = Hash.new
@@ -78,7 +105,6 @@ class CodeTerminator::Html
78
105
  @elements << node
79
106
  end
80
107
  end
81
-
82
108
  add_children(child) if child.children.any?
83
109
  end
84
110
  @elements
@@ -302,14 +328,24 @@ class CodeTerminator::Html
302
328
  if child.attribute_nodes.empty?
303
329
  node = Hash.new
304
330
  node[:parent] = parent.name
305
- node[:tag] = child.name
306
- node[:content] = child.text if child.text?
331
+ # node[:tag] = child.name
332
+ if child.name == "#cdata-section"
333
+ node[:tag] = "text"
334
+ else
335
+ node[:tag] = child.name
336
+ end
337
+ node[:content] = child.text if !child.text.nil?
307
338
  @elements << node
308
339
  else
309
340
  child.attribute_nodes.each do |element_attribute|
310
341
  node = Hash.new
311
342
  node[:parent] = parent.name
312
- node[:tag] = child.name
343
+ # node[:tag] = child.name
344
+ if element_attribute.name == "#cdata-section"
345
+ node[:tag] = "text"
346
+ else
347
+ node[:tag] = element_attribute.name
348
+ end
313
349
  node[:attribute] = element_attribute.name if !element_attribute.name.nil?
314
350
  node[:value] = element_attribute.value if !element_attribute.value.nil?
315
351
  @elements << node
@@ -320,8 +356,8 @@ class CodeTerminator::Html
320
356
  end
321
357
 
322
358
  def remove_empty_text (reader)
323
- reader.at("body").children.each do |child|
324
- if child.text?
359
+ reader.at('html').children.each do |child|
360
+ if !child.text.nil?
325
361
  child.remove if child.content.to_s.squish.empty?
326
362
  end
327
363
  check_children(child) if child.children.any?
@@ -331,7 +367,7 @@ class CodeTerminator::Html
331
367
 
332
368
  def check_children(parent)
333
369
  parent.children.each do |child|
334
- if child.text?
370
+ if !child.text.nil?
335
371
  child.remove if child.content.to_s.squish.empty?
336
372
  end
337
373
  check_children(child) if child.children.any?
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.4.2"
2
+ VERSION = "0.4.3"
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.2
4
+ version: 0.4.3
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-09-20 00:00:00.000000000 Z
11
+ date: 2016-09-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler