ruby-debug-passenger 0.0.1 → 0.1.0
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 +83 -62
- data/lib/ruby-debug-passenger/version.rb +1 -1
- data/lib/ruby-debug-passenger.rb +9 -1
- data/lib/tasks/debug.rake +43 -34
- data/ruby-debug-passenger.gemspec +5 -4
- metadata +7 -6
data/README.md
CHANGED
@@ -1,62 +1,83 @@
|
|
1
|
-
# ruby-debug-passenger
|
2
|
-
|
3
|
-
## Background
|
4
|
-
I wanted to use Phusion Passenger as an Apache module (not standalone) but still
|
5
|
-
be able to use the interactive Ruby debugger.
|
6
|
-
|
7
|
-
Thanks to
|
8
|
-
[Adam Meehan](http://duckpunching.com/passenger-mod_rails-for-development-now-with-debugger)
|
9
|
-
I was able to do that, and I decided to make it into a reusable Gem.
|
10
|
-
|
11
|
-
## Requirements
|
12
|
-
This is been tested on:
|
13
|
-
|
14
|
-
* Rails 3.2.2
|
15
|
-
* Ruby (MRI) 1.9.2
|
16
|
-
* Ruby Debugger 0.11.6
|
17
|
-
* Phusion Passenger 3.0.11
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
```ruby
|
34
|
-
gem "
|
35
|
-
gem "ruby-debug-passenger"
|
36
|
-
```
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
```
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
##
|
62
|
-
|
1
|
+
# ruby-debug-passenger
|
2
|
+
|
3
|
+
## Background
|
4
|
+
I wanted to use Phusion Passenger as an Apache module (not standalone) but still
|
5
|
+
be able to use the interactive Ruby debugger.
|
6
|
+
|
7
|
+
Thanks to
|
8
|
+
[Adam Meehan](http://duckpunching.com/passenger-mod_rails-for-development-now-with-debugger)
|
9
|
+
I was able to do that, and I decided to make it into a reusable Gem.
|
10
|
+
|
11
|
+
## Requirements
|
12
|
+
This is been tested on:
|
13
|
+
|
14
|
+
* Rails 3.2.2
|
15
|
+
* Ruby (MRI) 1.9.2
|
16
|
+
* Old Ruby Debugger 0.11.6
|
17
|
+
* Phusion Passenger 3.0.11
|
18
|
+
|
19
|
+
and
|
20
|
+
|
21
|
+
* Rails 3.0.14
|
22
|
+
* Ruby (MRI) 1.9.3-p125
|
23
|
+
* Debugger gem 1.1.4
|
24
|
+
* Phusion Passenger 3.0.12 and 3.0.13
|
25
|
+
|
26
|
+
It will probably work on other versions, but not on Rails 2.
|
27
|
+
|
28
|
+
It may or may not work on Ruby 1.8.
|
29
|
+
|
30
|
+
## Installation
|
31
|
+
Add this to your `Gemfile` (assuming you are on Ruby 1.9):
|
32
|
+
|
33
|
+
```ruby
|
34
|
+
gem "debugger"
|
35
|
+
gem "ruby-debug-passenger"
|
36
|
+
```
|
37
|
+
|
38
|
+
or use the old ruby-debug gem:
|
39
|
+
|
40
|
+
```ruby
|
41
|
+
gem "ruby-debug19", require: "ruby-debug"
|
42
|
+
gem "ruby-debug-passenger"
|
43
|
+
```
|
44
|
+
|
45
|
+
Or if you're using Ruby 1.8 you can try the following, but it hasn't been tested!
|
46
|
+
|
47
|
+
```ruby
|
48
|
+
gem "ruby-debug"
|
49
|
+
gem "ruby-debug-passenger"
|
50
|
+
```
|
51
|
+
|
52
|
+
Then run `bundle install` to install it.
|
53
|
+
|
54
|
+
## Usage
|
55
|
+
Add `debugger` anywhere in your Ruby code that you want to invoke the debugger.
|
56
|
+
(Or in an ERB template add `<% debugger %>`.)
|
57
|
+
|
58
|
+
Run `rake debug` to restart Phusion Passenger and connect to the debugger. (You
|
59
|
+
will be prompted to reload the app in your browser.)
|
60
|
+
|
61
|
+
## Suggested configuration
|
62
|
+
I recommend putting this in your `~/.rdebugrc`:
|
63
|
+
|
64
|
+
```ruby
|
65
|
+
set autolist
|
66
|
+
set autoeval
|
67
|
+
set autoreload
|
68
|
+
```
|
69
|
+
|
70
|
+
## Recommended reading
|
71
|
+
* [ruby-debug documentation](http://bashdb.sourceforge.net/ruby-debug.html)
|
72
|
+
* [RailsCast #54](http://railscasts.com/episodes/54-debugging-with-ruby-debug)
|
73
|
+
(the setup steps are out of date, but it shows why ruby-debug can be useful)
|
74
|
+
|
75
|
+
## Changelog
|
76
|
+
### 0.1.0
|
77
|
+
* Support for `debugger` gem (Kai Middleton) #1
|
78
|
+
|
79
|
+
### 0.0.1
|
80
|
+
* Initial release
|
81
|
+
|
82
|
+
## License
|
83
|
+
MIT License - see `LICENSE.txt`.
|
data/lib/ruby-debug-passenger.rb
CHANGED
@@ -11,7 +11,15 @@ module RubyDebugPassenger
|
|
11
11
|
# ever run in the development environment (for safety more than anything
|
12
12
|
# else).
|
13
13
|
if Rails.env.development? && File.exists?(File.join(Rails.root, 'tmp', 'debug.txt'))
|
14
|
-
|
14
|
+
begin
|
15
|
+
require 'debugger'
|
16
|
+
rescue LoadError
|
17
|
+
begin
|
18
|
+
require 'ruby-debug'
|
19
|
+
rescue LoadError
|
20
|
+
raise "One of the gems 'debugger' or 'ruby-debug' must be present when using the gem 'ruby-debug-passenger'"
|
21
|
+
end
|
22
|
+
end
|
15
23
|
File.delete(File.join(Rails.root, 'tmp', 'debug.txt'))
|
16
24
|
Debugger.wait_connection = true
|
17
25
|
Debugger.start_remote
|
data/lib/tasks/debug.rake
CHANGED
@@ -1,34 +1,43 @@
|
|
1
|
-
desc "Restart the app with debugging enabled, then launch the debugger"
|
2
|
-
task :debug do
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
rescue Interrupt
|
30
|
-
|
31
|
-
puts "\
|
32
|
-
|
33
|
-
|
34
|
-
|
1
|
+
desc "Restart the app with debugging enabled, then launch the debugger"
|
2
|
+
task :debug do
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'debugger'
|
6
|
+
rescue LoadError
|
7
|
+
begin
|
8
|
+
require 'ruby-debug'
|
9
|
+
rescue LoadError
|
10
|
+
puts "One of the gems 'debugger' or 'ruby-debug' must be present for this task to work"
|
11
|
+
exit 1
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# This instructs the app to wait for the debugger to connect after loading
|
16
|
+
# See config/environments/development.rb
|
17
|
+
FileUtils.touch(File.join(Rails.root, 'tmp', 'debug.txt'))
|
18
|
+
|
19
|
+
# Instruct Phusion Passenger to restart the app
|
20
|
+
FileUtils.touch(File.join(Rails.root, 'tmp', 'restart.txt'))
|
21
|
+
|
22
|
+
# Wait for it to restart (requires the user to load a page)
|
23
|
+
puts "Waiting for restart (please reload the app in your web browser)..."
|
24
|
+
begin
|
25
|
+
while File.exists?(File.join(Rails.root, 'tmp', 'debug.txt'))
|
26
|
+
sleep 0.5
|
27
|
+
end
|
28
|
+
sleep 1
|
29
|
+
rescue Interrupt
|
30
|
+
File.delete(File.join(Rails.root, 'tmp', 'debug.txt'))
|
31
|
+
puts "\rCancelled."
|
32
|
+
exit 1
|
33
|
+
end
|
34
|
+
|
35
|
+
puts "Loading debugger..."
|
36
|
+
begin
|
37
|
+
Debugger.start_client
|
38
|
+
rescue Interrupt
|
39
|
+
# Clear the "^C" that is displayed when you press Ctrl-C
|
40
|
+
puts "\r\e[0KDisconnected."
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -10,10 +10,11 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/davejamesmiller/ruby-debug-passenger"
|
11
11
|
s.summary = %q{Adds a 'rake debug' task to Rails to restart Phusion Passenger with a debugger connected}
|
12
12
|
s.description = <<-EOF
|
13
|
-
Adds an initializer that loads 'ruby-debug' and starts the
|
14
|
-
'rake debug' task that tells Phusion Passenger to restart
|
15
|
-
enabled. This makes it possible to do interactive debugging
|
16
|
-
Phusion Passenger Apache module - it does not require the
|
13
|
+
Adds an initializer that loads 'ruby-debug' or 'debugger' and starts the
|
14
|
+
debugger, and a 'rake debug' task that tells Phusion Passenger to restart
|
15
|
+
with debugging enabled. This makes it possible to do interactive debugging
|
16
|
+
when using the Phusion Passenger Apache module - it does not require the
|
17
|
+
standalone server.
|
17
18
|
EOF
|
18
19
|
s.license = 'MIT'
|
19
20
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-debug-passenger
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,12 +9,13 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-07-01 00:00:00.000000000Z
|
13
13
|
dependencies: []
|
14
|
-
description: ! " Adds an initializer that loads 'ruby-debug'
|
15
|
-
|
16
|
-
\
|
17
|
-
\ Phusion Passenger Apache module - it does not require the
|
14
|
+
description: ! " Adds an initializer that loads 'ruby-debug' or 'debugger' and
|
15
|
+
starts the\n debugger, and a 'rake debug' task that tells Phusion Passenger to
|
16
|
+
restart\n with debugging enabled. This makes it possible to do interactive debugging\n
|
17
|
+
\ when using the Phusion Passenger Apache module - it does not require the\n standalone
|
18
|
+
server.\n"
|
18
19
|
email:
|
19
20
|
- dave@davejamesmiller.com
|
20
21
|
executables: []
|