pry-rescue 1.1.1 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 60a747dabc7b9f689e6e152f6dc96375ba765301
4
+ data.tar.gz: 8580701fafd6da9467f07d6de7e9c8f31cce95b1
5
+ SHA512:
6
+ metadata.gz: 049f1c260a868d3beb71810d508b2625d6c98e6de8e0302e93de84b478c1c8a32fbb1e04c2670a167f91d086f0c44d5dccb5066f089a092bdd9517f5c9fc950d
7
+ data.tar.gz: 1fc6745f1fd1c7c39ec18fb7521d1cf3c800e6bfb43a936620ae90c723492c64436387f7739d8d9e45af53c664b6b7e6821a91d9ab5cd09c0eaa261ad6b797ab
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - rbx-19mode
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
- source :rubygems
1
+ source 'https://rubygems.org'
2
2
  gemspec
data/README.md CHANGED
@@ -1,11 +1,14 @@
1
- **pry-rescue** - super-fast debugging for ruby. (See [Pry to the
2
- rescue!](http://cirw.in/blog/pry-to-the-rescue))
1
+ # pry-rescue
3
2
 
4
- Introduction
5
- ============
3
+ Super-fast debugging for Ruby. (See [Pry to the rescue!](http://cirw.in/blog/pry-to-the-rescue))
4
+ <a href="https://travis-ci.org/ConradIrwin/pry-rescue">
5
+ <img src="https://secure.travis-ci.org/ConradIrwin/pry-rescue.png?branch=master" alt="Build status">
6
+ </a>
7
+
8
+ ## Introduction
6
9
 
7
10
  pry-rescue is an implementation of "break on unhandled exception" for Ruby. Whenever an
8
- exception is raised, but not rescued, pry-rescue will automatically open pry for you:
11
+ exception is raised, but not rescued, pry-rescue will automatically open Pry for you:
9
12
 
10
13
  ```ruby
11
14
  $ rescue examples/example2.rb
@@ -21,10 +24,9 @@ from /home/conrad/0/ruby/pry-rescue/examples/example2.rb:22:in `gamma`
21
24
  [1] pry(main)>
22
25
  ```
23
26
 
24
- Installation
25
- ============
27
+ ## Installation
26
28
 
27
- You can install `pry-rescue` with rubygems as normal, and I strongly recommend you also
29
+ You can install `pry-rescue` with RubyGems as normal, and I strongly recommend you also
28
30
  install `pry-stack_explorer`. See [Known bugs](#known-bugs) for places that won't work.
29
31
 
30
32
  ```
@@ -40,20 +42,18 @@ group :development do
40
42
  end
41
43
  ```
42
44
 
43
- Usage
44
- =====
45
+ ## Usage
45
46
 
46
- For simple ruby scripts, just run them with the `rescue` executable instead of the `ruby`
47
+ For simple Ruby scripts, just run them with the `rescue` executable instead of the `ruby`
47
48
  executable.
48
49
 
49
50
  ```
50
51
  rescue <script.rb> [arguments..]
51
52
  ```
52
53
 
53
- Rails
54
- -----
54
+ ### Rails
55
55
 
56
- For rails, use `rescue rails` in place of `rails`, for example:
56
+ For Rails, use `rescue rails` in place of `rails`, for example:
57
57
 
58
58
  ```
59
59
  rescue rails server
@@ -65,20 +65,19 @@ If you're using `bundle exec` the rescue should go after the exec:
65
65
  bundle exec rescue rails server
66
66
  ```
67
67
 
68
- Then whenever an unhandled exception happens inside rails, a pry console will open on
69
- stdout. This is the same terminal that you see the rails logs on, so if you're
68
+ Then whenever an unhandled exception happens inside Rails, a Pry console will open on
69
+ stdout. This is the same terminal that you see the Rails logs on, so if you're
70
70
  using something like [pow](https://pow.cx) then you will run into difficulties.
71
71
 
72
72
  You might also be interested in
73
73
  [better_errors](https://github.com/charliesome/better_errors) which opens consoles in your
74
74
  browser on unhandled exceptions, and [pry-rails](https://github.com/rweng/pry-rails) which
75
- adds some rails specific helpers to pry, and replaces `rails console` by pry.
75
+ adds some Rails specific helpers to Pry, and replaces `rails console` by Pry.
76
76
 
77
- Rspec
78
- -----
77
+ ### RSpec
79
78
 
80
79
  If you're using [RSpec](https://rspec.org) or
81
- [respec](https://github.com/oggy/respec), you can open a pry session on
80
+ [respec](https://github.com/oggy/respec), you can open a Pry session on
82
81
  every test failure using `rescue rspec` or `rescue respec`:
83
82
 
84
83
  ```ruby
@@ -101,8 +100,7 @@ Unfortunately using `edit -c` to edit `_spec.rb` files does not yet reload the
101
100
  code in a way that the `try-again` command can understand. You can still use
102
101
  `try-again` if you edit code that is not in spec files.
103
102
 
104
- Minitest
105
- --------
103
+ ### Minitest
106
104
 
107
105
  Add the following to your `test_helper.rb` or to the top of your test file.
108
106
 
@@ -114,8 +112,7 @@ require 'pry-rescue/minitest'
114
112
  Then, when you have a failure, you can use `edit`, `edit -c`, and `edit-method`, then
115
113
  `try-again` to re-run the tests.
116
114
 
117
- Rack
118
- ----
115
+ ### Rack
119
116
 
120
117
  If you're using Rack, you should use the middleware instead (though be careful to only
121
118
  include it in development!):
@@ -124,15 +121,13 @@ include it in development!):
124
121
  use PryRescue::Rack if ENV["RACK_ENV"] == 'development'
125
122
  ```
126
123
 
127
- Pry commands
128
- ============
124
+ ## Pry commands
129
125
 
130
- `pry-rescue` adds two commands to pry. `cd-cause` and `try-again`. In combination with
126
+ `pry-rescue` adds two commands to Pry. `cd-cause` and `try-again`. In combination with
131
127
  `edit --method` these can let you fix the problem with your code and verify that the fix
132
128
  worked without restarting your program.
133
129
 
134
- cd-cause
135
- --------
130
+ ### cd-cause
136
131
 
137
132
  If you've run some code in Pry, and an exception was raised, you can use the `cd-cause`
138
133
  command:
@@ -173,11 +168,10 @@ from examples/example.rb:5:in `test`
173
168
 
174
169
  To get back from `cd-cause` you can either type `<ctrl+d>` or `cd ..`.
175
170
 
176
- try-again
177
- ---------
171
+ ### try-again
178
172
 
179
173
  Once you've used Pry's `edit` or command to fix your code, you can issue a `try-again`
180
- command to re-run your code. For rails and rack, this re-runs the request, for minitest
174
+ command to re-run your code. For Rails and rack, this re-runs the request, for minitest
181
175
  and rspec, it re-runs the current test, for more advanced users this re-runs the
182
176
  `Pry::rescue{ }` block.
183
177
 
@@ -195,11 +189,9 @@ From: examples/example.rb @ line 4 Object#test:
195
189
  foo
196
190
  ```
197
191
 
198
- Advanced usage
199
- ==============
192
+ ## Advanced usage
200
193
 
201
- Block form
202
- ----------
194
+ ### Block form
203
195
 
204
196
  If you want more fine-grained control over which parts of your code are rescued, you can
205
197
  also use the block form:
@@ -233,11 +225,10 @@ from examples/example.rb:7:in `rescue in test`
233
225
  [1] pry(main)>
234
226
  ```
235
227
 
236
- Rescuing an exception
237
- ---------------------
228
+ ### Rescuing an exception
238
229
 
239
- Finally. If you're doing your own exception handling, you can ask pry to open on an exception that you've caught.
240
- For this to work you must be inside a Pry::rescue{ } block.
230
+ Finally. If you're doing your own exception handling, you can ask Pry to open on an exception that you've caught.
231
+ For this to work you must be inside a `Pry::rescue{ }` block.
241
232
 
242
233
  ```ruby
243
234
  def test
@@ -249,14 +240,14 @@ end
249
240
  Pry::rescue{ test }
250
241
 
251
242
  ```
252
- Peeking
253
- =======
243
+
244
+ ## Peeking
254
245
 
255
246
  Sometimes bugs in your program don't cause exceptions. Instead your program just gets
256
247
  stuck. Examples include infinite loops, slow network calls, or tests that take a
257
- suprisingly long time to run.
248
+ surprisingly long time to run.
258
249
 
259
- In this case it's useful to be able to open a pry console when you notice that your
250
+ In this case it's useful to be able to open a Pry console when you notice that your
260
251
  program is not going anywhere. To do this, send your process a `SIGQUIT` using `<ctrl+\>`.
261
252
 
262
253
  ```ruby
@@ -275,12 +266,10 @@ From: ./examples/loop.rb @ line 10 Object#r
275
266
  pry (main)>
276
267
  ```
277
268
 
278
- Advanced peeking
279
- ----------------
269
+ ### Advanced peeking
280
270
 
281
271
  You can configure which signal pry-rescue listens for by default by exporting the
282
- `PRY_PEEK`
283
- environment variable that suits your use-case best:
272
+ `PRY_PEEK` environment variable that suits your use-case best:
284
273
 
285
274
  ```
286
275
  export PRY_PEEK="" # don't autopeek at all
@@ -292,7 +281,7 @@ export PRY_PEEK=EXIT # peek on program exit
292
281
  ```
293
282
 
294
283
  If it's only important for one program, then you can also set the environment variable in
295
- ruby before requiring pry-rescue
284
+ Ruby before requiring pry-rescue:
296
285
 
297
286
  ```ruby
298
287
  ENV['PRY_PEEK'] = '' # disable SIGQUIT handler
@@ -300,7 +289,7 @@ require "pry-rescue"
300
289
  ```
301
290
 
302
291
  Finally, you can enable peeking into programs that do not include pry-rescue by
303
- configuring ruby to always load one (or several) of these files:
292
+ configuring Ruby to always load one (or several) of these files:
304
293
 
305
294
  ```
306
295
  export RUBYOPT=-rpry-rescue/peek/int # peek on SIGINT (<ctrl-c>)
@@ -312,26 +301,24 @@ export RUBYOPT=-rpry-rescue/peek/exit # peek on program exit
312
301
 
313
302
  These last examples relies on having pry-rescue in the load path (i.e. at least in the
314
303
  gemset, or Gemfile of the program). If that is not true, you can use absolute paths. The
315
- hook files do not require the whole of pry-rescue, nor is any of pry itself loaded until
304
+ hook files do not require the whole of pry-rescue, nor is any of Pry itself loaded until
316
305
  you trigger the signal.
317
306
 
318
307
  ```
319
308
  export RUBYOPT=-r/home/cirwin/src/pry-rescue/lib/pry-rescue/peek/usr2
320
309
  ```
321
310
 
322
- Known bugs
323
- ==========
311
+ ## Known bugs
324
312
 
325
- * ruby 2.0, 1.9.3, 1.9.2 – no known bugs
326
- * ruby 1.9.1 — not supported
327
- * ruby 1.8.7 — occasional incorrect values for self
328
- * ree 1.8.7 — no known bugs
329
- * jruby 1.7 (1.8 mode and 1.9 mode) — no known bugs
330
- * jruby 1.6 (1.8 mode and 1.9 mode) — incorrect value for self in NoMethodErrors
331
- * rbx (1.8 mode and 1.9 mode) – does not catch some low-level errors (e.g. ZeroDivisionError)
313
+ * Ruby 2.0, 1.9.3, 1.9.2 – no known bugs
314
+ * Ruby 1.9.1 — not supported
315
+ * Ruby 1.8.7 — occasional incorrect values for self
316
+ * REE 1.8.7 — no known bugs
317
+ * JRuby 1.7 (1.8 mode and 1.9 mode) — no known bugs
318
+ * JRuby 1.6 (1.8 mode and 1.9 mode) — incorrect value for self in NoMethodErrors
319
+ * Rubinius (1.8 mode and 1.9 mode) – does not catch some low-level errors (e.g. ZeroDivisionError)
332
320
 
333
- Meta-fu
334
- =======
321
+ ## Meta-fu
335
322
 
336
323
  Released under the MIT license, see LICENSE.MIT for details. Contributions and bug-reports
337
324
  are welcome.
data/Rakefile CHANGED
@@ -1,3 +1,5 @@
1
+ require 'rspec/core/rake_task'
2
+
1
3
  task :default => :test
2
4
  task :spec => :test
3
5
 
@@ -17,10 +19,7 @@ task :sintax do
17
19
  sh 'bin/rescue examples/syntax-err.rb'
18
20
  end
19
21
 
20
- desc "Run tests"
21
- task :test do
22
- sh 'rspec spec'
23
- end
22
+ RSpec::Core::RakeTask.new(:test)
24
23
 
25
24
  task :build do
26
25
  sh 'gem build *.gemspec'
@@ -33,7 +33,7 @@ class << Pry
33
33
  # end
34
34
  #
35
35
  def rescued(e=$!)
36
- if e.instance_variable_get(:@rescue_bindings)
36
+ if e.instance_variable_defined?(:@rescue_bindings)
37
37
  PryRescue.enter_exception_context(e)
38
38
  else
39
39
  stack = ''
@@ -73,7 +73,7 @@ class << Pry
73
73
  def enable_rescuing!(block=nil)
74
74
  Interception.listen(block) do |exception, binding|
75
75
  bindings = binding.respond_to?(:callers) ? binding.callers : [binding]
76
- unless exception.instance_variable_get(:@rescue_bindings)
76
+ unless exception.instance_variable_defined?(:@rescue_bindings)
77
77
  exception.instance_variable_set(:@rescue_bindings, bindings)
78
78
  exception.instance_variable_set(:@rescue_cause, $!)
79
79
  end
@@ -1,24 +1,45 @@
1
1
  require 'pry-rescue'
2
- # TODO: it should be possible to do all this by simply wrapping
3
- # MiniTest::Unit::TestCase in recent versions of minitest.
4
- # Unfortunately the version of minitest bundled with ruby seems to
5
- # take precedence over the new gem, so we can't do this and still
6
- # support ruby-1.9.3
7
- class MiniTest::Unit::TestCase
8
- alias_method :run_without_rescue, :run
9
-
10
- def run(runner)
11
- Pry::rescue do
12
- run_without_rescue(runner)
2
+
3
+ # Minitest 5 handles all unknown exceptions, so to get them out of
4
+ # minitest, we need to add Exception to its passthrough types
5
+ if defined? Minitest::Test
6
+
7
+ class Minitest::Test
8
+ alias_method :run_without_rescue, :run
9
+
10
+ def run
11
+ Minitest::Test::PASSTHROUGH_EXCEPTIONS << Exception
12
+ Pry::rescue do
13
+ run_without_rescue
14
+ end
13
15
  end
14
16
  end
15
- end
16
17
 
17
- class << MiniTest::Unit.runner; self; end.class_eval do
18
- alias_method :puke_without_rescue, :puke
18
+ else
19
+
20
+ # TODO: it should be possible to do all this by simply wrapping
21
+ # MiniTest::Unit::TestCase in recent versions of minitest.
22
+ # Unfortunately the version of minitest bundled with ruby seems to
23
+ # take precedence over the new gem, so we can't do this and still
24
+ # support ruby-1.9.3
25
+
26
+ class MiniTest::Unit::TestCase
27
+ alias_method :run_without_rescue, :run
19
28
 
20
- def puke(suite, test, e)
21
- Pry::rescued(e)
22
- puke_without_rescue(suite, test, e)
29
+ def run(runner)
30
+ Pry::rescue do
31
+ run_without_rescue(runner)
32
+ end
33
+ end
23
34
  end
35
+
36
+ class << MiniTest::Unit.runner; self; end.class_eval do
37
+ alias_method :puke_without_rescue, :puke
38
+
39
+ def puke(suite, test, e)
40
+ Pry::rescued(e)
41
+ puke_without_rescue(suite, test, e)
42
+ end
43
+ end
44
+
24
45
  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 = '1.1.1'
3
+ s.version = '1.2.0'
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'
@@ -15,6 +15,7 @@ Gem::Specification.new do |s|
15
15
 
16
16
  s.add_development_dependency 'pry-stack_explorer' # upgrade to regular dep?
17
17
 
18
+ s.add_development_dependency 'rake'
18
19
  s.add_development_dependency 'rspec'
19
20
  s.add_development_dependency 'yard'
20
21
  s.add_development_dependency 'redcarpet'
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pry-rescue
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
5
- prerelease:
4
+ version: 1.2.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Conrad Irwin
@@ -11,118 +10,118 @@ authors:
11
10
  autorequire:
12
11
  bindir: bin
13
12
  cert_chain: []
14
- date: 2013-05-10 00:00:00.000000000 Z
13
+ date: 2013-10-28 00:00:00.000000000 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: pry
18
17
  requirement: !ruby/object:Gem::Requirement
19
- none: false
20
18
  requirements:
21
- - - ! '>='
19
+ - - '>='
22
20
  - !ruby/object:Gem::Version
23
21
  version: '0'
24
22
  type: :runtime
25
23
  prerelease: false
26
24
  version_requirements: !ruby/object:Gem::Requirement
27
- none: false
28
25
  requirements:
29
- - - ! '>='
26
+ - - '>='
30
27
  - !ruby/object:Gem::Version
31
28
  version: '0'
32
29
  - !ruby/object:Gem::Dependency
33
30
  name: interception
34
31
  requirement: !ruby/object:Gem::Requirement
35
- none: false
36
32
  requirements:
37
- - - ! '>='
33
+ - - '>='
38
34
  - !ruby/object:Gem::Version
39
35
  version: '0.3'
40
36
  type: :runtime
41
37
  prerelease: false
42
38
  version_requirements: !ruby/object:Gem::Requirement
43
- none: false
44
39
  requirements:
45
- - - ! '>='
40
+ - - '>='
46
41
  - !ruby/object:Gem::Version
47
42
  version: '0.3'
48
43
  - !ruby/object:Gem::Dependency
49
44
  name: pry-stack_explorer
50
45
  requirement: !ruby/object:Gem::Requirement
51
- none: false
52
46
  requirements:
53
- - - ! '>='
47
+ - - '>='
54
48
  - !ruby/object:Gem::Version
55
49
  version: '0'
56
50
  type: :development
57
51
  prerelease: false
58
52
  version_requirements: !ruby/object:Gem::Requirement
59
- none: false
60
53
  requirements:
61
- - - ! '>='
54
+ - - '>='
55
+ - !ruby/object:Gem::Version
56
+ version: '0'
57
+ - !ruby/object:Gem::Dependency
58
+ name: rake
59
+ requirement: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - '>='
62
+ - !ruby/object:Gem::Version
63
+ version: '0'
64
+ type: :development
65
+ prerelease: false
66
+ version_requirements: !ruby/object:Gem::Requirement
67
+ requirements:
68
+ - - '>='
62
69
  - !ruby/object:Gem::Version
63
70
  version: '0'
64
71
  - !ruby/object:Gem::Dependency
65
72
  name: rspec
66
73
  requirement: !ruby/object:Gem::Requirement
67
- none: false
68
74
  requirements:
69
- - - ! '>='
75
+ - - '>='
70
76
  - !ruby/object:Gem::Version
71
77
  version: '0'
72
78
  type: :development
73
79
  prerelease: false
74
80
  version_requirements: !ruby/object:Gem::Requirement
75
- none: false
76
81
  requirements:
77
- - - ! '>='
82
+ - - '>='
78
83
  - !ruby/object:Gem::Version
79
84
  version: '0'
80
85
  - !ruby/object:Gem::Dependency
81
86
  name: yard
82
87
  requirement: !ruby/object:Gem::Requirement
83
- none: false
84
88
  requirements:
85
- - - ! '>='
89
+ - - '>='
86
90
  - !ruby/object:Gem::Version
87
91
  version: '0'
88
92
  type: :development
89
93
  prerelease: false
90
94
  version_requirements: !ruby/object:Gem::Requirement
91
- none: false
92
95
  requirements:
93
- - - ! '>='
96
+ - - '>='
94
97
  - !ruby/object:Gem::Version
95
98
  version: '0'
96
99
  - !ruby/object:Gem::Dependency
97
100
  name: redcarpet
98
101
  requirement: !ruby/object:Gem::Requirement
99
- none: false
100
102
  requirements:
101
- - - ! '>='
103
+ - - '>='
102
104
  - !ruby/object:Gem::Version
103
105
  version: '0'
104
106
  type: :development
105
107
  prerelease: false
106
108
  version_requirements: !ruby/object:Gem::Requirement
107
- none: false
108
109
  requirements:
109
- - - ! '>='
110
+ - - '>='
110
111
  - !ruby/object:Gem::Version
111
112
  version: '0'
112
113
  - !ruby/object:Gem::Dependency
113
114
  name: capybara
114
115
  requirement: !ruby/object:Gem::Requirement
115
- none: false
116
116
  requirements:
117
- - - ! '>='
117
+ - - '>='
118
118
  - !ruby/object:Gem::Version
119
119
  version: '0'
120
120
  type: :development
121
121
  prerelease: false
122
122
  version_requirements: !ruby/object:Gem::Requirement
123
- none: false
124
123
  requirements:
125
- - - ! '>='
124
+ - - '>='
126
125
  - !ruby/object:Gem::Version
127
126
  version: '0'
128
127
  description: Allows you to wrap code in Pry::rescue{ } to open a pry session at any
@@ -138,6 +137,7 @@ extensions: []
138
137
  extra_rdoc_files: []
139
138
  files:
140
139
  - .gitignore
140
+ - .travis.yml
141
141
  - Gemfile
142
142
  - LICENSE.MIT
143
143
  - README.md
@@ -183,27 +183,26 @@ files:
183
183
  - spec/spec_helper.rb
184
184
  homepage: https://github.com/ConradIrwin/pry-rescue
185
185
  licenses: []
186
+ metadata: {}
186
187
  post_install_message:
187
188
  rdoc_options: []
188
189
  require_paths:
189
190
  - lib
190
191
  required_ruby_version: !ruby/object:Gem::Requirement
191
- none: false
192
192
  requirements:
193
- - - ! '>='
193
+ - - '>='
194
194
  - !ruby/object:Gem::Version
195
195
  version: '0'
196
196
  required_rubygems_version: !ruby/object:Gem::Requirement
197
- none: false
198
197
  requirements:
199
- - - ! '>='
198
+ - - '>='
200
199
  - !ruby/object:Gem::Version
201
200
  version: '0'
202
201
  requirements: []
203
202
  rubyforge_project:
204
- rubygems_version: 1.8.23
203
+ rubygems_version: 2.0.3
205
204
  signing_key:
206
- specification_version: 3
205
+ specification_version: 4
207
206
  summary: Open a pry session on any unhandled exceptions
208
207
  test_files: []
209
208
  has_rdoc: