code_terminator 0.4.17 → 0.5.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/code_terminator/html.rb +32 -46
- data/lib/code_terminator/version.rb +1 -1
- 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: 8d82edb81884a6b638e866c4e0d76ad85fca7d63
|
4
|
+
data.tar.gz: bed0a57860cb02b6e4335a9be299858f8a870f0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 29ccbd2cd7d53dd0838a62848ba2372b100e4a125b27e4f1487c908a13a1b75d2ebf2fe364ce478b3bc1a71b96d460924a106fb3cd9f681bee00431bba3c36a4
|
7
|
+
data.tar.gz: ef8fefbc5477d093d10faa05963af43b61346a67ecfacc27d2ecbf3cb860454031c569a34ff0043b90468c14515129ba340ff3de2351ae600db62da6ae1ceb60
|
data/lib/code_terminator/html.rb
CHANGED
@@ -289,7 +289,7 @@ class CodeTerminator::Html
|
|
289
289
|
|
290
290
|
elements.each do |e|
|
291
291
|
|
292
|
-
|
292
|
+
item = e[:tag]
|
293
293
|
|
294
294
|
if item == "text" or item == "comment"
|
295
295
|
|
@@ -298,63 +298,53 @@ class CodeTerminator::Html
|
|
298
298
|
if code.css(e[:parent]).count < 2
|
299
299
|
if code.css(e[:parent]).class == Nokogiri::XML::NodeSet
|
300
300
|
text_found = false
|
301
|
-
comment_found = false if item == "comment"
|
301
|
+
@comment_found = false if item == "comment"
|
302
302
|
error330 = nil
|
303
303
|
if code.css(e[:parent]).children.any?
|
304
|
-
code.css(e[:parent]).children.each do |node_child|
|
305
304
|
|
306
|
-
|
307
|
-
# p "item " + item
|
305
|
+
code.css(e[:parent]).children.each do |node_child|
|
308
306
|
|
309
|
-
|
310
|
-
|
307
|
+
if node_child.class == Nokogiri::XML::Comment
|
308
|
+
if e[:content].strip != ""
|
309
|
+
if node_child.text.strip! != e[:content].strip!
|
310
|
+
error330 = new_error(element: e, type: 330, description: "The text inside the comment should be #{e[:content]}")
|
311
|
+
end
|
311
312
|
end
|
313
|
+
@comment_found = true
|
314
|
+
end
|
312
315
|
|
313
|
-
if node_child.class
|
314
|
-
#embebed code
|
315
|
-
#if code.css(e[:parent]).text != e[:content]
|
316
|
-
|
316
|
+
if node_child.class == Nokogiri::XML::Text
|
317
317
|
if node_child.text.strip != e[:content].strip
|
318
|
-
|
319
|
-
# if comment isn't present in the code, mark add tag
|
320
|
-
if e[:content].strip != ""
|
321
|
-
error330 = new_error(element: e, type: 330, description: "The text inside the comment should be #{e[:content]}")
|
322
|
-
end
|
323
|
-
else
|
324
|
-
error330 = new_error(element: e, type: 330, description: "The text inside `<#{e[:parent]}>` should be #{e[:content]}")
|
325
|
-
end
|
318
|
+
error330 = new_error(element: e, type: 330, description: "The text inside `<#{e[:parent]}>` should be #{e[:content]}")
|
326
319
|
else
|
327
320
|
text_found = true
|
328
321
|
end
|
329
|
-
#end embebed code
|
330
322
|
end
|
331
|
-
end
|
332
323
|
|
333
|
-
if !(defined? comment_found).nil?
|
334
|
-
if !comment_found
|
335
|
-
html_errors << new_error(element: e, type: 404, description: "Remember to add the `<#{e[:tag]}>` tag")
|
336
|
-
end
|
337
324
|
end
|
338
325
|
#end each
|
339
326
|
else
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
344
|
-
|
345
|
-
|
346
|
-
|
327
|
+
|
328
|
+
if code.css(e[:parent]).text.strip != e[:content].strip
|
329
|
+
#validate if comment exist and has the expected content
|
330
|
+
if item == "comment"
|
331
|
+
error330 = new_error(element: e, type: 330, description: "The text inside the comment should be #{e[:content]}")
|
332
|
+
@comment_found = true
|
333
|
+
else
|
334
|
+
error330 = new_error(element: e, type: 330, description: "The text inside `<#{e[:parent]}>` should be #{e[:content]}")
|
335
|
+
end
|
347
336
|
else
|
348
|
-
|
337
|
+
text_found = true
|
349
338
|
end
|
350
|
-
|
351
|
-
text_found = true
|
352
|
-
end
|
339
|
+
|
353
340
|
end
|
354
341
|
#end if parent has children
|
355
|
-
|
356
|
-
#
|
357
|
-
|
342
|
+
|
343
|
+
#if comment not found, throw error
|
344
|
+
if !(defined? @comment_found).nil?
|
345
|
+
html_errors << new_error(element: e, type: 404, description: "Remember to add the `<#{e[:tag]}>` tag") if !@comment_found
|
346
|
+
remove_instance_variable(:@comment_found)
|
347
|
+
end
|
358
348
|
|
359
349
|
if !text_found && !error330.nil?
|
360
350
|
html_errors << error330
|
@@ -365,19 +355,15 @@ class CodeTerminator::Html
|
|
365
355
|
else
|
366
356
|
exist = false
|
367
357
|
code.css(e[:parent]).each do |code_css|
|
368
|
-
|
369
|
-
|
370
|
-
|
371
|
-
exist = true
|
372
|
-
end
|
373
|
-
#end
|
358
|
+
if code_css.text == e[:content]
|
359
|
+
exist = true
|
360
|
+
end
|
374
361
|
end
|
375
362
|
if !exist
|
376
363
|
html_errors << new_error(element: e, type: 330, description: "The text inside `<#{e[:parent]}>` should be #{e[:content]}")
|
377
364
|
end
|
378
365
|
end
|
379
366
|
#end if parent < 2
|
380
|
-
|
381
367
|
end
|
382
368
|
#end if content is null
|
383
369
|
|
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
|
+
version: 0.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Evelin Ponce
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-01-
|
11
|
+
date: 2017-01-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|