Skip to content

Commit

Permalink
Initial implementation - manually tested
Browse files Browse the repository at this point in the history
  • Loading branch information
parameme committed Aug 27, 2012
1 parent 55b00f4 commit 535a115
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 3 deletions.
5 changes: 5 additions & 0 deletions .powenv
@@ -0,0 +1,5 @@
export POW_WORKERS=1
if [ -f "$rvm_path/scripts/rvm" ] && [ -f ".rvmrc" ]; then
source "$rvm_path/scripts/rvm"
source ".rvmrc"
fi
1 change: 1 addition & 0 deletions .rvmrc
@@ -0,0 +1 @@
rvm use ruby-1.9.3@rubymine_pow --create
14 changes: 14 additions & 0 deletions Gemfile
@@ -0,0 +1,14 @@
source 'http://rubygems.dev' # Use local rubygems proxy/mirror (see https://github.com/maksar/rubygems_proxy )
source :rubygems

group :default do
gem 'sinatra'
#gem 'sinatra-contrib'
end

group :debug do
# Gems required by Rubymine's debugger - download and deploy .gem files into #{APP_ROOT}/vendor/cache
gem 'linecache19', '0.5.13' # http://rubyforge.org/frs/download.php/75414/linecache19-0.5.13.gem
gem 'ruby-debug-base19x', '~> 0.11.30.pre10' # http://rubygems.org/downloads/ruby-debug-base19x-0.11.30.pre10.gem
gem 'ruby-debug-ide', '~> 0.4.17.beta8' # http://rubygems.org/downloads/ruby-debug-ide-0.4.17.beta14.gem
end
35 changes: 35 additions & 0 deletions Gemfile.lock
@@ -0,0 +1,35 @@
GEM
remote: http://rubygems.dev/
remote: http://rubygems.org/
specs:
archive-tar-minitar (0.5.2)
columnize (0.3.6)
linecache19 (0.5.13)
ruby_core_source (>= 0.1.4)
rack (1.4.1)
rack-protection (1.2.0)
rack
rake (0.9.2.2)
ruby-debug-base19x (0.11.30.pre10)
columnize (>= 0.3.1)
linecache19 (>= 0.5.11)
rake (>= 0.8.1)
ruby_core_source (>= 0.1.4)
ruby-debug-ide (0.4.17.beta14)
rake (>= 0.8.1)
ruby_core_source (0.1.5)
archive-tar-minitar (>= 0.5.2)
sinatra (1.3.3)
rack (~> 1.3, >= 1.3.6)
rack-protection (~> 1.2)
tilt (~> 1.3, >= 1.3.3)
tilt (1.3.3)

PLATFORMS
ruby

DEPENDENCIES
linecache19 (= 0.5.13)
ruby-debug-base19x (~> 0.11.30.pre10)
ruby-debug-ide (~> 0.4.17.beta8)
sinatra
45 changes: 42 additions & 3 deletions README.md
@@ -1,4 +1,43 @@
rubymine_pow
============
# Debugging example

Super simple rubymine sinatra pow debugging example
This example project is a super-simple example of how I used

- [Sinatra](http://www.sinatrarb.com/)
- [Pow!](http://pow.cx/)
- [RubyMine](http://www.jetbrains.com/ruby/)

to graphically debug a previous employer's simple web projects

##### Prerequisites:

* Pow installed
* Customized gems installed (see Gemfile for details)

##### Usage

Add example preamble to config.ru of a pow-linked app

`touch tmp/debug.txt`

Load target project in Rubymine and construct a "Configuration" with your project name using the "Remote remote debug" defaults

Ensure an appropriate Rubymine breakpoint is set somewhere in your sinatra app

`touch tmp/restart.txt`

Navigate a browser instance to your pow app's root (should wait - waiting for RubyMine's debugger client to connect)

In Rubymine press "Debug" for the Rubymine "Configuration" you constructed above

Rubymine should then halt on the pow request as required.

Note:
This example assumes the POW_WORKERS variable is set to 1 (one). If multiple workers are active you may get errors that ruby-debug-ide could not attach to a port already in use.

Pow-worker / ruby-debug-ide / Rubymine remote debug client port mappings are therefore left as an exercise to the reader. So to, pow timeout parameters.

##### Lachlan Pitts ([parameme](mailto:github@parameme.com))

- [parameme@github](https://github.com/parameme)
- [@pittlsr](https://twitter.com/pittslr)
- [Ennova](http://ennova.com.au)
7 changes: 7 additions & 0 deletions app.rb
@@ -0,0 +1,7 @@
require 'sinatra'

class App < Sinatra::Base
get '/' do
'Rubymine debugging lives!'
end
end
26 changes: 26 additions & 0 deletions config.ru
@@ -0,0 +1,26 @@
#require 'rubygems' # ASSUMPTION: RUBY_VER > 1.9

require 'bundler'
Bundler.setup

if File.exists?(File.join('tmp','debug.txt'))
require 'ruby-debug-ide'
require 'ostruct'

options = OpenStruct.new(
'frame_bind' => false,
'host' => nil,
'load_mode' => false,
'port' => 1234,
'stop' => false,
'tracing' => false
)

Debugger::PROG_SCRIPT = File.expand_path($0)

# set options
Debugger.debug_program(options)
end

require './app'
run App
4 changes: 4 additions & 0 deletions tmp/.gitignore
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore
4 changes: 4 additions & 0 deletions vendor/cache/.gitignore
@@ -0,0 +1,4 @@
# Ignore everything in this directory
*
# Except this file
!.gitignore

0 comments on commit 535a115

Please sign in to comment.