binding.repl 0.1.0
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.
- data/.gitignore +17 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +22 -0
- data/README.md +70 -0
- data/Rakefile +1 -0
- data/binding.repl.gemspec +21 -0
- data/lib/binding.repl.rb +58 -0
- metadata +88 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013 Robert Gleeson
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,70 @@
|
|
1
|
+
| Project | binding.repl
|
2
|
+
|:----------------|:--------------------------------------------------
|
3
|
+
| Homepage | https://github.com/robgleeson/binding.repl
|
4
|
+
| Documentation | http://rubydoc.info/github/robgleeson/binding.repl
|
5
|
+
| CI | [](https://travis-ci.org/robgleeson/binding.repl)
|
6
|
+
| Author | Robert Gleeson
|
7
|
+
|
8
|
+
__DESCRIPTION__
|
9
|
+
|
10
|
+
__binding.repl__ can start a number of different ruby consoles at runtime.
|
11
|
+
IRB, ripl, and Pry(of course!) can be invoked at runtime in any context
|
12
|
+
that an instance of `Binding` closes over.
|
13
|
+
|
14
|
+
I owe all credit to John Mair([banisterfiend](https://github.com/banister)),
|
15
|
+
the creator of Pry, for seeing the potential in a console that can be
|
16
|
+
started at runtime and bound to the context of a `Binding`. I don't
|
17
|
+
think a single ruby console has put as much emphasize on a console
|
18
|
+
that be invoked at runtime as Pry has.
|
19
|
+
|
20
|
+
the interface to invoke Pry at runtime is very accessible and easy to
|
21
|
+
use but if you look at other ruby console implementations you might find
|
22
|
+
the eval() of code is the same. It happens through `Binding#eval` which
|
23
|
+
closes over a context(maybe the context is "Foo", a class, or an
|
24
|
+
instance of "Foo").
|
25
|
+
|
26
|
+
__binding.repl__ provides the same `binding.pry` interface to all ruby
|
27
|
+
consoles (if I missed one, open an issue or send an e-note :)).
|
28
|
+
|
29
|
+
__EXAMPLES__
|
30
|
+
|
31
|
+
```ruby
|
32
|
+
class Foo
|
33
|
+
binding.repl.pry # invoke pry in context of "Foo"
|
34
|
+
binding.repl.ripl # invoke ripl in context of "Foo"
|
35
|
+
binding.repl.irb # invoke irb in context of "Foo"
|
36
|
+
end
|
37
|
+
|
38
|
+
class BlogsController < ActionController::Base
|
39
|
+
def index
|
40
|
+
@blog = Blog.find(params[:id])
|
41
|
+
binding.repl.{pry,irb,ripl}
|
42
|
+
end
|
43
|
+
end
|
44
|
+
```
|
45
|
+
|
46
|
+
__CREDIT__
|
47
|
+
|
48
|
+
- [banisterfiend](https://github.com/banister) (John Mair)
|
49
|
+
for pry
|
50
|
+
|
51
|
+
- [Kyrylo](https://github.com/kyrylo) (Kyrylo Silin)
|
52
|
+
for his hard work on pry.
|
53
|
+
|
54
|
+
Rest of the Pry team(!!):
|
55
|
+
|
56
|
+
- [cirwin](https://github.com/conradirwin), Conrad Irwin.
|
57
|
+
- [ryanf](https://github.com/ryanf), Ryan Fitzgerald.
|
58
|
+
- [rking](https://github.com/rking), "rking", on adventures outside programming now.
|
59
|
+
|
60
|
+
__LICENSE__
|
61
|
+
|
62
|
+
MIT.
|
63
|
+
|
64
|
+
__CONTRIBUTING__
|
65
|
+
|
66
|
+
1. Fork it
|
67
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
68
|
+
3. Commit your changes (`git commit -am 'Add some feature'`)
|
69
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
70
|
+
5. Create a new E-Note
|
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
require "./lib/binding.repl"
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "binding.repl"
|
5
|
+
spec.version = Binding.repl.version
|
6
|
+
spec.authors = ["Robert Gleeson"]
|
7
|
+
spec.email = ["rob@flowof.info"]
|
8
|
+
spec.description = "binding.repl provides the same binding.pry interface to all ruby consoles"
|
9
|
+
spec.summary = "binding.repl provides the same binding.pry interface to all ruby consoles"
|
10
|
+
spec.homepage = ""
|
11
|
+
spec.license = "MIT"
|
12
|
+
|
13
|
+
spec.files = `git ls-files`.split($/)
|
14
|
+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
15
|
+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
16
|
+
spec.require_paths = ["lib"]
|
17
|
+
spec.required_ruby_version = ">= 1.9.2"
|
18
|
+
|
19
|
+
spec.add_development_dependency "bundler", "~> 1.3"
|
20
|
+
spec.add_development_dependency "rake"
|
21
|
+
end
|
data/lib/binding.repl.rb
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
klass = Class.new do
|
2
|
+
module BindingMixin
|
3
|
+
def repl
|
4
|
+
Binding.repl.new(self)
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.version
|
9
|
+
"0.1.0"
|
10
|
+
end
|
11
|
+
|
12
|
+
def initialize(binding)
|
13
|
+
@binding = binding
|
14
|
+
end
|
15
|
+
|
16
|
+
def pry(options = {})
|
17
|
+
safe_require "pry", defined?(Pry)
|
18
|
+
@binding.pry options
|
19
|
+
end
|
20
|
+
|
21
|
+
def ripl(options = {})
|
22
|
+
safe_require "ripl", defined?(Ripl)
|
23
|
+
Ripl.start options.merge(:binding => @binding)
|
24
|
+
end
|
25
|
+
|
26
|
+
def irb(options = nil)
|
27
|
+
# Insane API, but here it is (IRB.start() doesn't take binding).
|
28
|
+
safe_require "irb", defined?(IRB)
|
29
|
+
IRB.setup(nil)
|
30
|
+
irb = IRB::Irb.new IRB::WorkSpace.new(@binding)
|
31
|
+
IRB.conf[:IRB_RC].call(irb.context) if IRB.conf[:IRB_RC]
|
32
|
+
IRB.conf[:MAIN_CONTEXT] = irb.context
|
33
|
+
trap("SIGINT") do
|
34
|
+
irb.signal_handle
|
35
|
+
end
|
36
|
+
catch(:IRB_EXIT) do
|
37
|
+
irb.eval_input
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def safe_require(lib, already_loaded)
|
43
|
+
unless already_loaded
|
44
|
+
require(lib)
|
45
|
+
end
|
46
|
+
rescue LoadError => e
|
47
|
+
raise e, "the ruby console '#{lib}' could not be loaded. is '#{lib}' installed?"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Binding.class_exec(klass) do |klass|
|
52
|
+
define_singleton_method(:repl) do
|
53
|
+
# I can't figure out a good name for this class yet.
|
54
|
+
# return an anonymous class (for now).
|
55
|
+
klass
|
56
|
+
end
|
57
|
+
include Binding.repl::BindingMixin
|
58
|
+
end
|
metadata
ADDED
@@ -0,0 +1,88 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: binding.repl
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Robert Gleeson
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-09-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.3'
|
22
|
+
type: :development
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.3'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: rake
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :development
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: binding.repl provides the same binding.pry interface to all ruby consoles
|
47
|
+
email:
|
48
|
+
- rob@flowof.info
|
49
|
+
executables: []
|
50
|
+
extensions: []
|
51
|
+
extra_rdoc_files: []
|
52
|
+
files:
|
53
|
+
- .gitignore
|
54
|
+
- Gemfile
|
55
|
+
- LICENSE.txt
|
56
|
+
- README.md
|
57
|
+
- Rakefile
|
58
|
+
- binding.repl.gemspec
|
59
|
+
- lib/binding.repl.rb
|
60
|
+
homepage: ''
|
61
|
+
licenses:
|
62
|
+
- MIT
|
63
|
+
post_install_message:
|
64
|
+
rdoc_options: []
|
65
|
+
require_paths:
|
66
|
+
- lib
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
68
|
+
none: false
|
69
|
+
requirements:
|
70
|
+
- - ! '>='
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: 1.9.2
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
segments:
|
80
|
+
- 0
|
81
|
+
hash: -3901662146917571460
|
82
|
+
requirements: []
|
83
|
+
rubyforge_project:
|
84
|
+
rubygems_version: 1.8.23
|
85
|
+
signing_key:
|
86
|
+
specification_version: 3
|
87
|
+
summary: binding.repl provides the same binding.pry interface to all ruby consoles
|
88
|
+
test_files: []
|