code_terminator 0.3.0 → 0.3.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +24 -4
- data/code_terminator-0.2.7.gem +0 -0
- data/code_terminator-0.3.0.gem +0 -0
- data/code_terminator.gemspec +1 -1
- data/exercises/test.html +1 -1
- data/lib/code_terminator/css.rb +14 -16
- data/lib/code_terminator/html.rb +44 -30
- data/lib/code_terminator/version.rb +1 -1
- metadata +6 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4082bd74f0e7d14d4a8d8c6292a389dbdd442729
|
4
|
+
data.tar.gz: 01c77d3f7559c715c350837b0b294466bbc27082
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 618000fcb3011b6cf2417468725e1037d172090bb860e1228ebb2bf9ab2aee35851597ecbc258080c5233167ea2be7d6520a54d67c480ac42df7f29e1846ff7f
|
7
|
+
data.tar.gz: f15697ff82365c2246f39ed2ea25645a34254782b68b81035dfc48293ddcfe931b147143801c8c4535ffd115adea3e2650c37daeb5ffe9816de0812b71ddb838
|
data/README.md
CHANGED
@@ -50,7 +50,7 @@ You will know that the code and the source file have the same html elements when
|
|
50
50
|
# <h1>Come with me if you want to live!</h1>
|
51
51
|
#
|
52
52
|
>> ct.match("hola_mundo.html","<h2>Come with me if you want to live!</h2>")
|
53
|
-
#
|
53
|
+
# => [{:element=>{:parent=>"body", :tag=>"p"}, :type=>404, :description=>"p not exist"}]
|
54
54
|
```
|
55
55
|
|
56
56
|
##### CSS
|
@@ -76,7 +76,7 @@ You will know that the code and the source file have the same css elements when
|
|
76
76
|
# => h1{ margin: 100px; }
|
77
77
|
#
|
78
78
|
>> ct.match("test.html","h1{ margin: 50px; }")
|
79
|
-
#
|
79
|
+
# => [{:element=>{:selector=>"body", :property=>"background-color", :value=>"yellow"}, :type=>111, :description=>"not the same property background-color: yellow in selector body"}]
|
80
80
|
```
|
81
81
|
|
82
82
|
##Cheat Sheet
|
@@ -92,7 +92,7 @@ Match if the code have the same elements than the exercise. Return an array with
|
|
92
92
|
```ruby
|
93
93
|
>> ct = CodeTerminator::Html.new
|
94
94
|
>> ct.match("hola_mundo.html","<h2>Come with me if you want to live!</h2>")
|
95
|
-
#
|
95
|
+
# => [{:element=>{:parent=>"body", :tag=>"p"}, :type=>404, :description=>"p not exist"}]
|
96
96
|
#
|
97
97
|
```
|
98
98
|
|
@@ -104,10 +104,30 @@ Match if the code have the same elements than the exercise. Return an array with
|
|
104
104
|
```ruby
|
105
105
|
>> ct = CodeTerminator::Css.new
|
106
106
|
>> ct.match("hola_mundo.css","h1{ margin: 50px; }")
|
107
|
-
#
|
107
|
+
# => [{:element=>{:selector=>"body", :property=>"background-color", :value=>"yellow"}, :type=>111, :description=>"not the same property background-color: yellow in selector body"}]
|
108
|
+
|
108
109
|
#
|
109
110
|
```
|
110
111
|
|
112
|
+
######Errors description
|
113
|
+
The errors that throw match() are in json format to help you to identify each error type as the following:
|
114
|
+
```ruby
|
115
|
+
# [element, error_type, description]
|
116
|
+
[{:element=>{:selector=>"body", :property=>"background-color", :value=>"yellow"}, :type=>111, :description=>"not the same property background-color: yellow in selector body"}]
|
117
|
+
```
|
118
|
+
Errors Types
|
119
|
+
<ul>
|
120
|
+
<li><b>101 : </b>Css property not found</li>
|
121
|
+
<li><b>111 : </b>Different css property in the selector</li>
|
122
|
+
<li><b>330 : </b>Different text in the html tag</li>
|
123
|
+
<li><b>333 : </b>Different value in the html attribute</li>
|
124
|
+
<li><b>334 : </b>Html attribute doesn't exist in the tag</li>
|
125
|
+
<li><b>404 : </b>Element not found</li>
|
126
|
+
<li><b>440 : </b>Tag not found in the parent tag</li>
|
127
|
+
</ul>
|
128
|
+
|
129
|
+
<br>
|
130
|
+
|
111
131
|
###new_file(source, code)
|
112
132
|
Create a Html/Css file with the code of the editor. Return a boolean that indicate if the file was created or not.
|
113
133
|
#####HTML
|
Binary file
|
Binary file
|
data/code_terminator.gemspec
CHANGED
data/exercises/test.html
CHANGED
@@ -1 +1 @@
|
|
1
|
-
<body><h2>hola test</h2><
|
1
|
+
<body><h2>hola test</h2><div><h2>html</h2></div><div><h2>css</h2></div></body>
|
data/lib/code_terminator/css.rb
CHANGED
@@ -189,7 +189,7 @@ class CodeTerminator::Css
|
|
189
189
|
# => body { background-color: lightblue; }
|
190
190
|
#
|
191
191
|
# >> CodeTerminator::Css.match("test.css","body {background-color: blue; }")
|
192
|
-
# => ["not the same property background-color in selector body
|
192
|
+
# => [{:element=>{:selector=>"body", :property=>"background-color", :value=>"yellow"}, :type=>111, :description=>"not the same property background-color: yellow in selector body"}]
|
193
193
|
#
|
194
194
|
# Arguments:
|
195
195
|
# source: (String)
|
@@ -217,29 +217,18 @@ class CodeTerminator::Css
|
|
217
217
|
if e[:value]==""
|
218
218
|
property = e[:property] + ": "
|
219
219
|
if parser_property.empty? { |s| s.include?(property) }
|
220
|
-
|
221
|
-
node[:element] = e
|
222
|
-
node[:type] = 111
|
223
|
-
node[:description] = "not the same property " + property + " in selector " + item
|
224
|
-
css_errors << node
|
220
|
+
css_errors << new_error(element: e, type: 111, description: "not the same property " + property + " in selector " + item)
|
225
221
|
end
|
226
222
|
else
|
227
223
|
property = e[:property] + ": " + e[:value]
|
228
224
|
if !parser_property.include?(property)
|
229
|
-
|
230
|
-
node[:element] = e
|
231
|
-
node[:type] = 111
|
232
|
-
node[:description] = "not the same property " + property + " in selector " + item
|
233
|
-
css_errors << node
|
225
|
+
css_errors << new_error(element: e, type: 111, description: "not the same property " + property + " in selector " + item)
|
234
226
|
end
|
235
227
|
end
|
236
228
|
|
237
229
|
else
|
238
230
|
node = Hash.new
|
239
|
-
|
240
|
-
node[:type] = 101
|
241
|
-
node[:description] = "property "+ property + " not found in " + item
|
242
|
-
css_errors << node
|
231
|
+
css_errors << new_error(element: e, type: 101, description: "property "+ property + " not found in " + item)
|
243
232
|
end
|
244
233
|
end
|
245
234
|
end
|
@@ -248,7 +237,16 @@ class CodeTerminator::Css
|
|
248
237
|
|
249
238
|
private
|
250
239
|
|
251
|
-
|
240
|
+
def new_error(args = {})
|
241
|
+
element = args[:element]
|
242
|
+
type = args[:type]
|
243
|
+
description = args[:description]
|
244
|
+
node = Hash.new
|
245
|
+
node[:element] = element
|
246
|
+
node[:type] = type
|
247
|
+
node[:description] = description
|
248
|
+
node
|
249
|
+
end
|
252
250
|
#end
|
253
251
|
|
254
252
|
end
|
data/lib/code_terminator/html.rb
CHANGED
@@ -220,15 +220,23 @@ class CodeTerminator::Html
|
|
220
220
|
if item=="text"
|
221
221
|
|
222
222
|
if !e[:content].nil?
|
223
|
-
if code.css(e[:parent]).
|
224
|
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
223
|
+
if code.css(e[:parent]).count < 2
|
224
|
+
if code.css(e[:parent]).text != e[:content]
|
225
|
+
html_errors << new_error(element: e, type: 330, description: e[:parent] + " haven't the same text " + e[:content])
|
226
|
+
end
|
227
|
+
else
|
228
|
+
exist = false
|
229
|
+
code.css(e[:parent]).each do |code_css|
|
230
|
+
#if code_css.at_css(e[:tag]).parent.name == e[:parent]
|
231
|
+
if code_css.text == e[:content]
|
232
|
+
exist = true
|
233
|
+
end
|
234
|
+
#end
|
235
|
+
end
|
236
|
+
if !exist
|
237
|
+
html_errors << new_error(element: e, type: 330, description: e[:parent] + " haven't the same text " + e[:content])
|
238
|
+
end
|
229
239
|
end
|
230
|
-
#e[:content] == code.css()
|
231
|
-
|
232
240
|
end
|
233
241
|
|
234
242
|
else
|
@@ -236,38 +244,34 @@ class CodeTerminator::Html
|
|
236
244
|
|
237
245
|
if !e[:attribute].nil?
|
238
246
|
if code.css(e[:tag]).attribute(e[:attribute]).nil?
|
239
|
-
|
240
|
-
node[:element] = e
|
241
|
-
node[:type] = 334
|
242
|
-
node[:description] = e[:attribute] + " not exist in " + e[:tag]
|
243
|
-
html_errors << node
|
247
|
+
html_errors << new_error(element: e, type: 334, description: e[:attribute] + " not exist in " + e[:tag])
|
244
248
|
else
|
245
249
|
if code.css(e[:tag]).attribute(e[:attribute]).value != e[:value]
|
246
|
-
|
247
|
-
node[:element] = e
|
248
|
-
node[:type] = 333
|
249
|
-
node[:description] = e[:attribute] + " not is the same value " + e[:value]
|
250
|
-
html_errors << node
|
250
|
+
html_errors << new_error(element: e, type: 333, description: e[:attribute] + " not is the same value " + e[:value])
|
251
251
|
end
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
255
|
-
if code.
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
255
|
+
if code.css(e[:tag]).count < 2
|
256
|
+
if code.css(e[:tag]).first.parent.name != e[:parent]
|
257
|
+
html_errors << new_error(element: e, type: 440, description: e[:tag] + " not exist in " + e[:parent])
|
258
|
+
end
|
259
|
+
else
|
260
|
+
exist_in_parent = false
|
261
|
+
code.css(e[:tag]).each do |code_css|
|
262
|
+
if code_css.parent.name == e[:parent]
|
263
|
+
exist_in_parent = true
|
264
|
+
end
|
265
|
+
end
|
266
|
+
if !exist_in_parent
|
267
|
+
html_errors << new_error(element: e, type: 440, description: e[:tag] + " not exist in " + e[:parent])
|
268
|
+
end
|
261
269
|
end
|
262
270
|
|
263
271
|
else
|
264
272
|
|
265
273
|
if code.at_css(e[:tag]).nil?
|
266
|
-
|
267
|
-
node[:element] = e
|
268
|
-
node[:type] = 404
|
269
|
-
node[:description] = e[:tag] + " not exist"
|
270
|
-
html_errors << node
|
274
|
+
html_errors << new_error(element: e, type: 404, description: e[:tag] + " not exist")
|
271
275
|
end
|
272
276
|
|
273
277
|
end
|
@@ -275,7 +279,6 @@ class CodeTerminator::Html
|
|
275
279
|
end
|
276
280
|
end
|
277
281
|
|
278
|
-
|
279
282
|
html_errors
|
280
283
|
end
|
281
284
|
|
@@ -322,6 +325,17 @@ class CodeTerminator::Html
|
|
322
325
|
end
|
323
326
|
end
|
324
327
|
|
328
|
+
def new_error(args = {})
|
329
|
+
element = args[:element]
|
330
|
+
type = args[:type]
|
331
|
+
description = args[:description]
|
332
|
+
node = Hash.new
|
333
|
+
node[:element] = element
|
334
|
+
node[:type] = type
|
335
|
+
node[:description] = description
|
336
|
+
node
|
337
|
+
end
|
338
|
+
|
325
339
|
#end
|
326
340
|
|
327
341
|
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.3.
|
4
|
+
version: 0.3.2
|
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-08-
|
11
|
+
date: 2016-08-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -42,14 +42,14 @@ dependencies:
|
|
42
42
|
name: minitest
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
description: Helps to evaluate and parse html and css code.
|
@@ -81,6 +81,8 @@ files:
|
|
81
81
|
- code_terminator-0.2.4.gem
|
82
82
|
- code_terminator-0.2.5.gem
|
83
83
|
- code_terminator-0.2.6.gem
|
84
|
+
- code_terminator-0.2.7.gem
|
85
|
+
- code_terminator-0.3.0.gem
|
84
86
|
- code_terminator.gemspec
|
85
87
|
- exe/code_terminator
|
86
88
|
- exercises/new.html
|