jserror-rails 0.6.2 → 0.6.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.
- data/jserror-rails.gemspec +1 -1
- data/lib/jserror-rails/jserror_template.rb +69 -61
- metadata +2 -2
data/jserror-rails.gemspec
CHANGED
@@ -18,47 +18,51 @@ module JserrorRails
|
|
18
18
|
capture = true
|
19
19
|
while capture
|
20
20
|
function = (/(^.*= function.*$)/).match(scanning_data)
|
21
|
-
if function
|
22
|
-
|
23
|
-
|
21
|
+
if function
|
22
|
+
if function.to_s.count('{') != function.to_s.count('}')
|
23
|
+
old_lines = []
|
24
|
+
new_code_lines = []
|
24
25
|
|
25
|
-
|
26
|
-
|
26
|
+
scanning_data = function.post_match
|
27
|
+
method_line = function.captures.first
|
27
28
|
|
28
|
-
|
29
|
-
|
29
|
+
tabs = method_line.partition(method_line.strip[0]).first
|
30
|
+
name = method_line.match(/(.*) = function/).captures.first.strip
|
30
31
|
|
31
|
-
|
32
|
+
arguments = method_line.gsub(tabs, '').gsub(name, '').gsub(/\s*=\s*function\s*\(/, '').gsub(/\)\s*{.*$/, '').strip.split(', ').map {|a| "{#{a}: #{a}}"}
|
32
33
|
|
33
|
-
|
34
|
-
|
34
|
+
new_code_lines << method_line
|
35
|
+
old_lines << method_line
|
35
36
|
|
36
|
-
|
37
|
+
new_code_lines << "\n#{tabs}\ttry {"
|
37
38
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
39
|
+
bracket_count = 1 #start scanning until we find the ending bracket
|
40
|
+
scanning_data.each_line do |line|
|
41
|
+
line.chars do |char|
|
42
|
+
bracket_count += 1 if char == '{'
|
43
|
+
bracket_count -= 1 if char == '}'
|
44
|
+
end
|
45
|
+
new_code_lines << "\t" + line
|
46
|
+
old_lines << line
|
47
|
+
break if bracket_count <= 0
|
43
48
|
end
|
44
|
-
new_code_lines << "\t" + line
|
45
|
-
old_lines << line
|
46
|
-
break if bracket_count <= 0
|
47
|
-
end
|
48
49
|
|
49
|
-
|
50
|
+
new_code_lines.pop #pop of the last }; to add catch block before closing bracket in function
|
50
51
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
52
|
+
console_line = "javascript_error({name: '#{name.gsub('\'', '"')}',
|
53
|
+
error_message: e.message,
|
54
|
+
error_name: e.name,
|
55
|
+
code_block: '#{old_lines.join('').gsub("\n", '[::n::]').gsub('\'', '')}',
|
56
|
+
arguments: [#{arguments.join(', ')}],
|
57
|
+
source: $('*').html()
|
58
|
+
});"
|
58
59
|
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
new_code_lines << "#{tabs}\t} catch (e) { \n#{tabs}\t\t#{console_line}\n#{tabs}\t}\n"
|
61
|
+
new_code_lines << "#{tabs}};\n"
|
62
|
+
functions << {:replace => old_lines.join(''), :new => new_code_lines.join('')}
|
63
|
+
else
|
64
|
+
scanning_data = function.post_match
|
65
|
+
end
|
62
66
|
else
|
63
67
|
capture = false
|
64
68
|
end
|
@@ -69,46 +73,50 @@ module JserrorRails
|
|
69
73
|
while capture
|
70
74
|
function = (/(.*\(.+function\(.*\).*\{.*$)/).match(scanning_data)
|
71
75
|
if function
|
72
|
-
|
73
|
-
|
76
|
+
if function.to_s.match(/setTimeout/).nil?
|
77
|
+
old_lines = []
|
78
|
+
new_code_lines = []
|
74
79
|
|
75
|
-
|
76
|
-
|
80
|
+
scanning_data = function.post_match
|
81
|
+
method_line = function.captures.first
|
77
82
|
|
78
|
-
|
83
|
+
tabs = method_line.partition(method_line.strip[0]).first
|
79
84
|
|
80
|
-
|
81
|
-
|
85
|
+
name = method_line
|
86
|
+
arguments = (/.*\(.+function\((.*)\).*\{.*$/).match(method_line).captures.first.split(', ').map {|a| "{#{a}: #{a}}"}
|
82
87
|
|
83
|
-
|
84
|
-
|
88
|
+
new_code_lines << method_line
|
89
|
+
old_lines << method_line
|
85
90
|
|
86
|
-
|
91
|
+
new_code_lines << "\n#{tabs}\ttry {"
|
87
92
|
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
+
bracket_count = 1 #start scanning until we find the ending bracket
|
94
|
+
scanning_data.each_line do |line|
|
95
|
+
line.chars do |char|
|
96
|
+
bracket_count += 1 if char == '{'
|
97
|
+
bracket_count -= 1 if char == '}'
|
98
|
+
end
|
99
|
+
new_code_lines << "\t" + line
|
100
|
+
old_lines << line
|
101
|
+
break if bracket_count <= 0
|
93
102
|
end
|
94
|
-
new_code_lines << "\t" + line
|
95
|
-
old_lines << line
|
96
|
-
break if bracket_count <= 0
|
97
|
-
end
|
98
103
|
|
99
|
-
|
104
|
+
new_code_lines.pop #pop of the last }; to add catch block before closing bracket in function
|
100
105
|
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
106
|
+
console_line = "javascript_error({name: '#{name.gsub('\'', '"')}',
|
107
|
+
error_message: e.message,
|
108
|
+
error_name: e.name,
|
109
|
+
code_block: '#{old_lines.join('').gsub("\n", '[::n::]').gsub('\'', '')}',
|
110
|
+
arguments: [#{arguments.join(', ')}],
|
111
|
+
source: $('*').html()
|
112
|
+
});"
|
108
113
|
|
109
|
-
|
110
|
-
|
111
|
-
|
114
|
+
new_code_lines << "#{tabs}\t} catch (e) { \n#{tabs}\t\t#{console_line}\n#{tabs}\t}\n"
|
115
|
+
new_code_lines << "#{tabs}});\n"
|
116
|
+
functions << {:replace => old_lines.join(''), :new => new_code_lines.join('')}
|
117
|
+
else
|
118
|
+
scanning_data = function.post_match
|
119
|
+
end
|
112
120
|
else
|
113
121
|
capture = false
|
114
122
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jserror-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.4
|
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: 2012-05-
|
12
|
+
date: 2012-05-22 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
14
|
description: Adds try catch around all functions to allow better error debugging in
|
15
15
|
javascript.
|