Module: Mdbe
- Defined in:
- lib/mdbe.rb,
lib/mdbe/halt.rb,
lib/mdbe/version.rb,
lib/mdbe/debug_server.rb
Constant Summary collapse
- VERSION =
'0.1.0'
Class Method Summary collapse
- .application_port ⇒ Object
- .debug_port ⇒ Object
- .debug_storage ⇒ Object
- .ensure_debug_server_running! ⇒ Object
- .eval_object ⇒ Object
-
.full_gem_path ⇒ Object
end.
- .halt(inner_exception = nil) ⇒ Object
- .halted_threads ⇒ Object
- .install_rails_debugger ⇒ Object
- .store_debug_object(obj) ⇒ Object
Class Method Details
.application_port ⇒ Object
19 20 21 |
# File 'lib/mdbe/debug_server.rb', line 19 def self.application_port @application_port ||= Rails::Server.new.[:Port] end |
.debug_port ⇒ Object
14 15 16 17 |
# File 'lib/mdbe/debug_server.rb', line 14 def self.debug_port ensure_debug_server_running! @debug_server.[:Port] end |
.debug_storage ⇒ Object
23 24 25 |
# File 'lib/mdbe.rb', line 23 def debug_storage @debug_storage ||= {} end |
.ensure_debug_server_running! ⇒ Object
2 3 4 5 6 7 8 9 10 11 12 |
# File 'lib/mdbe/debug_server.rb', line 2 def self.ensure_debug_server_running! if not @debug_server @debug_server = Rails::Server.new @debug_server.[:Port] += 1 @debug_server.[:pid] = false Thread.start do @debug_server.start end end end |
.eval_object ⇒ Object
19 20 21 |
# File 'lib/mdbe.rb', line 19 def eval_object @eval_object ||= Object.new end |
.full_gem_path ⇒ Object
end
14 15 16 17 |
# File 'lib/mdbe.rb', line 14 def full_gem_path gem = Gem.loaded_specs["mdbe"] gem.full_gem_path end |
.halt(inner_exception = nil) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/mdbe/halt.rb', line 7 def halt(inner_exception = nil) halt_proc = Proc.new do nil.pause end halt_proc.__call_and_rescue do |eval_result| is_exception = eval_result[0] if is_exception if inner_exception == nil Thread.current.__set_exception(eval_result[1]) else Thread.current.__set_exception(inner_exception) end Thread.current[:is_rails_thread] = true eval_result[1] = Thread.current halted_threads.push(Thread.current) Thread.current[:manual_stop] = true Thread.stop Thread.current[:manual_stop] = false halted_threads.delete(Thread.current) eval_result[1].__exception.__resume else puts "ERROR: expected a Halt. __call_and_rescue not working correctly." Thread.current.__set_exception(nil) end end end |
.halted_threads ⇒ Object
38 39 40 |
# File 'lib/mdbe/halt.rb', line 38 def halted_threads @halted_threads ||= [] end |
.install_rails_debugger ⇒ Object
3 4 5 |
# File 'lib/mdbe/halt.rb', line 3 def install_rails_debugger require "mdbe/action_controller_debug_patch" end |
.store_debug_object(obj) ⇒ Object
27 28 29 |
# File 'lib/mdbe.rb', line 27 def store_debug_object(obj) debug_storage[obj.object_id] = obj end |