code_terminator 0.5.3 → 0.5.4

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: c9d2e6004e00bb19874ce02e5fd2ac2d242e82b2
4
- data.tar.gz: 43b7d9f3728863794ec443d6d798d605f31e9071
3
+ metadata.gz: 233ef9c63180ce9c609c9d3443768dc21c248fc1
4
+ data.tar.gz: 5160c33790932470001b17ed022ffcc8444b9aff
5
5
  SHA512:
6
- metadata.gz: 12f8a6a19fdd3fb3eda53677b21520d44485ba140602258dd0e554e3f05b27985d7fca2e8bd9b633b032c623db71835332382a5d439687890e3b5c9878372ad2
7
- data.tar.gz: c0b1a919ea9f3c44aaf3333c047d68616234f9cae019ae36396c614c1ed5fe6c5cc05a297c87e03e9cff619471691f0b229e73702db56123ee95a260c29b0b7f
6
+ metadata.gz: de1ab5d12911a2b911f86d75bdf5c7591d4511d14924575a34b8a090b21aa9162cceb6c9a9ade5837b87e63f55bf202e4c84f77f3f6a200fb971a65dccbab292
7
+ data.tar.gz: 1fec0cee3909f8fdbc1c792f22781f38bd1fc397e35e536a9034b4bb0705110fe48de0ac1f0c8e621e8db29eeda42d8c485076869d612b7e31cdf59759ff5911
@@ -1,14 +1,18 @@
1
- <!DOCTYPE html>
2
1
  <html>
3
2
  <head>
4
3
  <title>My Favorite Book</title>
5
4
  </head>
6
5
  <body>
7
- <div id="title">
6
+ <div id='title'>
8
7
  <h1></h1>
9
8
  </div>
10
- <div class="about">
9
+ <div class='about'>
10
+ <p></p>
11
+ </div>
12
+ <div class='contact'>
11
13
  <p></p>
12
14
  </div>
13
15
  </body>
14
16
  </html>
17
+
18
+ <!-- #CHECK THIS ACTIVITY, ID DIVS HAVE ATTRIBUTE DONT WORK COUNTER -->
@@ -299,7 +299,7 @@ class CodeTerminator::Html
299
299
 
300
300
  error_elements = Array.new
301
301
 
302
- errors_count = Array.new
302
+ elements_count = Array.new
303
303
 
304
304
  error333 = nil
305
305
 
@@ -309,12 +309,13 @@ class CodeTerminator::Html
309
309
 
310
310
  elements.each do |e|
311
311
 
312
- if errors_count.select {|element| element[:parent_pointer].to_s == e[:parent_pointer].to_s && element[:tag].to_s == e[:tag]}.count < 1
312
+ if elements_count.select {|element| element[:parent_pointer].to_s == e[:parent_pointer].to_s && element[:tag].to_s == e[:tag]}.count < 1
313
313
  error_element = Hash.new
314
314
  error_element[:tag] = e[:tag]
315
+ error_element[:pointer] = e[:pointer]
315
316
  error_element[:parent_pointer] = e[:parent_pointer]
316
317
  error_element[:count] = 0
317
- errors_count << error_element
318
+ elements_count << error_element
318
319
  end
319
320
 
320
321
  item = e[:tag]
@@ -333,67 +334,78 @@ class CodeTerminator::Html
333
334
  end
334
335
  end
335
336
  #end if content is null
336
-
337
337
  else
338
338
  #item class is different to text or comment
339
339
 
340
- if code.css(e[:tag]).length > 0
341
-
342
- code.css(e[:tag]).each do |tag|
343
-
344
- e_check = css_code_checked.select {|element| element[:original_pointer].to_s == e[:pointer].to_s }
345
- # p "echeck " + e_check.to_s
346
- e_check2 = css_code_checked.select {|element| element[:pointer].to_s == tag.pointer_id.to_s }
347
-
348
- #original_pointer es el pointer del elemento e[]
349
- #busca si el original_pointer esta en la lista de relaciones
350
- #busca si el pointer del tag esta en la lista de relaciones
351
- #cuando un original pointer o un pointer esta en la lista de relaciones, ya no puede volver a ser ingresado en la lista
352
- #si el original pointer ya esta en la lista de relaciones, ya no es necesario volver a checarlo
353
- check_original_pointer = css_code_checked.select {|element| element[:original_pointer].to_s == e[:pointer].to_s }
354
-
355
- check_add_pointer = css_code_checked.select {|element| element[:pointer].to_s == tag.pointer_id.to_s }
356
-
357
- #si el target pointer- pointer no esta en la lista de check agregar,
358
- #si es target-pointer que ya existe + otro pointer da error,
359
- #si es target-pointer y si esta, hacer nada.
360
- #si pointer ya esta en la lista hacer nada
361
- #look for same tags in code
362
-
363
- if check_original_pointer.count == 0
364
- if check_add_pointer.count < 1
365
- element_checked = Hash.new
366
- element_checked[:pointer] = tag.pointer_id
367
- element_checked[:tag] = e[:tag]
368
- element_checked[:original_pointer] = e[:pointer]
369
- element_checked[:original_parent_pointer] = e[:parent_pointer]
370
- css_code_checked << element_checked
340
+ code.css(e[:tag]).each do |tag|
341
+ tag_element = nil
342
+ e_check = css_code_checked.select {|element| element[:original_pointer].to_s == e[:pointer].to_s }
343
+ # p "echeck " + e_check.to_s
344
+ e_check2 = css_code_checked.select {|element| element[:pointer].to_s == tag.pointer_id.to_s }
345
+
346
+ #original_pointer es el pointer del elemento e[]
347
+ #busca si el original_pointer esta en la lista de relaciones
348
+ #busca si el pointer del tag esta en la lista de relaciones
349
+ #cuando un original pointer o un pointer esta en la lista de relaciones, ya no puede volver a ser ingresado en la lista
350
+ #si el original pointer ya esta en la lista de relaciones, ya no es necesario volver a checarlo
351
+ check_original_pointer = css_code_checked.select {|element| element[:original_pointer].to_s == e[:pointer].to_s }
352
+
353
+ check_add_pointer = css_code_checked.select {|element| element[:pointer].to_s == tag.pointer_id.to_s }
354
+
355
+ #look for same tags in code
356
+ if check_original_pointer.count == 0
357
+ if check_add_pointer.count < 1
358
+ element_checked = Hash.new
359
+ element_checked[:pointer] = tag.pointer_id
360
+ element_checked[:tag] = e[:tag]
361
+ element_checked[:original_pointer] = e[:pointer]
362
+ element_checked[:original_parent_pointer] = e[:parent_pointer]
363
+ css_code_checked << element_checked
364
+
365
+ error_element = elements_count.select {|element| element[:tag].to_s == e[:tag].to_s && element[:parent_pointer].to_s == e[:parent_pointer].to_s}.first
366
+ error_element[:count] += 1
367
+ end
368
+ end
369
+ # end
370
+ # p "checked = " + elements_count.to_s
371
371
 
372
+ if code.css(e[:tag]).length > 0
372
373
 
373
- error_element = errors_count.select {|element| element[:tag].to_s == e[:tag].to_s && element[:parent_pointer].to_s == e[:parent_pointer].to_s}.first
374
- error_element[:count] += 1
374
+ #tag es el elemento reccorrido en el codigo
375
+ #e es el elemento original
376
+ #elementscount son los elementos que existen en codigo y original
375
377
 
376
- else
378
+ # if tag_element
379
+ if e[:attribute]
377
380
 
378
- end
379
- end
381
+ p "e --- " + e[:tag].to_s
382
+ p "e pt--- " + e[:pointer].to_s
383
+ p "e parent pt--- " + e[:parent_pointer].to_s
384
+ p "e attribute --- " + e[:attribute].to_s
385
+
386
+
387
+ # if tag.attribute(e[:attribute])
388
+ # p "elements count = " + css_code_checked.to_s
389
+ tag_element = css_code_checked.select {|element| element[:pointer].to_s == tag.pointer_id.to_s && element[:original_pointer] == e[:pointer] }.first
390
+ p "tag --" + tag.name.to_s
391
+ p "tag --" + tag.to_s
392
+ p "tag parent -- " + tag.parent.name.to_s
393
+ p "tag pointer -- " + tag.pointer_id.to_s
394
+ p "tag parent pointer -- " + tag.parent.pointer_id.to_s
395
+ p "tag attribute -- " + tag.attribute(e[:attribute]).to_s
396
+ p "parent_element --- " + tag_element.to_s
397
+ # else
380
398
  # end
381
- # e_check_exist = nil
382
- # end
383
399
 
384
- if e_check.count < 1 and e_check2.count < 1
385
-
386
- element_checked = Hash.new
387
- element_checked[:pointer] = tag.pointer_id
388
- element_checked[:tag] = e[:tag]
389
- element_checked[:target_pointer] = e[:pointer]
390
- element_checked[:target_parent_pointer] = e[:parent_pointer]
391
-
392
-
393
- if e[:attribute]
394
400
  # Check the tag's attributes
395
- if tag.attribute(e[:attribute]).nil?
396
- html_errors << new_error(element: e, type: 334, description: "`<#{e[:tag]}>` should have an attribute named #{e[:attribute]}")
401
+ if tag.attribute(e[:attribute]).nil?
402
+ if tag_element
403
+ # p "attribute element " + e[:attribute].to_s
404
+ # p "attribute tag " + tag.attribute(e[:attribute]).name.to_s
405
+ # if e[:attribute] != tag.attribute(e[:attribute]).name
406
+ p html_errors << new_error(element: e, type: 334, description: "`<#{e[:tag]}>` should have an attribute named #{e[:attribute]}")
407
+ # end
408
+ end
397
409
  else
398
410
  if tag.attribute(e[:attribute]).value != e[:value]
399
411
  exist_in_body << false
@@ -402,17 +414,13 @@ class CodeTerminator::Html
402
414
  if !(e[:tag] == "img" && e[:attribute] == "src" && e[:value] == "")
403
415
  error333 = new_error(element: e, type: 333, description: "Make sure that the attribute #{e[:attribute]} in `<#{e[:tag]}>` has the value #{e[:value]}")
404
416
  end
405
- else
406
- p "add code_checked"
407
- css_code_checked << element_checked
417
+ else
418
+ # p "add code_checked"
419
+ # css_code_checked << element_checked
408
420
  exist_in_body << true
409
421
  end
410
-
411
422
  end
412
-
413
- end #if element checked
414
-
415
- end
423
+ # end
416
424
 
417
425
 
418
426
  # p "respond" + tag.parent.to_s
@@ -421,10 +429,10 @@ class CodeTerminator::Html
421
429
 
422
430
  p "check if exists in parent tags"
423
431
 
424
- e_check4 = css_code_checked.select {|element| element[:pointer].to_s == e[:pointer].to_s }
425
- e_check5 = css_code_checked.select {|element| element[:target_parent_pointer].to_s == e[:parent_pointer].to_s }
432
+ # e_check4 = css_code_checked.select {|element| element[:pointer].to_s == e[:pointer].to_s }
433
+ # e_check5 = css_code_checked.select {|element| element[:target_parent_pointer].to_s == e[:parent_pointer].to_s }
426
434
 
427
- if (tag.count < 2 && tag.first) or (e_check4.count < 1 && e_check5.count < 1)
435
+ if (tag.count < 2 && tag.first)
428
436
  if tag.first.parent.name != e[:parent]
429
437
  html_errors << new_error(element: e, type: 440, description: "Remember to add the `<#{e[:tag]}>` tag inside `<#{e[:parent]}>`")
430
438
  end
@@ -437,20 +445,14 @@ class CodeTerminator::Html
437
445
  end
438
446
  end
439
447
 
440
-
441
448
  end
442
449
 
450
+ end
451
+
452
+ end
453
+
454
+ # end #end tag
443
455
 
444
- else
445
- "pasa else"
446
- # Check that the tag is present
447
- # p "check if exists in parent"
448
- e_check4 = css_code_checked.select {|element| element[:pointer].to_s == e[:pointer].to_s }
449
- e_check5 = css_code_checked.select {|element| element[:target_parent_pointer].to_s == e[:parent_pointer].to_s }
450
- if code.at_css(e[:tag]).nil? or e_check4.count < 1 and e_check5.count < 1
451
- html_errors << new_error(element: e, type: 404, description: "Remember to add the `<#{e[:tag]}>` tag")
452
- end
453
- end
454
456
 
455
457
  if exist_in_body && !exist_in_body.include?(true) && error333
456
458
  html_errors << error333
@@ -461,12 +463,14 @@ class CodeTerminator::Html
461
463
 
462
464
  end
463
465
 
464
- errors_count.each do |x|
466
+ # p elements_count.to_s
467
+
468
+ elements_count.each do |x|
465
469
  #filtrar por parent
466
470
  # tag_count = code.css(x[:tag]).length
467
471
  tag_count = elements.select {|element| element[:parent_pointer].to_s == x[:parent_pointer].to_s && element[:tag].to_s == x[:tag]}.count
468
-
469
- if tag_count > 1
472
+ # p x[:tag]!="body"
473
+ if tag_count >= 1 && !(x[:tag]=="body" || x[:tag]=="head" || x[:tag]=="text" || x[:tag]=="comment")
470
474
  if x[:count] < tag_count
471
475
  html_errors << new_error(element: x[:tag], type: 404, description: "Remember to add the `<#{x[:tag]}>` tag")
472
476
  end
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.5.3"
2
+ VERSION = "0.5.4"
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.5.3
4
+ version: 0.5.4
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-24 00:00:00.000000000 Z
11
+ date: 2017-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler