red-glass 0.1.4 → 0.1.5

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: 1981fbf8ec724074b636362a35c8e0ce01b6ef16
4
- data.tar.gz: 0d4101faeb1934eb0f63010f30b7c72d1955299f
3
+ metadata.gz: ab67587fe9749012ed0825735e13d059eba0d9a5
4
+ data.tar.gz: 2d9dbf7cf256413425e8b90e9ed8e6a6cb150347
5
5
  SHA512:
6
- metadata.gz: 9625acd8842cff9c1641f72a3b1346a103aa09413a24e6ccca2a5161cd610788615429567af5eb7ba44571e7c94140a1d67aa475606c4bc2ab3a6e6fcc495e34
7
- data.tar.gz: 342726e2f00e12f2ca70036f7ee317e7707177ddd6c07f0dbee5e96dba8c27c564a1394d48148cd2f74964de29aa7c592642cd6741523b6ba091114e44e4a2b7
6
+ metadata.gz: 422a44f794b1dcecdfc53eac1bbff98d15689d13c4e433ae1b48cba4d17d0a00d7b5dd680e1950ec5857ea3deaf1464da22ab70941286f297caa4ab0564c8794
7
+ data.tar.gz: 13d73d497b2125d1eea8272ccb1d08d47e7fe5da0885da4ba4d86d1ac736f8030c3391564a816fd33a5713989845f2534c4f737a4caa047ee865984b5db366cc
@@ -160,21 +160,12 @@ class RedGlass
160
160
  end
161
161
 
162
162
  def serialize_dom
163
- dom_json_string = "{\n\t\"browser\":" + "\"" + @page_metadata[:browser][:name] + "\","
164
- dom_json_string += "\n\t\"elements\":\n\t[\n\t"
165
- serialize_dom_js_string = stringify_serialize_dom_js
166
- dom_json_string += @driver.execute_script(serialize_dom_js_string + " return RecurseDomJSON(rgUtils.query('*'),'')")
167
- dom_json_string = dom_json_string[0, (dom_json_string.length - 3)] + "\n\t]\n}"
168
- @page_metadata[:doc_width] = @driver.execute_script(serialize_dom_js_string + ' return rgUtils.query(document).width()')
169
- @page_metadata[:doc_height] = @driver.execute_script(serialize_dom_js_string + ' return rgUtils.query(document).height()')
170
- write_serialized_dom dom_json_string
171
- end
172
-
173
- def stringify_serialize_dom_js
174
- recurse_dom_file = File.open("#{PROJ_ROOT}/red-glass-js/serialize-dom.js", 'rb')
175
- recurse_dom_string = recurse_dom_file.read
176
- recurse_dom_file.close
177
- recurse_dom_string
163
+ dom = JSON.parse(@driver.execute_script("return JSON.stringify(jQuery(document).redGlass('serializeDOM'));"),
164
+ { symbolize_names: true })
165
+ dom[:browser] = @page_metadata[:browser][:name]
166
+ @page_metadata[:doc_width] = dom[:width]
167
+ @page_metadata[:doc_height] = dom[:height]
168
+ write_serialized_dom(dom.to_json)
178
169
  end
179
170
 
180
171
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: red-glass
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Frank O'Hara
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-02-04 00:00:00.000000000 Z
11
+ date: 2014-09-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sinatra
@@ -200,7 +200,6 @@ files:
200
200
  - lib/red-glass/red-glass-app/server.key
201
201
  - lib/red-glass/red-glass-app/views/index.erb
202
202
  - lib/red-glass/red-glass-js/redglass.carryall.js
203
- - lib/red-glass/red-glass-js/serialize-dom.js
204
203
  - lib/red-glass/red_glass.rb
205
204
  - lib/red-glass/red_glass_listener.rb
206
205
  homepage: https://github.com/fohara/red-glass
@@ -1,30 +0,0 @@
1
- var rgUtils = {};
2
- var uniqueIds = [];
3
- rgUtils.query = jQuery;
4
- rgUtils.toInt = function(n){ return Math.round(Number(n)); };
5
- rgUtils.hasText = function($thing){
6
- var isTxt = true;
7
- if($thing.text() == ""){
8
- isTxt = false;
9
- }
10
- return isTxt;
11
- };
12
- rgUtils.isVisible = function($thing) { return $thing.is(':visible'); };
13
-
14
- function RecurseDomJSON($item, domJSON) {
15
- $item.each(function() {
16
- try{
17
- domJSON += '{"tagName":' + '"' + rgUtils.query(this).get(0).tagName + '"' + ',' + '"id":' + '"' +
18
- rgUtils.query(this).attr("id") + '"' + ',' + '"top":' + '"' + rgUtils.toInt(rgUtils.query(this).offset().top) + '"' +
19
- ',' + '"left":' + '"' + rgUtils.toInt(rgUtils.query(this).offset().left) + '"' +
20
- ',' + '"xpath":' + '"' + rgUtils.query(this).ellocate(uniqueIds).xpath + '"' +
21
- ',' + '"width":' + '"' + rgUtils.toInt(rgUtils.query(this).width()) + '"' +
22
- ',' + '"height":' + '"' + rgUtils.toInt(rgUtils.query(this).height()) + '"' +
23
- ',' + '"isVisible":' + '"' + rgUtils.isVisible(rgUtils.query(this)) + '"' +
24
- ',' + '"hasText":' + '"' + rgUtils.hasText(rgUtils.query(this)) +'"},\n\t' ;
25
- }
26
- catch(err){ } // Perhaps errors could be thrown in a configurable "strict" mode.
27
- });
28
- uniqueIds = [];
29
- return domJSON;
30
- }