We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6a75cc5 commit cd0e71aCopy full SHA for cd0e71a
ruby/debug.rb
@@ -0,0 +1,31 @@
1
+require 'irb'
2
+
3
+# source: http://jameskilton.com/2009/04/02/embedding-irb-into-your-ruby-application/
4
+module IRB # :nodoc:
5
+ def self.start_session(binding)
6
+ unless @__initialized
7
+ args = ARGV
8
+ ARGV.replace(ARGV.dup)
9
+ IRB.setup(nil)
10
+ ARGV.replace(args)
11
+ @__initialized = true
12
+ end
13
14
+ workspace = WorkSpace.new(binding)
15
+ irb = Irb.new(workspace)
16
17
+ @CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
18
+ @CONF[:MAIN_CONTEXT] = irb.context
19
20
+ catch(:IRB_EXIT) do
21
+ irb.eval_input
22
23
24
+end
25
26
+def hack(binding)
27
+ IRB.start_session(binding)
28
29
30
+# TODO: get binding without sending it as a parameter
31
+# https://github.com/quix/binding_of_caller
0 commit comments