rorvswild 1.0.0.pre.alpha → 1.0.0.pre.alpha2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rorvswild/agent.rb +1 -2
- data/lib/rorvswild/location.rb +19 -3
- data/lib/rorvswild/version.rb +1 -1
- data/test/rorvswild_test.rb +8 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b2e54a9c9fc7d9ef4b92bc45f8f0ecbc52105af2
|
4
|
+
data.tar.gz: 7961fe5c7ae2c6feb83cfd5c08e00d73b9cbe4f8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4a38e82f8384ce51edc22282b536047f1f38a3c33cc4e465bbfdf22e81720e928fbce9e8eda575a5e3e8906faa9c113afde036d4955cda6ee3e6b7cf5bdf9989
|
7
|
+
data.tar.gz: bf0b0b27b2e44bd742b6374b351f5736d2cdbc8742346d218cfbd9ecc9da314271c32f69b6a4aeb30efd5bcc5be8e4d185b6871a291c3dc3c1009ac0ab1d8046
|
data/lib/rorvswild/agent.rb
CHANGED
@@ -161,9 +161,8 @@ module RorVsWild
|
|
161
161
|
end
|
162
162
|
|
163
163
|
def exception_to_hash(exception, extra_details = nil)
|
164
|
-
file, line
|
164
|
+
file, line = extract_most_relevant_file_and_line_from_exception(exception)
|
165
165
|
{
|
166
|
-
method: method,
|
167
166
|
line: line.to_i,
|
168
167
|
file: relative_path(file),
|
169
168
|
message: exception.message,
|
data/lib/rorvswild/location.rb
CHANGED
@@ -1,13 +1,29 @@
|
|
1
1
|
module RorVsWild
|
2
2
|
module Location
|
3
|
+
def extract_most_relevant_file_and_line(locations)
|
4
|
+
location = find_most_relevant_location(locations)
|
5
|
+
[relative_path(location.path), location.lineno]
|
6
|
+
end
|
7
|
+
|
3
8
|
def find_most_relevant_location(locations)
|
4
9
|
result = locations.find { |l| l.path.index(app_root) == 0 && !(l.path =~ gem_home_regex) } if app_root
|
5
10
|
result || locations.find { |l| !(l.path =~ gem_home_regex) } || locations.first
|
6
11
|
end
|
7
12
|
|
8
|
-
def
|
9
|
-
|
10
|
-
|
13
|
+
def extract_most_relevant_file_and_line_from_exception(exception)
|
14
|
+
# Exception#backtrace_locations is faster but exists since 2.1.0.
|
15
|
+
# Sometime Exception#backtrace_locations returns nil for an unknow reason. So we fallback to the old way.
|
16
|
+
if exception.respond_to?(:backtrace_locations) && locations = exception.backtrace_locations
|
17
|
+
extract_most_relevant_file_and_line(locations)
|
18
|
+
else
|
19
|
+
extract_most_relevant_file_and_line_from_array_of_strings(exception.backtrace)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def extract_most_relevant_file_and_line_from_array_of_strings(stack)
|
24
|
+
location = stack.find { |str| str =~ app_root_regex && !(str =~ gem_home_regex) } if app_root_regex
|
25
|
+
location ||= stack.find { |str| !(str =~ gem_home_regex) } if gem_home_regex
|
26
|
+
relative_path(location || stack.first).split(":".freeze)
|
11
27
|
end
|
12
28
|
|
13
29
|
def gem_home_regex
|
data/lib/rorvswild/version.rb
CHANGED
data/test/rorvswild_test.rb
CHANGED
@@ -126,6 +126,14 @@ class RorVsWildTest < Minitest::Test
|
|
126
126
|
ENV["GEM_HOME"], ENV["GEM_PATH"] = original_gem_home, original_gem_path
|
127
127
|
end
|
128
128
|
|
129
|
+
def test_extract_most_relevant_file_and_line_from_array_of_strings
|
130
|
+
callstack = ["#{ENV["GEM_HOME"]}/lib/sql.rb:1", "/usr/lib/ruby/net/http.rb:2", "/rails/root/app/models/user.rb:3"]
|
131
|
+
assert_equal(["/app/models/user.rb", "3"], agent.extract_most_relevant_file_and_line_from_array_of_strings(callstack))
|
132
|
+
|
133
|
+
locations = ["#{ENV["GEM_HOME"]}/lib/sql.rb:1"]
|
134
|
+
assert_equal(["#{ENV["GEM_HOME"]}/lib/sql.rb", "1"], agent.extract_most_relevant_file_and_line_from_array_of_strings(locations))
|
135
|
+
end
|
136
|
+
|
129
137
|
private
|
130
138
|
|
131
139
|
def agent
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rorvswild
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.pre.
|
4
|
+
version: 1.0.0.pre.alpha2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Alexis Bernard
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|