snorkel 0.0.5 → 0.0.6
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.
- checksums.yaml +4 -4
- data/lib/snorkel.rb +16 -8
- 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: c6a66320c6a87e7c3add5bd6fba739b0bc02a4eb
|
4
|
+
data.tar.gz: dffc797231ed6c1606999f5a0c915a42008906fc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d7937ab12717ba91efe35ddc069b3770475f9bce9e1fbfd10cc21b56e7c41b953f0aaa51de90d3e5563d76b521b17e56b5cb09a601c47dc60cd06439572cfd69
|
7
|
+
data.tar.gz: 277fed12feb129a063533cb953a916f7ee2a17c9168bea458d69a34da23de7727b48d9d6d24bf4bc54ff8bc7328db32ac87deee7a9354bd760b5e9b9d96c2a6b
|
data/lib/snorkel.rb
CHANGED
@@ -3,14 +3,24 @@ require 'colored'
|
|
3
3
|
|
4
4
|
class ErrorRescue
|
5
5
|
def initialize(file)
|
6
|
-
|
6
|
+
exit unless is_ruby?(file)
|
7
7
|
@file_name = file
|
8
|
+
@file = File.open(file, "rb")
|
8
9
|
@message = nil
|
9
|
-
|
10
|
+
track_code
|
10
11
|
ask_response
|
11
12
|
end
|
12
13
|
|
13
|
-
def
|
14
|
+
def is_ruby?(file)
|
15
|
+
if file[-3..-1] != ".rb"
|
16
|
+
puts "You can only go snorkeling with Ruby!"
|
17
|
+
false
|
18
|
+
else
|
19
|
+
true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def track_code
|
14
24
|
begin
|
15
25
|
eval(@file.read)
|
16
26
|
rescue => ex
|
@@ -30,13 +40,12 @@ class ErrorRescue
|
|
30
40
|
def ask_response
|
31
41
|
puts "On line #{find_line[1]} of #{@file_name}: #{@message.capitalize}".blue
|
32
42
|
puts "Would you like to search your error?"
|
33
|
-
|
34
|
-
launch_search
|
43
|
+
launch_search($stdin.gets.chomp)
|
35
44
|
end
|
36
45
|
|
37
|
-
def launch_search
|
46
|
+
def launch_search(response)
|
38
47
|
new_message = @message.split(" ").join("+").downcase
|
39
|
-
if
|
48
|
+
if response.start_with? 'y'
|
40
49
|
Launchy.open("https://www.google.com/#q=#{new_message}+ruby")
|
41
50
|
else
|
42
51
|
puts "Have a nice day!"
|
@@ -45,4 +54,3 @@ class ErrorRescue
|
|
45
54
|
|
46
55
|
end
|
47
56
|
|
48
|
-
|