snorkel 0.0.4 → 0.0.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/snorkel.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e67409085b19f4a945f6dd9d4e8dfc17a92442fe
|
4
|
+
data.tar.gz: 76eda0fa079c65917b0d49d0a820310b12641d19
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c07b8dd897e3cbb8efd9ba895dac040a4978cb29e1e670ec3f4a430ec0b9a0c5d8a2e727a28fde9c72de4e59d1e9fde3a7c05f59c083db0eed1a91587d59bedb
|
7
|
+
data.tar.gz: f1c44ed923e62f46ad6c25873320e29712bf61215d7dfcc759096d1ed0be1e918ec06973aff37de663e8df85d550be1db8a3935700075ea6a8780ba436c16de2
|
data/lib/snorkel.rb
CHANGED
@@ -4,6 +4,8 @@ require 'colored'
|
|
4
4
|
class ErrorRescue
|
5
5
|
def initialize(file)
|
6
6
|
@file = File.open(file, "rb")
|
7
|
+
@file_name = file
|
8
|
+
@message = nil
|
7
9
|
track_method
|
8
10
|
ask_response
|
9
11
|
end
|
@@ -11,14 +13,22 @@ class ErrorRescue
|
|
11
13
|
def track_method
|
12
14
|
begin
|
13
15
|
eval(@file.read)
|
14
|
-
rescue
|
16
|
+
rescue => ex
|
15
17
|
@message = ex.message
|
18
|
+
@line = ex.backtrace
|
16
19
|
end
|
17
20
|
return if @message == nil
|
18
21
|
end
|
19
22
|
|
23
|
+
def find_line
|
24
|
+
@line.map do |e|
|
25
|
+
e.match(/^(.+?):(\d+)(|:in `(.+)')$/)
|
26
|
+
$2
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
20
30
|
def ask_response
|
21
|
-
puts @message.capitalize.blue
|
31
|
+
puts "On line #{find_line[1]} of #{@file_name}: #{@message.capitalize}".blue
|
22
32
|
puts "Would you like to search your error?"
|
23
33
|
@response = $stdin.gets.chomp
|
24
34
|
launch_search
|
@@ -36,4 +46,3 @@ class ErrorRescue
|
|
36
46
|
end
|
37
47
|
|
38
48
|
|
39
|
-
|