code_terminator 0.4.5 → 0.4.6

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: 7509514e388e2c045e061ccafa776714aa166cc2
4
- data.tar.gz: 9391400890dd1499985ea3161dcd9f43df69d79c
3
+ metadata.gz: d023b54f3d9e4807758e10c9d8c9c1ad512d1feb
4
+ data.tar.gz: 81cc874ddd8da35b5ca80ac60cb6c8ad811ef544
5
5
  SHA512:
6
- metadata.gz: 6729e406cb5949dd4a47c662ed2851daa5a2b1ed4a5b44fef8208022331d1914bb5d44841f36823d340195df391c6a5f22491cae0fb905a80a164506e262770a
7
- data.tar.gz: 31d71cfb8a70982460db6cdeecee7cfcd28ec06420d048e1fb0979865d8aacf788431fcb506c7107aaf8769dc6f31f8eba4a8eda8d13c894b63875beba22817e
6
+ metadata.gz: c75b3ff7b196f630bd6fa95f83bc1b7f480e4c34f932747c744a4729dd979003d9cecf49d05a306dc187b13f04f056420b70b529d0b3c7affda954e94440382a
7
+ data.tar.gz: c94d216cd485c7f5f5e09e471aeb78f4c6f8a104c9bf2badb39f2bb04ac70b6185b6641783576d9ef3252984e1c4e96d15c56dff8b4727f8ac289f69352bc71c
@@ -253,7 +253,12 @@ class CodeTerminator::Html
253
253
 
254
254
  elements = get_elements(source)
255
255
 
256
+ exist_in_body = Array.new
257
+
258
+ error333 = nil
259
+
256
260
  elements.each do |e|
261
+
257
262
  item = e[:tag]
258
263
 
259
264
  if item=="text"
@@ -280,27 +285,36 @@ class CodeTerminator::Html
280
285
  end
281
286
 
282
287
  else
288
+
283
289
  if code.css(e[:tag]).length > 0
284
290
 
291
+ code.css(e[:tag]).each do |tag|
292
+
285
293
  if !e[:attribute].nil?
286
294
  # Check the tag's attributes
287
- if code.css(e[:tag]).attribute(e[:attribute]).nil?
295
+ if tag.attribute(e[:attribute]).nil?
288
296
  html_errors << new_error(element: e, type: 334, description: "#{e[:tag]} should have an attribute named #{e[:attribute]}.")
289
297
  else
290
- if code.css(e[:tag]).attribute(e[:attribute]).value != e[:value]
291
- html_errors << new_error(element: e, type: 333, description: "Make sure that the attribute #{e[:attribute]} in #{e[:tag]} has the value #{e[:value]}.")
298
+ if tag.attribute(e[:attribute]).value != e[:value]
299
+ exist_in_body << false
300
+ error333 = new_error(element: e, type: 333, description: "Make sure that the attribute #{e[:attribute]} in #{e[:tag]} has the value #{e[:value]}.")
301
+ else
302
+ exist_in_body << true
292
303
  end
304
+
293
305
  end
294
306
  end
295
307
 
296
308
  # Check that tags exist within parent tags
297
- if code.css(e[:tag]).count < 2
298
- if code.css(e[:tag]).first.parent.name != e[:parent]
309
+ if tag.first.respond_to? :parent
310
+
311
+ if tag.count < 2 && !tag.first.nil?
312
+ if tag.first.parent.name != e[:parent]
299
313
  html_errors << new_error(element: e, type: 440, description: "Remember to add the #{e[:tag]} tag inside #{e[:parent]}.")
300
314
  end
301
315
  else
302
- exist_in_parent = false
303
- code.css(e[:tag]).each do |code_css|
316
+ exist_in_parent = false
317
+ tag.each do |code_css|
304
318
  if code_css.parent.name == e[:parent]
305
319
  exist_in_parent = true
306
320
  end
@@ -309,6 +323,8 @@ class CodeTerminator::Html
309
323
  html_errors << new_error(element: e, type: 440, description: "Remember to add the #{e[:tag]} tag inside #{e[:parent]}.")
310
324
  end
311
325
  end
326
+ end
327
+ end
312
328
 
313
329
  else
314
330
  # Check that the tag is present
@@ -317,7 +333,13 @@ class CodeTerminator::Html
317
333
  end
318
334
  end
319
335
 
336
+ if !exist_in_body.empty? && !exist_in_body.include?(true) && !error333.nil?
337
+ html_errors << error333
338
+ end
339
+ exist_in_body = []
340
+
320
341
  end
342
+
321
343
  end
322
344
 
323
345
  html_errors
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.4.5"
2
+ VERSION = "0.4.6"
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.5
4
+ version: 0.4.6
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-30 00:00:00.000000000 Z
11
+ date: 2016-10-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler