jsinstrument 0.0.6 → 0.0.7

Sign up to get free protection for your applications and to get access to all the features.
@@ -17,6 +17,7 @@
17
17
  * mark code line
18
18
  */
19
19
  mark: function(file, lines) {
20
+ file = file.replace(/\./g, '_')
20
21
  if(!this._data[file]) this._data[file] = [];
21
22
  for (var i in lines) {
22
23
  if(!this._data[file][lines[i]]) {
@@ -28,6 +29,7 @@
28
29
  * Hit a line
29
30
  */
30
31
  hit: function(file, line) {
32
+ file = file.replace(/\./g, '_')
31
33
  if(!this._data[file]) this._data[file] = [];
32
34
 
33
35
  if(!this._data[file][line]) this._data[file][line] = 1;
@@ -42,20 +44,14 @@
42
44
  */
43
45
  if(!force && this._uploading) return;
44
46
 
47
+ var self = this;
45
48
  this._uploading = true;
46
49
 
47
50
  try {
48
- $.post('%{upload_url}', this._serialize(this._data, mark)).success(function() {
49
- for (var file in _$jscoverage._data) {
50
- var length = _$jscoverage._data[file].length;
51
- for (var line = 0; line < length; line++) {
52
- var value = _$jscoverage._data[file][line];
53
- if (value === undefined || value === null) continue;
54
- _$jscoverage._data[file][line] = 0;
55
- }
56
- }
57
- }).complete(function() {
58
- _$jscoverage._uploading = false;
51
+ $.post('%{upload_url}', this._serialize(this._data, mark)).done(function() {
52
+ console.log('Coverage data uploaded!');
53
+ }).always(function() {
54
+ self._uploading = false;
59
55
  });
60
56
  } catch (e) {
61
57
  this._uploading = false;
@@ -122,12 +118,6 @@
122
118
  return '0000'.substr(s.length) + s;
123
119
  },
124
120
  };
125
-
126
- // $(document).ready(function() {
127
- // $(window).unload(function (e) {
128
- // _$jscoverage.upload(true);
129
- // });
130
- // });
131
121
  }
132
122
 
133
123
  root.%{js_object_name}.mark('%{src_filename}', %{instrumented_lines});
@@ -1,3 +1,3 @@
1
1
  module JSInstrument
2
- VERSION = "0.0.6"
2
+ VERSION = "0.0.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jsinstrument
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.6
4
+ version: 0.0.7
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: