speed_gun 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b40c0f702aa3870e1ebe8d74a1f3a9eb2a1ca466
4
- data.tar.gz: 738743cbdf2c13d04392d9e994327e7d5ec8adb6
3
+ metadata.gz: 5cf528977aacdbf3ccd15ec92ab77584c15a907d
4
+ data.tar.gz: d46b1fcb2f3a1347479846fb9e958723d147733e
5
5
  SHA512:
6
- metadata.gz: edf1b6096de4f1af119d765f674d4776b79c5646f0039dc17dc0e01cf486797a75eb7b08a6549246e897a0476aec656933f44395bda159069366ffe97a8b41b2
7
- data.tar.gz: 1b6f3b24ea288632ab2d89101f1d9ee3e69b002051c8bff29a96cef42e90a4b64624643a018a4db8ae158f10986a39d0e6729a1d5b47b8473e83c668926f486a
6
+ metadata.gz: 4b27e2f2d0f288178c9c026eaf4ed47ddd9779e5d60d2c88aae99ca831839d8daa0d2c9d06bac204a7b2c1b6270d9336997d7ed9966c33ab6c6bdd17c35d936f
7
+ data.tar.gz: f9114c2faffeeb1d1831e08b05fef6408136389593f1608d8e5531be694737a8e10106b6e9acc3744f0002aeed87b59f40377bc2d4bc72e67bc3049168b61889
@@ -50,16 +50,30 @@ if(!window['speedGun']) { window.speedGun = {}; };
50
50
  };
51
51
 
52
52
  speedGun.send = function(data) {
53
- $.post(speedGun.endpoint, data, function() {});
53
+ if(speedGun.activated) {
54
+ $.post(speedGun.endpoint, data, function() {});
55
+ } else {
56
+ if(!speedGun.queue) { speedGun.queue = [] };
57
+ speedGun.queue.push(data);
58
+ }
54
59
  };
55
60
 
61
+ speedGun.processQueue = function() {
62
+ var queue = speedGun.queue || [];
63
+ for(var i = 0; i < queue.length; i++) {
64
+ speedGun.send(queue[i])
65
+ }
66
+ }
67
+
56
68
  var loadedInterval = setInterval(function() {
57
69
  if (performance.timing.loadEventEnd != 0) {
58
70
  clearInterval(loadedInterval);
59
71
 
60
72
  speedGun.id = $('#speed_gun').data('speed-gun-id');
61
73
  speedGun.endpoint = $('#speed_gun').data('speed-gun-endpoint') + "/" + speedGun.id;
62
- speedGun.sendBrowserInfo()
74
+ speedGun.activated = true;
75
+ speedGun.sendBrowserInfo();
76
+ speedGun.processQueue();
63
77
  }
64
78
  }, 100);
65
79
  })(window['jQuery'] || window['Zepto']);
@@ -50,16 +50,30 @@ if(!window['speedGun']) { window.speedGun = {}; };
50
50
  };
51
51
 
52
52
  speedGun.send = function(data) {
53
- $.post(speedGun.endpoint, data, function() {});
53
+ if(speedGun.activated) {
54
+ $.post(speedGun.endpoint, data, function() {});
55
+ } else {
56
+ if(!speedGun.queue) { speedGun.queue = [] };
57
+ speedGun.queue.push(data);
58
+ }
54
59
  };
55
60
 
61
+ speedGun.processQueue = function() {
62
+ var queue = speedGun.queue || [];
63
+ for(var i = 0; i < queue.length; i++) {
64
+ speedGun.send(queue[i])
65
+ }
66
+ }
67
+
56
68
  var loadedInterval = setInterval(function() {
57
69
  if (performance.timing.loadEventEnd != 0) {
58
70
  clearInterval(loadedInterval);
59
71
 
60
72
  speedGun.id = $('#speed_gun').data('speed-gun-id');
61
73
  speedGun.endpoint = $('#speed_gun').data('speed-gun-endpoint') + "/" + speedGun.id;
62
- speedGun.sendBrowserInfo()
74
+ speedGun.activated = true;
75
+ speedGun.sendBrowserInfo();
76
+ speedGun.processQueue();
63
77
  }
64
78
  }, 100);
65
79
  })(window['jQuery'] || window['Zepto']);
@@ -5,7 +5,7 @@ class SpeedGun::Profiler::Manual < SpeedGun::Profiler::Base
5
5
  'Manual'
6
6
  end
7
7
 
8
- attr_reader :html
8
+ attr_reader :title, :html
9
9
 
10
10
  def before_profile(title, html = '')
11
11
  @title = title
@@ -14,7 +14,11 @@ class SpeedGun::Profiler
14
14
 
15
15
  return nil unless src
16
16
 
17
- data = MessagePack.unpack(src)
17
+ restore(src)
18
+ end
19
+
20
+ def self.restore(src)
21
+ data = src.kind_of?(String) ? MessagePack.unpack(src) : src
18
22
 
19
23
  profiler = new({})
20
24
  profiler.restore_by_hash(data)
@@ -1,3 +1,3 @@
1
1
  module SpeedGun
2
- VERSION = '0.0.1'
2
+ VERSION = '0.0.2'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: speed_gun
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sho Kusano
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-02 00:00:00.000000000 Z
11
+ date: 2013-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler