binding.repl 0.5.0.1 → 0.6.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/ChangeLog.txt +17 -3
- data/README.md +26 -19
- data/lib/binding.repl.rb +27 -7
- data/lib/binding.repl/{irb.rb → console/irb.rb} +0 -0
- data/lib/binding.repl/{pry.rb → console/pry.rb} +0 -0
- data/lib/binding.repl/{ripl.rb → console/ripl.rb} +0 -0
- data/lib/binding.repl/rc.rb +6 -5
- metadata +5 -5
data/ChangeLog.txt
CHANGED
@@ -1,18 +1,32 @@
|
|
1
|
+
== v0.6.0
|
2
|
+
- add Binding.repl.{disable!,enable!}.
|
3
|
+
turn binding.repl.{pry,irb,ripl,auto} into a no-op.
|
4
|
+
closes #8.
|
5
|
+
|
6
|
+
== v0.5.1
|
7
|
+
- $CWD/.binding.repl.rc has precendence over $HOME/.binding.repl.rc
|
8
|
+
stupid mistake. $CWD/.binding.repl.rc should be loaded instead of
|
9
|
+
$HOME/.binding.repl.rc if it exists.
|
10
|
+
|
11
|
+
- compare ENV["BINDING_REPL_RC"] as a string.
|
12
|
+
casting with to_i on nil(the default) returns 0.
|
13
|
+
file was never loaded.
|
14
|
+
|
1
15
|
== v0.5.0.1
|
2
16
|
- documentation fix
|
3
17
|
error in documentation
|
4
18
|
|
5
19
|
== v0.5.0
|
6
20
|
- disable {$HOME,$CWD}/.binding.repl.rc loading
|
7
|
-
set ENV["BINDING_REPL_RC"] = 0 to disable load.
|
21
|
+
set ENV["BINDING_REPL_RC"] = "0" to disable load.
|
8
22
|
|
9
23
|
== v0.4.1
|
10
24
|
- read {$HOME,$CWD}/.binding.repl.rc as JSON
|
11
|
-
|
25
|
+
less security concerns than parsing ruby.
|
12
26
|
|
13
27
|
== v0.4.0
|
14
28
|
- read {$HOME,$CWD}/.binding.ripl.rc on load
|
15
|
-
see README for
|
29
|
+
see README for documentation.
|
16
30
|
|
17
31
|
== v0.3.0
|
18
32
|
- add Binding.repl.add
|
data/README.md
CHANGED
@@ -33,13 +33,12 @@ __EXAMPLES__
|
|
33
33
|
class BlogsController < ApplicationController
|
34
34
|
def show
|
35
35
|
@blog = Blog.find(params[:id])
|
36
|
-
# starts pry, irb, or ripl in the context of 'BlogsController#show'.
|
37
36
|
binding.repl.{pry,irb,ripl}
|
38
37
|
end
|
39
38
|
end
|
40
39
|
|
41
40
|
class Bar
|
42
|
-
# auto discover the first available console.
|
41
|
+
# auto discover and start the first available console.
|
43
42
|
# default order is: ripl, pry, or irb.
|
44
43
|
binding.repl.auto
|
45
44
|
|
@@ -49,6 +48,20 @@ class Bar
|
|
49
48
|
# remove "irb" from auto discovery
|
50
49
|
Binding.repl.auto_load_order -= ["irb"]
|
51
50
|
end
|
51
|
+
|
52
|
+
class Baz
|
53
|
+
# invoke irb
|
54
|
+
binding.repl.irb
|
55
|
+
Binding.repl.disable!
|
56
|
+
|
57
|
+
# no-op, returns :'binding.repl.disabled' and continues execution.
|
58
|
+
binding.repl.irb
|
59
|
+
binding.repl.ripl
|
60
|
+
|
61
|
+
# invoke pry
|
62
|
+
Binding.repl.enable!
|
63
|
+
binding.repl.pry
|
64
|
+
end
|
52
65
|
```
|
53
66
|
|
54
67
|
__NOTES__
|
@@ -75,21 +88,29 @@ class Foo
|
|
75
88
|
end
|
76
89
|
```
|
77
90
|
|
91
|
+
_DEPENDENCIES_
|
92
|
+
|
93
|
+
binding.repl doesn't depend on anything. it's up to you to meet the
|
94
|
+
dependencies(pry, irb, and/or ripl). `binding.repl.{ripl,pry,irb}`
|
95
|
+
will try to load the appropiate console for you if it looks like it
|
96
|
+
hasn't been loaded yet.
|
97
|
+
|
78
98
|
_WORKING WITH TEAMS_
|
79
99
|
|
80
100
|
people working in teams might have different choices for what ruby
|
81
101
|
console they like to use and __binding.repl__ tries to accomondate by
|
82
102
|
reading a `.binding.repl.rc` file from $HOME or the current working
|
83
|
-
directory. It's a JSON file
|
103
|
+
directory. It's a very simple JSON file.
|
84
104
|
|
85
|
-
let's say amy
|
105
|
+
let's say rob & amy are working on some code together. amy prefers
|
106
|
+
IRB, so her `$HOME/.binding.repl.rc` would look like this:
|
86
107
|
```javascript
|
87
108
|
{
|
88
109
|
"auto_load_order": ["irb", "pry", "ripl"]
|
89
110
|
}
|
90
111
|
```
|
91
112
|
|
92
|
-
|
113
|
+
rob prefers pry, so his `$HOME/.binding.repl.rc` would look like this:
|
93
114
|
```ruby
|
94
115
|
{
|
95
116
|
"auto_load_order": ["pry", "ripl", "irb"]
|
@@ -107,20 +128,6 @@ class Foo
|
|
107
128
|
end
|
108
129
|
```
|
109
130
|
|
110
|
-
_RIPL & IRB_
|
111
|
-
|
112
|
-
I have only used Ripl once(to write this library) and I don't use IRB
|
113
|
-
much anymore. If I can improve support for either please let me know
|
114
|
-
via an issue or pull request/e-note.
|
115
|
-
|
116
|
-
|
117
|
-
_DEPENDENCIES_
|
118
|
-
|
119
|
-
binding.repl doesn't depend on anything. it's up to you to meet the
|
120
|
-
dependencies(pry, irb, and/or ripl). `binding.repl.{ripl,pry,irb}`
|
121
|
-
will try to load the appropiate console for you if it looks like it
|
122
|
-
hasn't been loaded yet.
|
123
|
-
|
124
131
|
__INSTALL__
|
125
132
|
|
126
133
|
ruby 1.9+ only.
|
data/lib/binding.repl.rb
CHANGED
@@ -18,7 +18,20 @@ class BindingRepl
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def self.version
|
21
|
-
"0.
|
21
|
+
"0.6.0"
|
22
|
+
end
|
23
|
+
|
24
|
+
def self.disabled?
|
25
|
+
@disabled
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.enable!
|
29
|
+
@disabled = false
|
30
|
+
!@disabled
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.disable!
|
34
|
+
@disabled = true
|
22
35
|
end
|
23
36
|
|
24
37
|
def self.add(console, predicate, runner)
|
@@ -44,11 +57,14 @@ class BindingRepl
|
|
44
57
|
|
45
58
|
def auto
|
46
59
|
load_order = Binding.repl.auto_load_order
|
60
|
+
exit_value = nil
|
47
61
|
load_order.each do |console|
|
48
62
|
exit_value = invoke_console(console.to_sym, {})
|
49
63
|
return exit_value unless invoke_failed?(exit_value)
|
50
64
|
end
|
51
|
-
|
65
|
+
if invoke_failed?(exit_value)
|
66
|
+
raise LoadError, "failed to load consoles: #{load_order.join(", ")}", []
|
67
|
+
end
|
52
68
|
end
|
53
69
|
|
54
70
|
private
|
@@ -57,10 +73,14 @@ private
|
|
57
73
|
end
|
58
74
|
|
59
75
|
def invoke_failed?(exit_value)
|
60
|
-
exit_value.to_s
|
76
|
+
exit_value = exit_value.to_s
|
77
|
+
exit_value.start_with?("binding.repl") && exit_value != 'binding.repl.disabled'
|
61
78
|
end
|
62
79
|
|
63
80
|
def invoke_console(console, options)
|
81
|
+
if Binding.repl.disabled?
|
82
|
+
return :'binding.repl.disabled'
|
83
|
+
end
|
64
84
|
require_predicate, runner = @lookup[console]
|
65
85
|
require_console(console, require_predicate)
|
66
86
|
runner.call(@binding, options)
|
@@ -85,10 +105,10 @@ Binding.class_eval do
|
|
85
105
|
include klass::BindingMixin
|
86
106
|
repl.auto_load_order = %w(ripl pry irb)
|
87
107
|
end
|
88
|
-
require_relative "binding.repl/pry"
|
89
|
-
require_relative "binding.repl/irb"
|
90
|
-
require_relative "binding.repl/ripl"
|
108
|
+
require_relative "binding.repl/console/pry"
|
109
|
+
require_relative "binding.repl/console/irb"
|
110
|
+
require_relative "binding.repl/console/ripl"
|
91
111
|
|
92
|
-
if ENV["BINDING_REPL_RC"]
|
112
|
+
if ENV["BINDING_REPL_RC"] != "0"
|
93
113
|
require_relative "binding.repl/rc"
|
94
114
|
end
|
File without changes
|
File without changes
|
File without changes
|
data/lib/binding.repl/rc.rb
CHANGED
@@ -2,14 +2,15 @@ require "json"
|
|
2
2
|
home_rc = File.join ENV["HOME"], ".binding.repl.rc"
|
3
3
|
local_rc = File.join Dir.getwd, ".binding.repl.rc"
|
4
4
|
|
5
|
-
if File.exists?(
|
6
|
-
json = File.read(home_rc)
|
7
|
-
end
|
8
|
-
if !File.exists?(home_rc) && File.exists?(local_rc)
|
5
|
+
if File.exists?(local_rc)
|
9
6
|
json = File.read(local_rc)
|
7
|
+
else
|
8
|
+
if File.exists?(home_rc)
|
9
|
+
json = File.read(home_rc)
|
10
|
+
end
|
10
11
|
end
|
11
12
|
|
12
|
-
if
|
13
|
+
if json
|
13
14
|
options = JSON.parse(json) rescue nil
|
14
15
|
end
|
15
16
|
if options
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: binding.repl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.6.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -60,10 +60,10 @@ files:
|
|
60
60
|
- Rakefile
|
61
61
|
- binding.repl.gemspec
|
62
62
|
- lib/binding.repl.rb
|
63
|
-
- lib/binding.repl/irb.rb
|
64
|
-
- lib/binding.repl/pry.rb
|
63
|
+
- lib/binding.repl/console/irb.rb
|
64
|
+
- lib/binding.repl/console/pry.rb
|
65
|
+
- lib/binding.repl/console/ripl.rb
|
65
66
|
- lib/binding.repl/rc.rb
|
66
|
-
- lib/binding.repl/ripl.rb
|
67
67
|
homepage: https://github.com/robgleeson/binding.repl
|
68
68
|
licenses:
|
69
69
|
- MIT
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
version: '0'
|
86
86
|
segments:
|
87
87
|
- 0
|
88
|
-
hash:
|
88
|
+
hash: 1608399329349294521
|
89
89
|
requirements: []
|
90
90
|
rubyforge_project:
|
91
91
|
rubygems_version: 1.8.23
|