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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 36841a7175d4921d5897f6b8d6564c30c3faf304
4
- data.tar.gz: c1dd23d69fb8f0a0b854d994c66b8a211b96602a
3
+ metadata.gz: 8d82edb81884a6b638e866c4e0d76ad85fca7d63
4
+ data.tar.gz: bed0a57860cb02b6e4335a9be299858f8a870f0d
5
5
  SHA512:
6
- metadata.gz: 8d6731a9d11dfedbf61575bd88a4c21b407d43f07ad56d3be4b8d5f9f1f539a332a3b724844821cb710e3592a3cc406572d0845271e3b0b3ea8453dbb0dbb45a
7
- data.tar.gz: c756dba97ae07804dccd80af20aa3055402985d974f64304dbba8ed6ff5ea7382f49a02b149b1a1d6b02c8d39f8f2288f13bc5beb3460af90f1cc48ebc50ee4d
6
+ metadata.gz: 29ccbd2cd7d53dd0838a62848ba2372b100e4a125b27e4f1487c908a13a1b75d2ebf2fe364ce478b3bc1a71b96d460924a106fb3cd9f681bee00431bba3c36a4
7
+ data.tar.gz: ef8fefbc5477d093d10faa05963af43b61346a67ecfacc27d2ecbf3cb860454031c569a34ff0043b90468c14515129ba340ff3de2351ae600db62da6ae1ceb60
@@ -289,7 +289,7 @@ class CodeTerminator::Html
289
289
 
290
290
  elements.each do |e|
291
291
 
292
- p item = e[:tag]
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
- # p "node child " + node_child.class.to_s
307
- # p "item " + item
305
+ code.css(e[:parent]).children.each do |node_child|
308
306
 
309
- if item == "comment" && node_child.class == Nokogiri::XML::Comment
310
- comment_found = true
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 != Nokogiri::XML::Element
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
- if item == "comment"
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
- if item == "comment"
341
- html_errors << new_error(element: e, type: 404, description: "Remember to add the `<#{e[:tag]}>` tag")
342
- end
343
- if code.css(e[:parent]).text.strip != e[:content].strip
344
- # p "text of node: " + code.css(e[:parent]).text
345
- if item == "comment"
346
- error330 = new_error(element: e, type: 330, description: "The text inside the comment should be #{e[:content]}")
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
- error330 = new_error(element: e, type: 330, description: "The text inside `<#{e[:parent]}>` should be #{e[:content]}")
337
+ text_found = true
349
338
  end
350
- else
351
- text_found = true
352
- end
339
+
353
340
  end
354
341
  #end if parent has children
355
- # if !comment_found
356
- # html_errors << new_error(element: e, type: 404, description: "Remember to add the `comment` tag")
357
- # end
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
- #if code_css.at_css(e[:tag]).parent.name == e[:parent]
369
- p "text content: " + code_css.text
370
- if code_css.text == e[:content]
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
 
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.4.17"
2
+ VERSION = "0.5.0"
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.17
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-05 00:00:00.000000000 Z
11
+ date: 2017-01-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler