irb_drop 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (5) hide show
  1. data/README.markdown +26 -0
  2. data/Rakefile +10 -0
  3. data/irb_drop.gemspec +36 -0
  4. data/lib/irb_drop.rb +44 -0
  5. metadata +48 -0
data/README.markdown ADDED
@@ -0,0 +1,26 @@
1
+ README
2
+ ======
3
+
4
+
5
+ Summary
6
+ -------
7
+ IRB sessions anywhere!
8
+
9
+
10
+ Installation
11
+ ------------
12
+ `gem install irb_drop`
13
+
14
+
15
+ Usage
16
+ -----
17
+ Anywhere in your code, you can just place
18
+
19
+ binding.irb_drop
20
+
21
+ That will drop you into an irb session right there.
22
+
23
+
24
+ Description
25
+ -----------
26
+ Enables you to drop into an IRB session from any code.
data/Rakefile ADDED
@@ -0,0 +1,10 @@
1
+ $LOAD_PATH.unshift(File.expand_path('../rake/lib', __FILE__))
2
+ Dir.glob(File.expand_path('../rake/tasks/**/*.{rake,task,rb}', __FILE__)) do |task_file|
3
+ begin
4
+ import task_file
5
+ rescue LoadError => e
6
+ warn "Failed to load task file #{task_file}"
7
+ warn " #{e.class} #{e.message}"
8
+ warn " #{e.backtrace.first}"
9
+ end
10
+ end
data/irb_drop.gemspec ADDED
@@ -0,0 +1,36 @@
1
+ # encoding: utf-8
2
+
3
+ Gem::Specification.new do |s|
4
+ s.name = "irb_drop"
5
+ s.version = "0.0.1"
6
+ s.authors = "AWD Schweiz"
7
+ s.homepage = "https://github.com/apeiros/irb_drop"
8
+
9
+ s.description = <<-DESCRIPTION.gsub(/^ /, '').chomp
10
+ Enables you to drop into an IRB session from any code.
11
+ DESCRIPTION
12
+ s.summary = <<-SUMMARY.gsub(/^ /, '').chomp
13
+ IRB sessions anywhere!
14
+ SUMMARY
15
+
16
+ s.email = "info@awd.ch"
17
+ s.files =
18
+ Dir['bin/**/*'] +
19
+ Dir['lib/**/*'] +
20
+ Dir['rake/**/*'] +
21
+ Dir['test/**/*'] +
22
+ %w[
23
+ irb_drop.gemspec
24
+ Rakefile
25
+ README.markdown
26
+ ]
27
+
28
+ if File.directory?('bin') then
29
+ executables = Dir.chdir('bin') { Dir.glob('**/*').select { |f| File.executable?(f) } }
30
+ s.executables = executables unless executables.empty?
31
+ end
32
+
33
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1")
34
+ s.rubygems_version = "1.3.1"
35
+ s.specification_version = 3
36
+ end
data/lib/irb_drop.rb ADDED
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+
4
+
5
+ module Kernel
6
+
7
+ # Enables you to drop into an IRB session from any code.
8
+ #
9
+ # @example
10
+ # irb_drop(binding)
11
+ def irb_drop(context=nil, *argv)
12
+ require 'irb'
13
+ require 'pp'
14
+ require 'yaml'
15
+ restore_trap = false
16
+ old_trap = nil
17
+ original_argv = ARGV.dup
18
+ ARGV.replace(argv) # IRB is being stupid
19
+ unless defined? ::IRB_SETUP
20
+ IRB.setup(nil)
21
+ Object.const_set(:IRB_SETUP, true)
22
+ end
23
+ irb = IRB::Irb.new(IRB::WorkSpace.new(context))
24
+ IRB.conf[:IRB_RC].call(irb.context) if IRB.conf[:IRB_RC] # loads the irbrc?
25
+ IRB.conf[:MAIN_CONTEXT] = irb.context # why would the main context be set here?
26
+ restore_trap = old_trap = trap("SIGINT") do irb.signal_handle end
27
+ restore_trap = true
28
+ ARGV.replace(original_argv)
29
+ catch(:IRB_EXIT) do irb.eval_input end
30
+ ensure
31
+ trap("SIGINT", old_trap) if restore_trap
32
+ end
33
+ module_function :irb_drop
34
+ end
35
+
36
+ class Binding
37
+
38
+ # @example
39
+ # binding.irb_drop
40
+ #
41
+ def irb_drop(*argv)
42
+ Kernel.irb_drop(self, *argv)
43
+ end
44
+ end
metadata ADDED
@@ -0,0 +1,48 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: irb_drop
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - AWD Schweiz
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-03-09 00:00:00.000000000Z
13
+ dependencies: []
14
+ description: Enables you to drop into an IRB session from any code.
15
+ email: info@awd.ch
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - lib/irb_drop.rb
21
+ - irb_drop.gemspec
22
+ - Rakefile
23
+ - README.markdown
24
+ homepage: https://github.com/apeiros/irb_drop
25
+ licenses: []
26
+ post_install_message:
27
+ rdoc_options: []
28
+ require_paths:
29
+ - lib
30
+ required_ruby_version: !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
36
+ required_rubygems_version: !ruby/object:Gem::Requirement
37
+ none: false
38
+ requirements:
39
+ - - ! '>'
40
+ - !ruby/object:Gem::Version
41
+ version: 1.3.1
42
+ requirements: []
43
+ rubyforge_project:
44
+ rubygems_version: 1.8.17
45
+ signing_key:
46
+ specification_version: 3
47
+ summary: IRB sessions anywhere!
48
+ test_files: []