rack-debug 1.3.1 → 1.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.rdoc CHANGED
@@ -13,9 +13,6 @@ Rails
13
13
 
14
14
  Middleware
15
15
 
16
- # install
17
- $ gem install ddollar-rack-debug
18
-
19
16
  # add a use line to your builder
20
17
  require 'rack/debug'
21
18
  Rack::Builder.new do
@@ -23,6 +20,12 @@ Middleware
23
20
  run MyApp.new
24
21
  end
25
22
 
23
+ # can optionally specify where to put the sockets
24
+ use Rack::Debug, :socket_path => '/tmp/rack-debug'
25
+
26
+ # Rakefile
27
+ require 'rack-debug/tasks'
28
+
26
29
  Add breakpoints to your code
27
30
 
28
31
  @user = User.find(params[:id])
@@ -39,6 +42,9 @@ Debugging:
39
42
  (rdb:1) p @user
40
43
  #<User id: 1, name: "David Dollar", email: "ddollar@gmail.com", created_at: "...", updated_at: "...">
41
44
 
45
+ # can specify the socket path
46
+ SOCKET_PATH=/tmp/rack-debug rake debug
47
+
42
48
  Thanks to:
43
49
 
44
50
  Rack::Bug for a good example of Rack middleware in Rails
data/Rakefile CHANGED
@@ -5,16 +5,16 @@ begin
5
5
  require 'jeweler'
6
6
  Jeweler::Tasks.new do |gem|
7
7
  gem.name = "rack-debug"
8
- gem.summary = %Q{Rack::Debug adds a middlerware interface to ruby-debug}
8
+ gem.summary = %Q{Rack::Debug adds a middleware interface to ruby-debug}
9
9
  gem.description = <<-DESCRIPTION
10
10
 
11
- Rack::Debug adds a middlerware interface to ruby-debug
11
+ Rack::Debug adds a middlerware interface to ruby-debug
12
12
  http://github.com/github/rack-debug
13
13
 
14
14
  DESCRIPTION
15
15
  gem.email = "<ddollar@gmail.com>"
16
16
  gem.homepage = "http://github.com/ddollar/rack-debug"
17
- gem.authors = ["David Dollar"]
17
+ gem.authors = ["David Dollar", "Bart Teeuwisse"]
18
18
 
19
19
  gem.add_dependency 'rack', '>= 1.0'
20
20
  gem.add_dependency 'ruby-debug', '>= 0.10'
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.3.1
1
+ 1.4.1
@@ -4,13 +4,16 @@ require 'thread'
4
4
  require 'fileutils'
5
5
 
6
6
  module Debugger
7
- SOCKET_PATH = File.join(Rails.root, 'tmp', 'sockets', 'debugger')
7
+
8
+ DEFAULT_SOCKET_PATH = File.join(Dir.getwd, 'tmp', 'sockets', 'debugger')
8
9
 
9
10
  class << self
10
- def start_unix_socket_remote(socket_path=SOCKET_PATH, post_mortem = false)
11
+ def start_unix_socket_remote(socket_path, post_mortem = false)
11
12
  return if @thread
12
13
  return if started?
13
14
 
15
+ socket_path ||= DEFAULT_SOCKET_PATH
16
+
14
17
  self.interface = nil
15
18
  start
16
19
  self.post_mortem if post_mortem
@@ -47,9 +50,12 @@ module Debugger
47
50
  end
48
51
  alias_method :start_unix_socket_server, :start_unix_socket_remote
49
52
 
50
- def start_unix_socket_control(socket_path=SOCKET_PATH) # :nodoc:
53
+ def start_unix_socket_control(socket_path) # :nodoc:
51
54
  raise "Debugger is not started" unless started?
52
55
  return if defined?(@control_thread) && @control_thread
56
+
57
+ socket_path ||= DEFAULT_SOCKET_PATH
58
+
53
59
  File.unlink(socket_path) if File.exists?(socket_path)
54
60
  @control_thread = DebugThread.new do
55
61
  server = UNIXServer.open(socket_path)
@@ -61,7 +67,9 @@ module Debugger
61
67
  end
62
68
  end
63
69
 
64
- def start_unix_socket_client(socket_path=SOCKET_PATH)
70
+ def start_unix_socket_client(socket_path)
71
+ socket_path ||= DEFAULT_SOCKET_PATH
72
+
65
73
  require "socket"
66
74
  interface = Debugger::LocalInterface.new
67
75
  socket = UNIXSocket.new(socket_path + '.server')
@@ -8,7 +8,7 @@ task :debug do
8
8
  require File.join(File.dirname(__FILE__), 'debugger')
9
9
 
10
10
  begin
11
- Debugger.start_unix_socket_client
11
+ Debugger.start_unix_socket_client ENV['SOCKET_PATH']
12
12
  rescue Errno::ENOENT
13
13
  puts "Server is not running or Passenger has spooled down"
14
14
  rescue StandardError => ex
data/lib/rack/debug.rb CHANGED
@@ -2,25 +2,29 @@ require 'rack'
2
2
 
3
3
  class Rack::Debug
4
4
 
5
- VERSION = '0.1.0'
6
-
7
- attr_reader :app
5
+ attr_reader :app, :options
8
6
 
9
7
  def initialize(app, options={})
8
+ @app = app
9
+ @options = options
10
+
10
11
  extend_ruby_debug!
11
- @app = app
12
12
  end
13
13
 
14
14
  def call(env)
15
15
  LineCache::clear_file_cache
16
- Debugger.start_unix_socket_remote
16
+ Debugger.start_unix_socket_remote(socket_path)
17
17
  app.call(env)
18
18
  end
19
19
 
20
20
  private ######################################################################
21
21
 
22
22
  def extend_ruby_debug!
23
- require File.join(File.dirname(__FILE__), '..', '..', 'ext', 'debugger')
23
+ require File.join(File.dirname(__FILE__), '..', 'rack-debug', 'debugger')
24
+ end
25
+
26
+ def socket_path
27
+ options[:socket_path]
24
28
  end
25
29
 
26
30
  end
data/rack-debug.gemspec CHANGED
@@ -5,13 +5,13 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rack-debug}
8
- s.version = "1.3.1"
8
+ s.version = "1.4.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["David Dollar"]
12
- s.date = %q{2009-10-21}
11
+ s.authors = ["David Dollar", "Bart Teeuwisse"]
12
+ s.date = %q{2009-11-05}
13
13
  s.description = %q{
14
- Rack::Debug adds a middlerware interface to ruby-debug
14
+ Rack::Debug adds a middlerware interface to ruby-debug
15
15
  http://github.com/github/rack-debug
16
16
 
17
17
  }
@@ -24,19 +24,17 @@ http://github.com/github/rack-debug
24
24
  "README.rdoc",
25
25
  "Rakefile",
26
26
  "VERSION",
27
- "init.rb",
28
27
  "lib/rack-debug.rb",
29
28
  "lib/rack-debug/debugger.rb",
30
29
  "lib/rack-debug/tasks.rb",
31
30
  "lib/rack/debug.rb",
32
- "rack-debug.gemspec",
33
- "tasks/rack-debug.rake"
31
+ "rack-debug.gemspec"
34
32
  ]
35
33
  s.homepage = %q{http://github.com/ddollar/rack-debug}
36
34
  s.rdoc_options = ["--charset=UTF-8"]
37
35
  s.require_paths = ["lib"]
38
36
  s.rubygems_version = %q{1.3.5}
39
- s.summary = %q{Rack::Debug adds a middlerware interface to ruby-debug}
37
+ s.summary = %q{Rack::Debug adds a middleware interface to ruby-debug}
40
38
 
41
39
  if s.respond_to? :specification_version then
42
40
  current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rack-debug
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.1
4
+ version: 1.4.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Dollar
8
+ - Bart Teeuwisse
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
12
 
12
- date: 2009-10-21 00:00:00 -04:00
13
+ date: 2009-11-05 00:00:00 -05:00
13
14
  default_executable:
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
@@ -34,7 +35,7 @@ dependencies:
34
35
  version:
35
36
  description: |+
36
37
 
37
- Rack::Debug adds a middlerware interface to ruby-debug
38
+ Rack::Debug adds a middlerware interface to ruby-debug
38
39
  http://github.com/github/rack-debug
39
40
 
40
41
  email: <ddollar@gmail.com>
@@ -49,13 +50,11 @@ files:
49
50
  - README.rdoc
50
51
  - Rakefile
51
52
  - VERSION
52
- - init.rb
53
53
  - lib/rack-debug.rb
54
54
  - lib/rack-debug/debugger.rb
55
55
  - lib/rack-debug/tasks.rb
56
56
  - lib/rack/debug.rb
57
57
  - rack-debug.gemspec
58
- - tasks/rack-debug.rake
59
58
  has_rdoc: true
60
59
  homepage: http://github.com/ddollar/rack-debug
61
60
  licenses: []
@@ -83,6 +82,6 @@ rubyforge_project:
83
82
  rubygems_version: 1.3.5
84
83
  signing_key:
85
84
  specification_version: 3
86
- summary: Rack::Debug adds a middlerware interface to ruby-debug
85
+ summary: Rack::Debug adds a middleware interface to ruby-debug
87
86
  test_files: []
88
87
 
data/init.rb DELETED
File without changes
@@ -1 +0,0 @@
1
- require 'rack-debug/tasks'