rack-debug 1.0.2 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -0
- data/Rakefile +49 -0
- data/VERSION +1 -0
- data/ext/debugger.rb +89 -0
- data/init.rb +0 -0
- data/lib/rack/debug.rb +7 -0
- data/rack-debug.gemspec +54 -0
- data/tasks/rack-debug.rake +17 -0
- metadata +35 -10
data/.gitignore
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "rack-debug"
|
8
|
+
gem.summary = %Q{Rack::Debug adds a middlerware interface to ruby-debug}
|
9
|
+
gem.description = <<-DESCRIPTION
|
10
|
+
|
11
|
+
Rack::Debug adds a middlerware interface to ruby-debug
|
12
|
+
http://github.com/github/rack-debug
|
13
|
+
|
14
|
+
DESCRIPTION
|
15
|
+
gem.email = "<ddollar@gmail.com>"
|
16
|
+
gem.homepage = "http://github.com/ddollar/rack-debug"
|
17
|
+
gem.authors = ["David Dollar"]
|
18
|
+
gem.add_dependency 'rake', '>= 1.0'
|
19
|
+
gem.add_dependency 'rake', '>= 1.0'
|
20
|
+
end
|
21
|
+
Jeweler::GemcutterTasks.new
|
22
|
+
rescue LoadError
|
23
|
+
puts "Jeweler (or a dependency) not available. Install it with: sudo gem install jeweler"
|
24
|
+
end
|
25
|
+
|
26
|
+
require 'spec/rake/spectask'
|
27
|
+
Spec::Rake::SpecTask.new(:spec) do |spec|
|
28
|
+
spec.libs << 'lib' << 'spec'
|
29
|
+
spec.spec_files = FileList['spec/**/*_spec.rb']
|
30
|
+
end
|
31
|
+
|
32
|
+
Spec::Rake::SpecTask.new(:rcov) do |spec|
|
33
|
+
spec.libs << 'lib' << 'spec'
|
34
|
+
spec.pattern = 'spec/**/*_spec.rb'
|
35
|
+
spec.rcov = true
|
36
|
+
end
|
37
|
+
|
38
|
+
task :spec => :check_dependencies
|
39
|
+
|
40
|
+
task :default => :spec
|
41
|
+
|
42
|
+
begin
|
43
|
+
require 'yard'
|
44
|
+
YARD::Rake::YardocTask.new
|
45
|
+
rescue LoadError
|
46
|
+
task :yardoc do
|
47
|
+
abort "YARD is not available. In order to run yardoc, you must: sudo gem install yard"
|
48
|
+
end
|
49
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.1.0
|
data/ext/debugger.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
require 'ruby-debug'
|
2
|
+
require 'socket'
|
3
|
+
require 'thread'
|
4
|
+
require 'fileutils'
|
5
|
+
|
6
|
+
module Debugger
|
7
|
+
SOCKET_PATH = File.join(Rails.root, 'tmp', 'sockets', 'debugger')
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def start_unix_socket_remote(socket_path=SOCKET_PATH, post_mortem = false)
|
11
|
+
return if @thread
|
12
|
+
return if started?
|
13
|
+
|
14
|
+
self.interface = nil
|
15
|
+
start
|
16
|
+
self.post_mortem if post_mortem
|
17
|
+
|
18
|
+
FileUtils.mkdir_p(File.dirname(socket_path))
|
19
|
+
|
20
|
+
server_path = "#{socket_path}.server"
|
21
|
+
control_path = "#{socket_path}.control"
|
22
|
+
|
23
|
+
start_unix_socket_control(control_path)
|
24
|
+
|
25
|
+
yield if block_given?
|
26
|
+
|
27
|
+
mutex = Mutex.new
|
28
|
+
proceed = ConditionVariable.new
|
29
|
+
|
30
|
+
File.unlink(server_path) if File.exists?(server_path)
|
31
|
+
@thread = DebugThread.new do
|
32
|
+
server = UNIXServer.open(server_path)
|
33
|
+
while (session = server.accept)
|
34
|
+
self.interface = RemoteInterface.new(session)
|
35
|
+
if wait_connection
|
36
|
+
mutex.synchronize do
|
37
|
+
proceed.signal
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
if wait_connection
|
43
|
+
mutex.synchronize do
|
44
|
+
proceed.wait(mutex)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
alias_method :start_unix_socket_server, :start_unix_socket_remote
|
49
|
+
|
50
|
+
def start_unix_socket_control(socket_path=SOCKET_PATH) # :nodoc:
|
51
|
+
raise "Debugger is not started" unless started?
|
52
|
+
return if defined?(@control_thread) && @control_thread
|
53
|
+
File.unlink(socket_path) if File.exists?(socket_path)
|
54
|
+
@control_thread = DebugThread.new do
|
55
|
+
server = UNIXServer.open(socket_path)
|
56
|
+
while (session = server.accept)
|
57
|
+
interface = RemoteInterface.new(session)
|
58
|
+
processor = ControlCommandProcessor.new(interface)
|
59
|
+
processor.process_commands
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def start_unix_socket_client(socket_path=SOCKET_PATH)
|
65
|
+
require "socket"
|
66
|
+
interface = Debugger::LocalInterface.new
|
67
|
+
socket = UNIXSocket.new(socket_path + '.server')
|
68
|
+
puts "Connected."
|
69
|
+
|
70
|
+
catch(:exit) do
|
71
|
+
while (line = socket.gets)
|
72
|
+
case line
|
73
|
+
when /^PROMPT (.*)$/
|
74
|
+
input = interface.read_command($1)
|
75
|
+
throw :exit unless input
|
76
|
+
socket.puts input
|
77
|
+
when /^CONFIRM (.*)$/
|
78
|
+
input = interface.confirm($1)
|
79
|
+
throw :exit unless input
|
80
|
+
socket.puts input
|
81
|
+
else
|
82
|
+
print line
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
socket.close
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
data/init.rb
ADDED
File without changes
|
data/lib/rack/debug.rb
CHANGED
@@ -7,6 +7,7 @@ class Rack::Debug
|
|
7
7
|
attr_reader :app
|
8
8
|
|
9
9
|
def initialize(app, options={})
|
10
|
+
extend_ruby_debug!
|
10
11
|
@app = app
|
11
12
|
end
|
12
13
|
|
@@ -16,4 +17,10 @@ class Rack::Debug
|
|
16
17
|
app.call(env)
|
17
18
|
end
|
18
19
|
|
20
|
+
private ######################################################################
|
21
|
+
|
22
|
+
def extend_ruby_debug!
|
23
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'ext', 'debugger')
|
24
|
+
end
|
25
|
+
|
19
26
|
end
|
data/rack-debug.gemspec
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
# Generated by jeweler
|
2
|
+
# DO NOT EDIT THIS FILE
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run `rake gemspec`
|
4
|
+
# -*- encoding: utf-8 -*-
|
5
|
+
|
6
|
+
Gem::Specification.new do |s|
|
7
|
+
s.name = %q{rack-debug}
|
8
|
+
s.version = "1.1.0"
|
9
|
+
|
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-08-31}
|
13
|
+
s.description = %q{
|
14
|
+
Rack::Debug adds a middlerware interface to ruby-debug
|
15
|
+
http://github.com/github/rack-debug
|
16
|
+
|
17
|
+
}
|
18
|
+
s.email = %q{<ddollar@gmail.com>}
|
19
|
+
s.extra_rdoc_files = [
|
20
|
+
"README.rdoc"
|
21
|
+
]
|
22
|
+
s.files = [
|
23
|
+
".gitignore",
|
24
|
+
"README.rdoc",
|
25
|
+
"Rakefile",
|
26
|
+
"VERSION",
|
27
|
+
"ext/debugger.rb",
|
28
|
+
"init.rb",
|
29
|
+
"lib/rack/debug.rb",
|
30
|
+
"rack-debug.gemspec",
|
31
|
+
"tasks/rack-debug.rake"
|
32
|
+
]
|
33
|
+
s.homepage = %q{http://github.com/ddollar/rack-debug}
|
34
|
+
s.rdoc_options = ["--charset=UTF-8"]
|
35
|
+
s.require_paths = ["lib"]
|
36
|
+
s.rubygems_version = %q{1.3.5}
|
37
|
+
s.summary = %q{Rack::Debug adds a middlerware interface to ruby-debug}
|
38
|
+
|
39
|
+
if s.respond_to? :specification_version then
|
40
|
+
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
41
|
+
s.specification_version = 3
|
42
|
+
|
43
|
+
if Gem::Version.new(Gem::RubyGemsVersion) >= Gem::Version.new('1.2.0') then
|
44
|
+
s.add_runtime_dependency(%q<rake>, [">= 1.0"])
|
45
|
+
s.add_runtime_dependency(%q<rake>, [">= 1.0"])
|
46
|
+
else
|
47
|
+
s.add_dependency(%q<rake>, [">= 1.0"])
|
48
|
+
s.add_dependency(%q<rake>, [">= 1.0"])
|
49
|
+
end
|
50
|
+
else
|
51
|
+
s.add_dependency(%q<rake>, [">= 1.0"])
|
52
|
+
s.add_dependency(%q<rake>, [">= 1.0"])
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
# desc "Explaining what the task does"
|
2
|
+
# task :socket_debugger do
|
3
|
+
# # Task goes here
|
4
|
+
# end
|
5
|
+
|
6
|
+
desc 'Launch the Rack::Debug client'
|
7
|
+
task :debug do
|
8
|
+
require File.join(File.dirname(__FILE__), '..', 'ext', 'debugger')
|
9
|
+
|
10
|
+
begin
|
11
|
+
Debugger.start_unix_socket_client
|
12
|
+
rescue Errno::ENOENT
|
13
|
+
puts "Server is not running or Passenger has spooled down"
|
14
|
+
rescue StandardError => ex
|
15
|
+
puts "Unable to connect to debugging socket: #{ex}"
|
16
|
+
end
|
17
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rack-debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Dollar
|
@@ -9,17 +9,35 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-08-
|
12
|
+
date: 2009-08-31 00:00:00 -04:00
|
13
13
|
default_executable:
|
14
|
-
dependencies:
|
15
|
-
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
type: :runtime
|
18
|
+
version_requirement:
|
19
|
+
version_requirements: !ruby/object:Gem::Requirement
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.0"
|
24
|
+
version:
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: rake
|
27
|
+
type: :runtime
|
28
|
+
version_requirement:
|
29
|
+
version_requirements: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: "1.0"
|
34
|
+
version:
|
16
35
|
description: |+
|
17
36
|
|
18
37
|
Rack::Debug adds a middlerware interface to ruby-debug
|
19
38
|
http://github.com/github/rack-debug
|
20
39
|
|
21
|
-
|
22
|
-
email: ddollar@gmail.com
|
40
|
+
email: <ddollar@gmail.com>
|
23
41
|
executables: []
|
24
42
|
|
25
43
|
extensions: []
|
@@ -27,15 +45,22 @@ extensions: []
|
|
27
45
|
extra_rdoc_files:
|
28
46
|
- README.rdoc
|
29
47
|
files:
|
30
|
-
-
|
48
|
+
- .gitignore
|
31
49
|
- README.rdoc
|
50
|
+
- Rakefile
|
51
|
+
- VERSION
|
52
|
+
- ext/debugger.rb
|
53
|
+
- init.rb
|
54
|
+
- lib/rack/debug.rb
|
55
|
+
- rack-debug.gemspec
|
56
|
+
- tasks/rack-debug.rake
|
32
57
|
has_rdoc: true
|
33
58
|
homepage: http://github.com/ddollar/rack-debug
|
34
59
|
licenses: []
|
35
60
|
|
36
61
|
post_install_message:
|
37
|
-
rdoc_options:
|
38
|
-
|
62
|
+
rdoc_options:
|
63
|
+
- --charset=UTF-8
|
39
64
|
require_paths:
|
40
65
|
- lib
|
41
66
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -52,7 +77,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
52
77
|
version:
|
53
78
|
requirements: []
|
54
79
|
|
55
|
-
rubyforge_project:
|
80
|
+
rubyforge_project:
|
56
81
|
rubygems_version: 1.3.5
|
57
82
|
signing_key:
|
58
83
|
specification_version: 3
|