code_terminator 0.3.4 → 0.4.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/css.rb +14 -18
- data/lib/code_terminator/html.rb +13 -11
- 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: b1e8b4fbb2da92212f15642327bdf9effac8e772
|
4
|
+
data.tar.gz: a8c55254172be2a62348ee952ef4b147cee66f53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 445a692e5ec0d4bede8bbd120e96e46a26d5c63951c000b65a315f69f8e68f9121f503a537844f508e292a5bc2910a03e88b9d9061b9bd9fa64b682bad8840a0
|
7
|
+
data.tar.gz: f6e1e1b313b5568685bf44a84fd579bef937e5ea3cabf637e608d581fc544eab9ab8047a4e3801b9d8126672b7a2d47195a66da408115a718719c61c00343f78
|
data/lib/code_terminator/css.rb
CHANGED
@@ -102,11 +102,11 @@ class CodeTerminator::Css
|
|
102
102
|
#else
|
103
103
|
#valid = false
|
104
104
|
end
|
105
|
-
|
105
|
+
else
|
106
106
|
errors[0] = "error"
|
107
|
-
|
107
|
+
end
|
108
108
|
errors
|
109
|
-
|
109
|
+
end
|
110
110
|
|
111
111
|
# Read a css file. Return a string with the text of the file.
|
112
112
|
#
|
@@ -120,20 +120,16 @@ class CodeTerminator::Css
|
|
120
120
|
def read_file(source)
|
121
121
|
if @source_type == "url"
|
122
122
|
fileCss = open(source).read
|
123
|
+
text = fileCss
|
123
124
|
else
|
124
125
|
fileCss = File.open(source, "r")
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
126
|
+
begin
|
127
|
+
text = fileCss.read
|
128
|
+
rescue
|
129
|
+
text = false
|
130
|
+
ensure
|
131
|
+
#fileHtml.close unless fileHtml.nil?
|
131
132
|
end
|
132
|
-
fileCss.close
|
133
|
-
rescue
|
134
|
-
text = false
|
135
|
-
ensure
|
136
|
-
#fileHtml.close unless fileHtml.nil?
|
137
133
|
end
|
138
134
|
|
139
135
|
text
|
@@ -216,7 +212,7 @@ class CodeTerminator::Css
|
|
216
212
|
elements.each do |e|
|
217
213
|
item = e[:selector]
|
218
214
|
if !e[:property].nil?
|
219
|
-
|
215
|
+
property = e[:property]
|
220
216
|
parser_array = parser.find_by_selector(item)
|
221
217
|
if parser_array.any?
|
222
218
|
parser_property = parser_array[0].split(";")
|
@@ -225,18 +221,18 @@ class CodeTerminator::Css
|
|
225
221
|
if e[:value]==""
|
226
222
|
property = e[:property] + ": "
|
227
223
|
if parser_property.empty? { |s| s.include?(property) }
|
228
|
-
css_errors << new_error(element: e, type: 111, description: "
|
224
|
+
css_errors << new_error(element: e, type: 111, description: "Make sure the property #{property} is in the selector #{item}.")
|
229
225
|
end
|
230
226
|
else
|
231
227
|
property = e[:property] + ": " + e[:value]
|
232
228
|
if !parser_property.include?(property)
|
233
|
-
css_errors << new_error(element: e, type: 111, description: "
|
229
|
+
css_errors << new_error(element: e, type: 111, description: "Make sure the property #{property} is in the selector #{item}.")
|
234
230
|
end
|
235
231
|
end
|
236
232
|
|
237
233
|
else
|
238
234
|
node = Hash.new
|
239
|
-
css_errors << new_error(element: e, type: 101, description:
|
235
|
+
css_errors << new_error(element: e, type: 101, description: "Add #{property} inside #{item}.")
|
240
236
|
end
|
241
237
|
end
|
242
238
|
end
|
data/lib/code_terminator/html.rb
CHANGED
@@ -231,10 +231,11 @@ class CodeTerminator::Html
|
|
231
231
|
|
232
232
|
if item=="text"
|
233
233
|
|
234
|
+
# Check the text
|
234
235
|
if !e[:content].nil?
|
235
236
|
if code.css(e[:parent]).count < 2
|
236
237
|
if code.css(e[:parent]).text != e[:content]
|
237
|
-
html_errors << new_error(element: e, type: 330, description: e[:parent]
|
238
|
+
html_errors << new_error(element: e, type: 330, description: "The text inside #{e[:parent]} should be #{e[:content]}.")
|
238
239
|
end
|
239
240
|
else
|
240
241
|
exist = false
|
@@ -246,7 +247,7 @@ class CodeTerminator::Html
|
|
246
247
|
#end
|
247
248
|
end
|
248
249
|
if !exist
|
249
|
-
html_errors << new_error(element: e, type: 330, description: e[:parent]
|
250
|
+
html_errors << new_error(element: e, type: 330, description: "The text inside #{e[:parent]} should be #{e[:content]}.")
|
250
251
|
end
|
251
252
|
end
|
252
253
|
end
|
@@ -255,19 +256,21 @@ class CodeTerminator::Html
|
|
255
256
|
if code.css(e[:tag]).length > 0
|
256
257
|
|
257
258
|
if !e[:attribute].nil?
|
259
|
+
# Check the tag's attributes
|
258
260
|
if code.css(e[:tag]).attribute(e[:attribute]).nil?
|
259
|
-
html_errors << new_error(element: e, type: 334, description: e[:
|
261
|
+
html_errors << new_error(element: e, type: 334, description: "#{e[:tag]} should have an attribute named #{e[:attribute]}.")
|
260
262
|
else
|
261
263
|
if code.css(e[:tag]).attribute(e[:attribute]).value != e[:value]
|
262
|
-
html_errors << new_error(element: e, type: 333, description: e[:attribute]
|
264
|
+
html_errors << new_error(element: e, type: 333, description: "Make sure that the attribute #{e[:attribute]} in #{e[:tag]} has the value #{e[:value]}.")
|
263
265
|
end
|
264
266
|
end
|
265
267
|
end
|
266
268
|
|
269
|
+
# Check that tags exist within parent tags
|
267
270
|
if code.css(e[:tag]).count < 2
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
+
if code.css(e[:tag]).first.parent.name != e[:parent]
|
272
|
+
html_errors << new_error(element: e, type: 440, description: "Remember to add the #{e[:tag]} tag inside #{e[:parent]}.")
|
273
|
+
end
|
271
274
|
else
|
272
275
|
exist_in_parent = false
|
273
276
|
code.css(e[:tag]).each do |code_css|
|
@@ -276,16 +279,15 @@ class CodeTerminator::Html
|
|
276
279
|
end
|
277
280
|
end
|
278
281
|
if !exist_in_parent
|
279
|
-
html_errors << new_error(element: e, type: 440, description: e[:tag]
|
282
|
+
html_errors << new_error(element: e, type: 440, description: "Remember to add the #{e[:tag]} tag inside #{e[:parent]}.")
|
280
283
|
end
|
281
284
|
end
|
282
285
|
|
283
286
|
else
|
284
|
-
|
287
|
+
# Check that the tag is present
|
285
288
|
if code.at_css(e[:tag]).nil?
|
286
|
-
html_errors << new_error(element: e, type: 404, description: e[:tag]
|
289
|
+
html_errors << new_error(element: e, type: 404, description: "Remember to add the #{e[:tag]} tag.")
|
287
290
|
end
|
288
|
-
|
289
291
|
end
|
290
292
|
|
291
293
|
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
|
+
version: 0.4.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: 2016-09-
|
11
|
+
date: 2016-09-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|