wbench 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,43 @@
1
+
2
+ /**
3
+ * converted stringify() to jQuery plugin.
4
+ * serializes a simple object to a JSON formatted string.
5
+ * Note: stringify() is different from jQuery.serialize() which URLEncodes form elements
6
+
7
+ * UPDATES:
8
+ * Added a fix to skip over Object.prototype members added by the prototype.js library
9
+ * USAGE:
10
+ * jQuery.ajax({
11
+ * data : {serialized_object : jQuery.stringify (JSON_Object)},
12
+ * success : function (data) {
13
+ *
14
+ * }
15
+ * });
16
+ *
17
+ * CREDITS: http://blogs.sitepointstatic.com/examples/tech/json-serialization/json-serialization.js
18
+ */
19
+ jQuery.extend({
20
+ stringify : function stringify(obj) {
21
+ var t = typeof (obj);
22
+ if (t != "object" || obj === null) {
23
+ // simple data type
24
+ if (t == "string") obj = '"' + obj + '"';
25
+ return String(obj);
26
+ } else {
27
+ // recurse array or object
28
+ var n, v, json = [], arr = (obj && obj.constructor == Array);
29
+
30
+ for (n in obj) {
31
+ v = obj[n];
32
+ t = typeof(v);
33
+ if (obj.hasOwnProperty(n)) {
34
+ if (t == "string") v = '"' + v + '"'; else if (t == "object" && v !== null) v = jQuery.stringify(v);
35
+ json.push((arr ? "" : '"' + n + '":') + String(v));
36
+ }
37
+ }
38
+ return (arr ? "[" : "{") + String(json) + (arr ? "]" : "}");
39
+ }
40
+ }
41
+ });
42
+
43
+
@@ -43,9 +43,10 @@ module WBench
43
43
 
44
44
  directory = File.expand_path(File.dirname(__FILE__)) + '/../javascripts'
45
45
  jquery = File.open(File.join(directory, 'jquery.1.9.1.min.js'))
46
+ stringify = File.open(File.join(directory, 'jquery.stringify.js'))
46
47
  wbench = File.open(File.join(directory, 'wbench.js'))
47
48
 
48
- @script = jquery.read + wbench.read
49
+ @script = jquery.read + stringify.read + wbench.read
49
50
  end
50
51
  end
51
52
  end
@@ -18,7 +18,7 @@ module WBench
18
18
  end
19
19
 
20
20
  def domains
21
- @domains ||= JSON.parse(@browser.evaluate_script('JSON.stringify(resourceURLs())')).map do |url|
21
+ @domains ||= JSON.parse(@browser.evaluate_script('jQuery.stringify(resourceURLs())')).map do |url|
22
22
  URI(url).host
23
23
  end.compact.uniq
24
24
  end
@@ -1,3 +1,3 @@
1
1
  module WBench
2
- VERSION = '0.2.2'
2
+ VERSION = '0.2.3'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wbench
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-02-18 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: capybara
@@ -63,6 +63,7 @@ files:
63
63
  - bin/wbench
64
64
  - example.png
65
65
  - lib/javascripts/jquery.1.9.1.min.js
66
+ - lib/javascripts/jquery.stringify.js
66
67
  - lib/javascripts/wbench.js
67
68
  - lib/wbench.rb
68
69
  - lib/wbench/benchmark.rb