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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "jserror-rails"
5
- s.version = "0.6.2"
5
+ s.version = "0.6.4"
6
6
  s.authors = ["Jeremy Geros"]
7
7
  s.email = ["jeremy453@gmail.com"]
8
8
  s.homepage = ""
@@ -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
- old_lines = []
23
- new_code_lines = []
21
+ if function
22
+ if function.to_s.count('{') != function.to_s.count('}')
23
+ old_lines = []
24
+ new_code_lines = []
24
25
 
25
- scanning_data = function.post_match
26
- method_line = function.captures.first
26
+ scanning_data = function.post_match
27
+ method_line = function.captures.first
27
28
 
28
- tabs = method_line.partition(method_line.strip[0]).first
29
- name = method_line.match(/(.*) = function/).captures.first.strip
29
+ tabs = method_line.partition(method_line.strip[0]).first
30
+ name = method_line.match(/(.*) = function/).captures.first.strip
30
31
 
31
- arguments = method_line.gsub(tabs, '').gsub(name, '').gsub(/\s*=\s*function\s*\(/, '').gsub(/\)\s*{.*$/, '').strip.split(', ').map {|a| "{#{a}: #{a}}"}
32
+ arguments = method_line.gsub(tabs, '').gsub(name, '').gsub(/\s*=\s*function\s*\(/, '').gsub(/\)\s*{.*$/, '').strip.split(', ').map {|a| "{#{a}: #{a}}"}
32
33
 
33
- new_code_lines << method_line
34
- old_lines << method_line
34
+ new_code_lines << method_line
35
+ old_lines << method_line
35
36
 
36
- new_code_lines << "\n#{tabs}\ttry {"
37
+ new_code_lines << "\n#{tabs}\ttry {"
37
38
 
38
- bracket_count = 1 #start scanning until we find the ending bracket
39
- scanning_data.each_line do |line|
40
- line.chars do |char|
41
- bracket_count += 1 if char == '{'
42
- bracket_count -= 1 if char == '}'
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
- new_code_lines.pop #pop of the last }; to add catch block before closing bracket in function
50
+ new_code_lines.pop #pop of the last }; to add catch block before closing bracket in function
50
51
 
51
- console_line = "javascript_error({name: '#{name.gsub('\'', '"')}',
52
- error_message: e.message,
53
- error_name: e.name,
54
- code_block: '#{old_lines.join('').gsub("\n", '[::n::]').gsub('\'', '')}',
55
- arguments: [#{arguments.join(', ')}],
56
- source: $('*').html()
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
- new_code_lines << "#{tabs}\t} catch (e) { \n#{tabs}\t\t#{console_line}\n#{tabs}\t}\n"
60
- new_code_lines << "#{tabs}};\n"
61
- functions << {:replace => old_lines.join(''), :new => new_code_lines.join('')}
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
- old_lines = []
73
- new_code_lines = []
76
+ if function.to_s.match(/setTimeout/).nil?
77
+ old_lines = []
78
+ new_code_lines = []
74
79
 
75
- scanning_data = function.post_match
76
- method_line = function.captures.first
80
+ scanning_data = function.post_match
81
+ method_line = function.captures.first
77
82
 
78
- tabs = method_line.partition(method_line.strip[0]).first
83
+ tabs = method_line.partition(method_line.strip[0]).first
79
84
 
80
- name = method_line
81
- arguments = (/.*\(.+function\((.*)\).*\{.*$/).match(method_line).captures.first.split(', ').map {|a| "{#{a}: #{a}}"}
85
+ name = method_line
86
+ arguments = (/.*\(.+function\((.*)\).*\{.*$/).match(method_line).captures.first.split(', ').map {|a| "{#{a}: #{a}}"}
82
87
 
83
- new_code_lines << method_line
84
- old_lines << method_line
88
+ new_code_lines << method_line
89
+ old_lines << method_line
85
90
 
86
- new_code_lines << "\n#{tabs}\ttry {"
91
+ new_code_lines << "\n#{tabs}\ttry {"
87
92
 
88
- bracket_count = 1 #start scanning until we find the ending bracket
89
- scanning_data.each_line do |line|
90
- line.chars do |char|
91
- bracket_count += 1 if char == '{'
92
- bracket_count -= 1 if char == '}'
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
- new_code_lines.pop #pop of the last }; to add catch block before closing bracket in function
104
+ new_code_lines.pop #pop of the last }; to add catch block before closing bracket in function
100
105
 
101
- console_line = "javascript_error({name: '#{name.gsub('\'', '"')}',
102
- error_message: e.message,
103
- error_name: e.name,
104
- code_block: '#{old_lines.join('').gsub("\n", '[::n::]').gsub('\'', '')}',
105
- arguments: [#{arguments.join(', ')}],
106
- source: $('*').html()
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
- new_code_lines << "#{tabs}\t} catch (e) { \n#{tabs}\t\t#{console_line}\n#{tabs}\t}\n"
110
- new_code_lines << "#{tabs}});\n"
111
- functions << {:replace => old_lines.join(''), :new => new_code_lines.join('')}
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.2
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-14 00:00:00.000000000Z
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.