code_terminator 0.3.3 → 0.3.4

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: f351939a093d05861579e853780bc4a84e05f5b6
4
- data.tar.gz: a005665ab611ecdff2bf4291cfb9051c31723baf
3
+ metadata.gz: 1dd44160b32331350392c5d4727b1452a642fd6c
4
+ data.tar.gz: 84ca42ce8d6ea053075fd2641c0f77bec1dfb608
5
5
  SHA512:
6
- metadata.gz: 134a2be5f1108ed22eb31e6f976d83cd67978f9eb20b362bb5d33dbbb07c23bfc0e38f386ab3c50c918a3e5d429b6b228222ad538d935e77cda486ce94baa8f8
7
- data.tar.gz: 674bfded4aa30b42859f9799bfbfff44060fbd6cdae888333ac29f65521837094c102d7fca47429a16f55f7c7292629d48df8d88a1bb75c37a7dcf042c40292a
6
+ metadata.gz: 4dbef31aae5338c9bca035bd29c9cb8793c18048ab9dadbf927d8c662a4473541faca1ada9a66b1a99ba6e73e070b563f332398d5d003bb910ce9c8e7256a61b
7
+ data.tar.gz: 32adf767833ac80b12bc666cedffbe5ad1c1c22890225ff09e880baa92687a23c538367f54c7f7809cffa7ba40e984b7717f4634765bd6e2c97f188d414a13f6
@@ -9,6 +9,9 @@ class CodeTerminator::Css
9
9
  @code = args[:code]
10
10
  @source = args[:source]
11
11
  @tags = Array.new
12
+
13
+ args[:source_type] ||= "file"
14
+ @source_type = args[:source_type]
12
15
  end
13
16
 
14
17
  # Create a CSS file with the code of the editor. Return a boolean that indicate if the file was created or not.
@@ -115,7 +118,12 @@ class CodeTerminator::Css
115
118
  # source: (String)
116
119
 
117
120
  def read_file(source)
118
- fileCss = File.open(source, "r")
121
+ if @source_type == "url"
122
+ fileCss = open(source).read
123
+ else
124
+ fileCss = File.open(source, "r")
125
+ end
126
+
119
127
  text = ""
120
128
  begin
121
129
  fileCss.each_line do |line|
@@ -217,18 +225,18 @@ class CodeTerminator::Css
217
225
  if e[:value]==""
218
226
  property = e[:property] + ": "
219
227
  if parser_property.empty? { |s| s.include?(property) }
220
- css_errors << new_error(element: e, type: 111, description: "not the same property " + property + " in selector " + item)
228
+ css_errors << new_error(element: e, type: 111, description: "Different property " + property + " on selector " + item)
221
229
  end
222
230
  else
223
231
  property = e[:property] + ": " + e[:value]
224
232
  if !parser_property.include?(property)
225
- css_errors << new_error(element: e, type: 111, description: "not the same property " + property + " in selector " + item)
233
+ css_errors << new_error(element: e, type: 111, description: "Different property " + property + " on selector " + item)
226
234
  end
227
235
  end
228
236
 
229
237
  else
230
238
  node = Hash.new
231
- css_errors << new_error(element: e, type: 101, description: "property "+ property + " not found in " + item)
239
+ css_errors << new_error(element: e, type: 101, description: "Property "+ property + " not found on " + item)
232
240
  end
233
241
  end
234
242
  end
@@ -8,6 +8,9 @@ class CodeTerminator::Html
8
8
  @source = args[:source]
9
9
  @tags = Array.new
10
10
  @elements = Array.new
11
+
12
+ args[:source_type] ||= "file"
13
+ @source_type = args[:source_type]
11
14
  end
12
15
 
13
16
  # Create a Html file with the code of the editor. Return a boolean that indicate if the file was created or not.
@@ -46,7 +49,11 @@ class CodeTerminator::Html
46
49
 
47
50
  def get_elements(source)
48
51
  @elements = Array.new
49
- reader = Nokogiri::HTML(File.open(source))
52
+ if @source_type == "url"
53
+ reader = Nokogiri::HTML(open(source).read)
54
+ else
55
+ reader = Nokogiri::HTML(File.open(source))
56
+ end
50
57
  reader = remove_empty_text(reader)
51
58
  reader.at('body').attribute_nodes.each do |element_attribute|
52
59
  node[:parent] = "html"
@@ -125,7 +132,12 @@ class CodeTerminator::Html
125
132
  # source: (String)
126
133
 
127
134
  def read_file(source)
128
- fileHtml = File.open(source, "r")
135
+ if @source_type == "url"
136
+ fileHtml = open(source).read
137
+ else
138
+ fileHtml = File.open(source, "r")
139
+ end
140
+
129
141
  text = ""
130
142
  begin
131
143
  fileHtml.each_line do |line|
@@ -244,17 +256,17 @@ class CodeTerminator::Html
244
256
 
245
257
  if !e[:attribute].nil?
246
258
  if code.css(e[:tag]).attribute(e[:attribute]).nil?
247
- html_errors << new_error(element: e, type: 334, description: e[:attribute] + " not exist in " + e[:tag])
259
+ html_errors << new_error(element: e, type: 334, description: e[:attribute] + " didn't exist in " + e[:tag])
248
260
  else
249
261
  if code.css(e[:tag]).attribute(e[:attribute]).value != e[:value]
250
- html_errors << new_error(element: e, type: 333, description: e[:attribute] + " not is the same value " + e[:value])
262
+ html_errors << new_error(element: e, type: 333, description: e[:attribute] + " isn't the same value " + e[:value])
251
263
  end
252
264
  end
253
265
  end
254
266
 
255
267
  if code.css(e[:tag]).count < 2
256
268
  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])
269
+ html_errors << new_error(element: e, type: 440, description: e[:tag] + " didn't exist in " + e[:parent])
258
270
  end
259
271
  else
260
272
  exist_in_parent = false
@@ -264,14 +276,14 @@ class CodeTerminator::Html
264
276
  end
265
277
  end
266
278
  if !exist_in_parent
267
- html_errors << new_error(element: e, type: 440, description: e[:tag] + " not exist in " + e[:parent])
279
+ html_errors << new_error(element: e, type: 440, description: e[:tag] + " didn't exist in " + e[:parent])
268
280
  end
269
281
  end
270
282
 
271
283
  else
272
284
 
273
285
  if code.at_css(e[:tag]).nil?
274
- html_errors << new_error(element: e, type: 404, description: e[:tag] + " not exist")
286
+ html_errors << new_error(element: e, type: 404, description: e[:tag] + " didn't exist")
275
287
  end
276
288
 
277
289
  end
@@ -1,3 +1,3 @@
1
1
  module CodeTerminator
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.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.3.3
4
+ version: 0.3.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: 2016-09-15 00:00:00.000000000 Z
11
+ date: 2016-09-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler