code_terminator 0.5.6 → 0.5.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 +4 -4
- data/exercises/css/lesson0.css +5 -0
- data/exercises/css/lesson0_w.css +5 -0
- data/exercises/css/lesson1_1.css +1 -0
- data/exercises/css/lesson1_2.css +5 -0
- data/exercises/css/lesson1_5.css +16 -0
- data/lib/code_terminator/css.rb +23 -3
- data/lib/code_terminator/html.rb +24 -105
- data/lib/code_terminator/version.rb +1 -1
- metadata +7 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 986026e1b23cb931e122837f5e2c9ffc298e3818
|
4
|
+
data.tar.gz: 2d13072f71055e8e2c188078f6317ba78196b3da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b02faf723eb6f4e8898d8ebf061e12c18eb2b0ad51cd111d9e91c144066948fb6c4908574a63e0693d8a2777285b22b78484e15e8ccee57ea3be889918de19d0
|
7
|
+
data.tar.gz: c54040e0e49c5b85784a1a59a7037943412fe38187ef951f6f57ad19413cce59148c3522f9978af3270295cf83f9b3aa13ca32ea67b9ba3b280a7508b465540f
|
@@ -0,0 +1 @@
|
|
1
|
+
#border{border-color:green; border-style:solid;}
|
data/lib/code_terminator/css.rb
CHANGED
@@ -208,16 +208,36 @@ class CodeTerminator::Css
|
|
208
208
|
parser.load_string!(code)
|
209
209
|
elements.each do |e|
|
210
210
|
item = e[:selector]
|
211
|
-
if
|
211
|
+
if e[:property]
|
212
212
|
property = e[:property]
|
213
213
|
parser_array = parser.find_by_selector(item)
|
214
214
|
if parser_array.any?
|
215
|
+
# p "array " + parser_array.to_s
|
215
216
|
parser_property = parser_array[0].split(";")
|
216
|
-
|
217
|
+
# p "array split" + parser_property.to_s
|
217
218
|
|
219
|
+
search_results = parser_property.select { |key| key.include?(property) }
|
220
|
+
if search_results.empty?
|
221
|
+
css_errors << new_error(element: e, type: 111, description: "Make sure the property _#{property}_ is in the selector **#{item}**")
|
222
|
+
end
|
223
|
+
|
224
|
+
|
225
|
+
# parser_property.each do |pp|
|
226
|
+
# p "include " + pp.include?(property).to_s
|
227
|
+
# if !pp.include?(property)
|
228
|
+
# css_errors << new_error(element: e, type: 111, description: "Make sure the property _#{property}_ is in the selector **#{item}**")
|
229
|
+
# end
|
230
|
+
# end
|
231
|
+
|
232
|
+
|
233
|
+
parser_property.each {|a| a.strip! if a.respond_to? :strip! }
|
234
|
+
|
235
|
+
|
236
|
+
# p "value:" + e[:value]
|
218
237
|
if e[:value]==""
|
219
238
|
property = e[:property] + ": "
|
220
|
-
|
239
|
+
# p "parser property: " + parser_property.to_s
|
240
|
+
if parser_property.empty?
|
221
241
|
css_errors << new_error(element: e, type: 111, description: "Make sure the property _#{property}_ is in the selector **#{item}**")
|
222
242
|
end
|
223
243
|
else
|
data/lib/code_terminator/html.rb
CHANGED
@@ -131,13 +131,6 @@ class CodeTerminator::Html
|
|
131
131
|
node[:parent_pointer] = child.parent.pointer_id
|
132
132
|
@elements << node
|
133
133
|
else
|
134
|
-
node = Hash.new
|
135
|
-
node[:parent] = "body"
|
136
|
-
node[:tag] = child.name
|
137
|
-
node[:content] = child.text if child.text? or child.comment?
|
138
|
-
node[:pointer] = child.pointer_id
|
139
|
-
node[:parent_pointer] = child.parent.pointer_id
|
140
|
-
@elements << node
|
141
134
|
child.attribute_nodes.each do |element_attribute|
|
142
135
|
node = Hash.new
|
143
136
|
node[:parent] = "body"
|
@@ -303,7 +296,6 @@ class CodeTerminator::Html
|
|
303
296
|
|
304
297
|
|
305
298
|
exist_in_body = Array.new
|
306
|
-
exist_value = Array.new
|
307
299
|
|
308
300
|
error_elements = Array.new
|
309
301
|
|
@@ -316,25 +308,15 @@ class CodeTerminator::Html
|
|
316
308
|
|
317
309
|
|
318
310
|
elements.each do |e|
|
319
|
-
|
320
|
-
|
321
|
-
|
322
|
-
|
323
|
-
|
324
|
-
|
325
|
-
|
326
|
-
|
327
|
-
|
328
|
-
|
329
|
-
# if elements_count.select {|element| element[:parent_pointer].to_s == e[:parent_pointer].to_s && element[:tag].to_s == e[:tag]}.count < 1
|
330
|
-
the_element = Hash.new
|
331
|
-
the_element[:tag] = e[:tag]
|
332
|
-
the_element[:pointer] = e[:pointer]
|
333
|
-
the_element[:parent_pointer] = e[:parent_pointer]
|
334
|
-
the_element[:count] = 1
|
335
|
-
elements_count << the_element
|
336
|
-
# end
|
337
|
-
end
|
311
|
+
|
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
|
+
error_element = Hash.new
|
314
|
+
error_element[:tag] = e[:tag]
|
315
|
+
error_element[:pointer] = e[:pointer]
|
316
|
+
error_element[:parent_pointer] = e[:parent_pointer]
|
317
|
+
error_element[:count] = 0
|
318
|
+
elements_count << error_element
|
319
|
+
end
|
338
320
|
|
339
321
|
item = e[:tag]
|
340
322
|
|
@@ -356,7 +338,6 @@ class CodeTerminator::Html
|
|
356
338
|
#item class is different to text or comment
|
357
339
|
|
358
340
|
code.css(e[:tag]).each do |tag|
|
359
|
-
p "tag " + tag.to_s
|
360
341
|
tag_element = nil
|
361
342
|
e_check = css_code_checked.select {|element| element[:original_pointer].to_s == e[:pointer].to_s }
|
362
343
|
# p "echeck " + e_check.to_s
|
@@ -370,22 +351,9 @@ class CodeTerminator::Html
|
|
370
351
|
check_original_pointer = css_code_checked.select {|element| element[:original_pointer].to_s == e[:pointer].to_s }
|
371
352
|
|
372
353
|
check_add_pointer = css_code_checked.select {|element| element[:pointer].to_s == tag.pointer_id.to_s }
|
373
|
-
# p "check_add " + check_add_pointer.to_s
|
374
|
-
#look for same tags in code
|
375
|
-
# p "elements_count"
|
376
|
-
# p elements_count
|
377
354
|
|
355
|
+
#look for same tags in code
|
378
356
|
if check_original_pointer.count == 0
|
379
|
-
# p "pasa"
|
380
|
-
# # if tag.attributes.nil?
|
381
|
-
# # p "CON ATRIBUTOS"
|
382
|
-
# # else
|
383
|
-
# # p elements_count.to_s
|
384
|
-
# p "element " +e[:tag].to_s
|
385
|
-
# p "e pointer "+e[:pointer].to_s
|
386
|
-
# p "e parent pointer "+e[:parent_pointer].to_s
|
387
|
-
|
388
|
-
# end
|
389
357
|
if check_add_pointer.count < 1
|
390
358
|
element_checked = Hash.new
|
391
359
|
element_checked[:pointer] = tag.pointer_id
|
@@ -394,11 +362,8 @@ class CodeTerminator::Html
|
|
394
362
|
element_checked[:original_parent_pointer] = e[:parent_pointer]
|
395
363
|
css_code_checked << element_checked
|
396
364
|
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
# p "the element " + the_element.to_s
|
401
|
-
the_element[:count] += 1 if the_element
|
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
|
402
367
|
end
|
403
368
|
end
|
404
369
|
# end
|
@@ -444,24 +409,13 @@ class CodeTerminator::Html
|
|
444
409
|
else
|
445
410
|
if tag.attribute(e[:attribute]).value != e[:value]
|
446
411
|
exist_in_body << false
|
447
|
-
# p "value " + e[:value]
|
448
|
-
tag_attribute = tag.attribute(e[:attribute]).name
|
449
|
-
tag_attribute_value = tag.attribute(e[:attribute]).value
|
450
|
-
# p "type " + e[:tag] + " with attribute " + e[:attribute] + " value " + e[:value]
|
412
|
+
# p "type " + e[:tag] + " with attribute " + e[:attribute] + " value " + e[:value]
|
451
413
|
# Check if the img have attribute src and value is null, the user can write whatever image he wants
|
452
|
-
|
453
|
-
|
454
|
-
if (!exist_value.include? tag_attribute_value and !exist_value.include? e[:value])
|
455
|
-
exist_in_body << false
|
456
|
-
error333 = new_error(element: e, type: 333, description: "Make sure that the attribute #{e[:attribute]} in `<#{e[:tag]}>` has the value #{e[:value]}")
|
457
|
-
end
|
458
|
-
# html_errors << error333 if error333
|
459
|
-
else
|
460
|
-
|
414
|
+
if !(e[:tag] == "img" && e[:attribute] == "src" && e[:value] == "")
|
415
|
+
error333 = new_error(element: e, type: 333, description: "Make sure that the attribute #{e[:attribute]} in `<#{e[:tag]}>` has the value #{e[:value]}")
|
461
416
|
end
|
462
417
|
else
|
463
418
|
# p "add code_checked"
|
464
|
-
exist_value << e[:value]
|
465
419
|
# css_code_checked << element_checked
|
466
420
|
exist_in_body << true
|
467
421
|
end
|
@@ -473,7 +427,7 @@ class CodeTerminator::Html
|
|
473
427
|
# Check that tags exist within parent tags
|
474
428
|
if tag.first.respond_to? :parent
|
475
429
|
|
476
|
-
|
430
|
+
p "check if exists in parent tags"
|
477
431
|
|
478
432
|
# e_check4 = css_code_checked.select {|element| element[:pointer].to_s == e[:pointer].to_s }
|
479
433
|
# e_check5 = css_code_checked.select {|element| element[:target_parent_pointer].to_s == e[:parent_pointer].to_s }
|
@@ -499,66 +453,31 @@ class CodeTerminator::Html
|
|
499
453
|
|
500
454
|
# end #end tag
|
501
455
|
|
456
|
+
|
502
457
|
if exist_in_body && !exist_in_body.include?(true) && error333
|
503
458
|
html_errors << error333
|
504
459
|
end
|
505
|
-
|
506
|
-
# if exist_in_body && !exist_in_body.include?(true) && error333
|
507
|
-
# html_errors << error333
|
508
|
-
# end
|
509
|
-
|
510
460
|
exist_in_body = []
|
511
|
-
error333 = nil
|
512
|
-
# exist_value = []
|
513
461
|
|
514
462
|
end
|
515
463
|
|
516
464
|
end
|
517
465
|
|
518
|
-
|
519
|
-
|
520
|
-
# p "elements_count2 = "
|
521
|
-
grouped_elements = elements_count.select {|element| element[:count] > 0}.group_by { |s| [s[:parent_pointer], s[:tag]] }
|
466
|
+
# p elements_count.to_s
|
522
467
|
|
523
|
-
|
468
|
+
elements_count.each do |x|
|
524
469
|
#filtrar por parent
|
525
|
-
#tag_count = code.css(x[:tag]).length
|
526
|
-
|
527
|
-
# p "group="+tag_count.group_by{|h| h[:parent_pointer]}.values.to_s
|
528
|
-
# p result=Hash[tag_count.group_by{|x|x}.map{|k,v| [k,v.size]}]
|
529
|
-
p "tag" + x.to_s
|
530
|
-
p "tag count " + tag_count.count.to_s
|
531
|
-
p "grouped" + x.to_s
|
532
|
-
p "grouped count " + x[1].first[:count].to_s
|
533
|
-
(p "div count " + x[1][0].count.to_s) if x[0][1]=="div"
|
534
|
-
|
535
|
-
# p tag_count = elements.select {|element| element[:pointer].to_s == x[:pointer].to_s && element[:tag].to_s == x[:tag]}.count
|
470
|
+
# tag_count = code.css(x[:tag]).length
|
471
|
+
tag_count = elements.select {|element| element[:parent_pointer].to_s == x[:parent_pointer].to_s && element[:tag].to_s == x[:tag]}.count
|
536
472
|
# p x[:tag]!="body"
|
537
|
-
if tag_count
|
473
|
+
if tag_count >= 1 && !(x[:tag]=="body" || x[:tag]=="head" || x[:tag]=="text" || x[:tag]=="comment" || x[:tag]=="img")
|
538
474
|
# if tag_count >= 1 && !(x[:tag]!="div")
|
539
|
-
|
540
|
-
|
541
|
-
html_errors << new_error(element: x[0][1], type: 404, description: "Remember to add the `<#{x[0][1]}>` tag")
|
542
|
-
end
|
543
|
-
else
|
544
|
-
if x[1].first[:count] < tag_count.count
|
545
|
-
html_errors << new_error(element: x[0][1], type: 404, description: "Remember to add the `<#{x[0][1]}>` tag")
|
475
|
+
if x[:count] < tag_count
|
476
|
+
html_errors << new_error(element: x[:tag], type: 404, description: "Remember to add the `<#{x[:tag]}>` tag")
|
546
477
|
end
|
547
|
-
end
|
548
478
|
end
|
549
479
|
end
|
550
480
|
|
551
|
-
# grouped_elements_null = elements_count.select {|element| element[:count] == 0}.group_by { |s| [s[:parent_pointer], s[:tag]] }
|
552
|
-
#
|
553
|
-
# grouped_elements_null.each do |nulls|
|
554
|
-
# if !(nulls[0][1]=="body" || nulls[0][1]=="head" || nulls[0][1]=="text" || nulls[0][1]=="comment")
|
555
|
-
# # if tag_count >= 1 && !(x[:tag]!="div")
|
556
|
-
# # if x[1].count < tag_count.count
|
557
|
-
# html_errors << new_error(element: nulls[0][1], type: 404, description: "Remember to add the `<#{nulls[0][1]}>` tag")
|
558
|
-
# # end
|
559
|
-
# end
|
560
|
-
# end
|
561
|
-
p elements_count
|
562
481
|
html_errors
|
563
482
|
|
564
483
|
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.
|
4
|
+
version: 0.5.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: 2017-
|
11
|
+
date: 2017-03-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -156,6 +156,11 @@ files:
|
|
156
156
|
- bin/setup
|
157
157
|
- code_terminator.gemspec
|
158
158
|
- exe/code_terminator
|
159
|
+
- exercises/css/lesson0.css
|
160
|
+
- exercises/css/lesson0_w.css
|
161
|
+
- exercises/css/lesson1_1.css
|
162
|
+
- exercises/css/lesson1_2.css
|
163
|
+
- exercises/css/lesson1_5.css
|
159
164
|
- exercises/get_elements.html
|
160
165
|
- exercises/html/check_body_tag_exist.html
|
161
166
|
- exercises/html/check_comment_empty.html
|