pry-rescue 0.9.pre.1 → 0.9
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/README.md +34 -6
- data/bin/rescue +5 -0
- data/lib/pry-rescue.rb +4 -0
- data/lib/pry-rescue/rails.rb +1 -26
- data/pry-rescue.gemspec +2 -2
- metadata +7 -10
data/README.md
CHANGED
@@ -11,6 +11,19 @@ instead of `ruby`:
|
|
11
11
|
rescue <script.rb> [arguments..]
|
12
12
|
```
|
13
13
|
|
14
|
+
If you're using Rails, you should add `pry-rescue` to the development section of your
|
15
|
+
Gemspec and then run rails server using rescue:
|
16
|
+
|
17
|
+
```
|
18
|
+
rescue rails server
|
19
|
+
```
|
20
|
+
|
21
|
+
If you're using `bundle exec` the rescue should go after the exec:
|
22
|
+
|
23
|
+
```
|
24
|
+
bundle exec rescue rails server
|
25
|
+
```
|
26
|
+
|
14
27
|
If you're using Rack, you should use the middleware instead (though be careful to only
|
15
28
|
include it in development!)
|
16
29
|
```
|
@@ -49,6 +62,19 @@ from examples/example.rb:7:in `rescue in test'
|
|
49
62
|
[1] pry(main)>
|
50
63
|
```
|
51
64
|
|
65
|
+
Finally. If you're doing your own exception handling, you can ask pry to open on an exception that you've caught.
|
66
|
+
For this to work you must be inside a Pry::rescue{ } block.
|
67
|
+
|
68
|
+
```ruby
|
69
|
+
def test
|
70
|
+
raise "foo"
|
71
|
+
rescue => e
|
72
|
+
Pry::rescued(e)
|
73
|
+
end
|
74
|
+
|
75
|
+
Pry::rescue{ test }
|
76
|
+
```
|
77
|
+
|
52
78
|
cd-cause
|
53
79
|
========
|
54
80
|
|
@@ -97,18 +123,20 @@ pry-stack explorer
|
|
97
123
|
==================
|
98
124
|
|
99
125
|
If you're running rubinius, or ruby-1.9, then you can use `pry-rescue` alongside
|
100
|
-
`pry-
|
126
|
+
`pry-stack\_explorer`. This gives you the ability to move `up` or `down` the stack so that
|
101
127
|
you can get a better idea of why your function ended up in a bad state. Run
|
102
128
|
[example2.rb](https://github.com/ConradIrwin/pry-rescue/blob/master/examples/example2.rb) to get a feel for what this is like.
|
103
129
|
|
104
130
|
Known bugs
|
105
131
|
==========
|
106
132
|
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
133
|
+
* ruby 2.0, 1.9.3, 1.9.2 – no known bugs
|
134
|
+
* ruby 1.9.1 — not supported
|
135
|
+
* ruby 1.8.7 — occasional incorrect values for self
|
136
|
+
* ree 1.8.7 — no known bugs
|
137
|
+
* jruby 1.7 (1.8 mode and 1.9 mode) — no known bugs
|
138
|
+
* jruby 1.6 (1.8 mode and 1.9 mode) — incorrect value for self in NoMethodErrors
|
139
|
+
* rbx (1.8 mode and 1.9 mode) – does not catch some low-level errors (e.g. ZeroDivisionError)
|
112
140
|
|
113
141
|
Meta-fu
|
114
142
|
=======
|
data/bin/rescue
CHANGED
data/lib/pry-rescue.rb
CHANGED
@@ -6,6 +6,10 @@ require File.expand_path('../pry-rescue/core_ext', __FILE__)
|
|
6
6
|
require File.expand_path('../pry-rescue/commands', __FILE__)
|
7
7
|
require File.expand_path('../pry-rescue/rack', __FILE__)
|
8
8
|
|
9
|
+
if ENV['PRY_RESCUE_RAILS']
|
10
|
+
require File.expand_path('../pry-rescue/rails', __FILE__)
|
11
|
+
end
|
12
|
+
|
9
13
|
begin
|
10
14
|
require 'pry-stack_explorer'
|
11
15
|
rescue LoadError
|
data/lib/pry-rescue/rails.rb
CHANGED
@@ -1,33 +1,8 @@
|
|
1
1
|
require 'pry-rescue'
|
2
2
|
class PryRescue
|
3
3
|
class Railtie < ::Rails::Railtie
|
4
|
-
|
5
4
|
initializer "pry_rescue" do |app|
|
6
|
-
|
7
|
-
app.config.middleware.use PryRescue::Rack
|
8
|
-
|
9
|
-
if defined?(::ActionDispatch::DebugExceptions)
|
10
|
-
monkeypatch(::ActionDispatch::DebugExceptions)
|
11
|
-
|
12
|
-
elsif defined?(::ActionDispatch::ShowExceptions)
|
13
|
-
monkeypatch(::ActionDispatch::ShowExceptions)
|
14
|
-
|
15
|
-
else
|
16
|
-
raise LoadError, "Sorry, your version of rails is not supported."
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
|
21
|
-
def monkeypatch(middleware)
|
22
|
-
middleware.class_eval do
|
23
|
-
|
24
|
-
def render_exception_with_pry_rescue(env, exception)
|
25
|
-
Pry::rescued(exception)
|
26
|
-
render_exception_without_pry_rescue(env, exception)
|
27
|
-
end
|
28
|
-
|
29
|
-
alias_method_chain :render_exception, :pry_rescue
|
30
|
-
end
|
5
|
+
app.config.middleware.use PryRescue::Rack
|
31
6
|
end
|
32
7
|
end
|
33
8
|
end
|
data/pry-rescue.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |s|
|
2
2
|
s.name = 'pry-rescue'
|
3
|
-
s.version = '0.9
|
3
|
+
s.version = '0.9'
|
4
4
|
s.summary = 'Open a pry session on any unhandled exceptions'
|
5
5
|
s.description = 'Allows you to wrap code in Pry::rescue{ } to open a pry session at any unhandled exceptions'
|
6
6
|
s.homepage = 'https://github.com/ConradIrwin/pry-rescue'
|
@@ -11,7 +11,7 @@ Gem::Specification.new do |s|
|
|
11
11
|
s.executables = ['rescue']
|
12
12
|
|
13
13
|
s.add_dependency 'pry'
|
14
|
-
s.add_dependency 'interception'
|
14
|
+
s.add_dependency 'interception', '>= 0.3'
|
15
15
|
|
16
16
|
s.add_development_dependency 'rspec'
|
17
17
|
s.add_development_dependency 'yard'
|
metadata
CHANGED
@@ -1,13 +1,11 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-rescue
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
prerelease:
|
4
|
+
prerelease: false
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 9
|
8
|
-
|
9
|
-
- 1
|
10
|
-
version: 0.9.pre.1
|
8
|
+
version: "0.9"
|
11
9
|
platform: ruby
|
12
10
|
authors:
|
13
11
|
- Conrad Irwin
|
@@ -41,7 +39,8 @@ dependencies:
|
|
41
39
|
- !ruby/object:Gem::Version
|
42
40
|
segments:
|
43
41
|
- 0
|
44
|
-
|
42
|
+
- 3
|
43
|
+
version: "0.3"
|
45
44
|
type: :runtime
|
46
45
|
version_requirements: *id002
|
47
46
|
- !ruby/object:Gem::Dependency
|
@@ -137,13 +136,11 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
137
136
|
version: "0"
|
138
137
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
139
138
|
requirements:
|
140
|
-
- - "
|
139
|
+
- - ">="
|
141
140
|
- !ruby/object:Gem::Version
|
142
141
|
segments:
|
143
|
-
-
|
144
|
-
|
145
|
-
- 1
|
146
|
-
version: 1.3.1
|
142
|
+
- 0
|
143
|
+
version: "0"
|
147
144
|
requirements: []
|
148
145
|
|
149
146
|
rubyforge_project:
|