ripl 0.2.6 → 0.2.7
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.rdoc +4 -0
- data/README.rdoc +2 -2
- data/lib/ripl/runner.rb +18 -23
- data/lib/ripl/shell.rb +1 -1
- data/lib/ripl/version.rb +1 -1
- data/man/ripl.1 +4 -4
- data/man/ripl.1.html +4 -4
- data/man/ripl.1.ronn +4 -4
- data/test/runner_test.rb +55 -30
- data/test/shell_test.rb +1 -0
- data/test/test_helper.rb +6 -2
- metadata +4 -4
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
|
@@ -77,7 +77,7 @@ modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:
|
|
|
77
77
|
{ripl-multi_line}[http://github.com/janlelis/ripl-multi_line]).
|
|
78
78
|
* No irb subsessions or workspaces (though ripl has jumps via
|
|
79
79
|
{ripl-commands}[http://github.com/cldwalker/ripl-commands])
|
|
80
|
-
* Some IRB.conf features aren't supported (see {ripl-irb}[http://github.com/cldwalker/ripl-irb]
|
|
80
|
+
* Some IRB.conf features aren't supported yet (see {ripl-irb}[http://github.com/cldwalker/ripl-irb]
|
|
81
81
|
for details)
|
|
82
82
|
|
|
83
83
|
Note: Irb features not in ripl can be implemented as plugins.
|
|
@@ -128,7 +128,7 @@ Creating and starting a custom shell is as simple as:
|
|
|
128
128
|
Ripl.start takes options to customize your shell. For example if you wanted to
|
|
129
129
|
start on a specific binding:
|
|
130
130
|
|
|
131
|
-
Ripl.start :binding =>
|
|
131
|
+
Ripl.start :binding => MyClass.instance_eval{ binding }
|
|
132
132
|
|
|
133
133
|
== Create Commands
|
|
134
134
|
|
data/lib/ripl/runner.rb
CHANGED
|
@@ -16,11 +16,7 @@ module Ripl::Runner
|
|
|
16
16
|
|
|
17
17
|
module API
|
|
18
18
|
def run(argv=ARGV)
|
|
19
|
-
|
|
20
|
-
load_rc(Ripl.config[:riplrc]) unless ENV['RIPLRC'] == 'false'
|
|
21
|
-
@run = true
|
|
22
|
-
parse_options(argv)
|
|
23
|
-
argv[0] ? run_command(argv) : start
|
|
19
|
+
argv[0].to_s[/^[^-]/] ? run_command(argv) : start(:argv=>argv)
|
|
24
20
|
end
|
|
25
21
|
|
|
26
22
|
def parse_options(argv)
|
|
@@ -28,26 +24,24 @@ module Ripl::Runner
|
|
|
28
24
|
case argv.shift
|
|
29
25
|
when /-I=?(.*)/
|
|
30
26
|
$LOAD_PATH.unshift(*($1.empty? ? argv.shift.to_s : $1).split(":"))
|
|
31
|
-
when /-r=?(.*)/
|
|
32
|
-
|
|
33
|
-
when '-
|
|
34
|
-
|
|
35
|
-
when '-
|
|
36
|
-
|
|
37
|
-
when '-f'
|
|
38
|
-
ENV['RIPL_IRBRC'] = 'false'
|
|
39
|
-
when '-h', '--help'
|
|
40
|
-
name_max = OPTIONS.map {|e| e[0].length }.max
|
|
41
|
-
desc_max = OPTIONS.map {|e| e[1].length }.max
|
|
42
|
-
puts "Usage: ripl [OPTIONS] [COMMAND] [ARGS]", "\nOptions:",
|
|
43
|
-
OPTIONS.map {|k,v| " %-*s %-*s" % [name_max, k, desc_max, v] }
|
|
44
|
-
exit
|
|
45
|
-
when /^(--?[^-]+)/
|
|
46
|
-
parse_option($1, argv)
|
|
27
|
+
when /-r=?(.*)/ then require($1.empty? ? argv.shift.to_s : $1)
|
|
28
|
+
when '-d' then $DEBUG = true
|
|
29
|
+
when '-v', '--version' then puts(Ripl::VERSION); exit
|
|
30
|
+
when '-f' then Ripl.config[:irbrc] = false
|
|
31
|
+
when '-h', '--help' then puts(help); exit
|
|
32
|
+
when /^(--?[^-]+)/ then parse_option($1, argv)
|
|
47
33
|
end
|
|
48
34
|
end
|
|
49
35
|
end
|
|
50
36
|
|
|
37
|
+
def help
|
|
38
|
+
return("ripl #{$1} [OPTIONS] [ARGS]") if $0[/ripl-(\w+)/]
|
|
39
|
+
name_max = OPTIONS.map {|e| e[0].length }.max
|
|
40
|
+
desc_max = OPTIONS.map {|e| e[1].length }.max
|
|
41
|
+
["Usage: ripl [COMMAND] [OPTIONS] [ARGS]", "\nOptions:",
|
|
42
|
+
OPTIONS.map {|k,v| " %-*s %-*s" % [name_max, k, desc_max, v] }]
|
|
43
|
+
end
|
|
44
|
+
|
|
51
45
|
def parse_option(option, argv)
|
|
52
46
|
warn "ripl: invalid option `#{option.sub(/^-+/, '')}'"
|
|
53
47
|
end
|
|
@@ -60,8 +54,9 @@ module Ripl::Runner
|
|
|
60
54
|
end
|
|
61
55
|
|
|
62
56
|
def start(options={})
|
|
63
|
-
|
|
64
|
-
Ripl.config[:
|
|
57
|
+
argv = options.delete(:argv) || ARGV
|
|
58
|
+
load_rc(Ripl.config[:riplrc]) unless argv.delete('-F')
|
|
59
|
+
parse_options(argv) if $0[/ripl$|ripl-\w+$/]
|
|
65
60
|
Ripl.shell(options).loop
|
|
66
61
|
end
|
|
67
62
|
|
data/lib/ripl/shell.rb
CHANGED
data/lib/ripl/version.rb
CHANGED
data/man/ripl.1
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
.
|
|
11
11
|
.nf
|
|
12
12
|
|
|
13
|
-
ripl [\-r|\-\-require] [\-I] [\-f] [\-d] [\-h|\-\-help] [\-v|\-\-version]
|
|
13
|
+
ripl [COMMAND] [\-r|\-\-require] [\-I] [\-f] [\-d] [\-h|\-\-help] [\-v|\-\-version] [ARGS]
|
|
14
14
|
.
|
|
15
15
|
.fi
|
|
16
16
|
.
|
|
@@ -228,7 +228,7 @@ Ripl\.start takes the same config keys mentioned in the \fBCONFIGURATION\fR sect
|
|
|
228
228
|
.
|
|
229
229
|
.nf
|
|
230
230
|
|
|
231
|
-
Ripl\.start :binding => MyClass\.
|
|
231
|
+
Ripl\.start :binding => MyClass\.instance_eval{ binding }
|
|
232
232
|
.
|
|
233
233
|
.fi
|
|
234
234
|
.
|
|
@@ -245,10 +245,10 @@ A ripl command is a command passed to ripl that loads a custom shell\. It\'s a c
|
|
|
245
245
|
.nf
|
|
246
246
|
|
|
247
247
|
# Load rails console without ~/\.irbrc
|
|
248
|
-
$ ripl \-f
|
|
248
|
+
$ ripl rails \-f
|
|
249
249
|
|
|
250
250
|
# Load rails console with debugger
|
|
251
|
-
$ ripl \-rrdebug
|
|
251
|
+
$ ripl rails \-rrdebug
|
|
252
252
|
.
|
|
253
253
|
.fi
|
|
254
254
|
.
|
data/man/ripl.1.html
CHANGED
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
|
|
81
81
|
<h2 id="SYNOPSIS">SYNOPSIS</h2>
|
|
82
82
|
|
|
83
|
-
<pre><code>ripl [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version]
|
|
83
|
+
<pre><code>ripl [COMMAND] [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version] [ARGS]
|
|
84
84
|
</code></pre>
|
|
85
85
|
|
|
86
86
|
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
|
@@ -230,7 +230,7 @@ Ripl.start
|
|
|
230
230
|
<p>Ripl.start takes the same config keys mentioned in the <code>CONFIGURATION</code> section. For example if you wanted to
|
|
231
231
|
start on a specific binding:</p>
|
|
232
232
|
|
|
233
|
-
<pre><code>Ripl.start :binding => MyClass.
|
|
233
|
+
<pre><code>Ripl.start :binding => MyClass.instance_eval{ binding }
|
|
234
234
|
</code></pre>
|
|
235
235
|
|
|
236
236
|
<p>Also, since all shells load ~/.riplrc, Ripl.start can be used to override undesirable global
|
|
@@ -243,10 +243,10 @@ package and invoke custom shells. A ripl command can take standard ripl options
|
|
|
243
243
|
before the command:</p>
|
|
244
244
|
|
|
245
245
|
<pre><code># Load rails console without ~/.irbrc
|
|
246
|
-
$ ripl -f
|
|
246
|
+
$ ripl rails -f
|
|
247
247
|
|
|
248
248
|
# Load rails console with debugger
|
|
249
|
-
$ ripl -rrdebug
|
|
249
|
+
$ ripl rails -rrdebug
|
|
250
250
|
</code></pre>
|
|
251
251
|
|
|
252
252
|
<p>To create a ripl command, create an executable in the format ripl-command and make sure it's in your
|
data/man/ripl.1.ronn
CHANGED
|
@@ -3,7 +3,7 @@ ripl(1) -- Ruby Interactive Print Loop - A light, modular alternative to irb
|
|
|
3
3
|
|
|
4
4
|
## SYNOPSIS
|
|
5
5
|
|
|
6
|
-
ripl [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version]
|
|
6
|
+
ripl [COMMAND] [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version] [ARGS]
|
|
7
7
|
|
|
8
8
|
## DESCRIPTION
|
|
9
9
|
|
|
@@ -155,7 +155,7 @@ Creating and starting a custom shell is as simple as:
|
|
|
155
155
|
Ripl.start takes the same config keys mentioned in the `CONFIGURATION` section. For example if you wanted to
|
|
156
156
|
start on a specific binding:
|
|
157
157
|
|
|
158
|
-
Ripl.start :binding => MyClass.
|
|
158
|
+
Ripl.start :binding => MyClass.instance_eval{ binding }
|
|
159
159
|
|
|
160
160
|
Also, since all shells load ~/.riplrc, Ripl.start can be used to override undesirable global
|
|
161
161
|
configuration for a custom shell.
|
|
@@ -167,10 +167,10 @@ package and invoke custom shells. A ripl command can take standard ripl options
|
|
|
167
167
|
before the command:
|
|
168
168
|
|
|
169
169
|
# Load rails console without ~/.irbrc
|
|
170
|
-
$ ripl -f
|
|
170
|
+
$ ripl rails -f
|
|
171
171
|
|
|
172
172
|
# Load rails console with debugger
|
|
173
|
-
$ ripl -rrdebug
|
|
173
|
+
$ ripl rails -rrdebug
|
|
174
174
|
|
|
175
175
|
To create a ripl command, create an executable in the format ripl-command and make sure it's in your
|
|
176
176
|
shell's $PATH. For example, the file 'ripl-my_gem' would be invoked with 'ripl my_gem'. Any
|
data/test/runner_test.rb
CHANGED
|
@@ -44,22 +44,48 @@ describe "Runner" do
|
|
|
44
44
|
end
|
|
45
45
|
|
|
46
46
|
describe "with subcommand" do
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
def set_dollar_zero(val)
|
|
48
|
+
$progname = $0
|
|
49
|
+
alias $0 $progname
|
|
50
|
+
$0 = val
|
|
50
51
|
end
|
|
51
52
|
|
|
52
|
-
|
|
53
|
-
mock(Runner).exec('ripl-rails')
|
|
53
|
+
def mock_exec(*args)
|
|
54
|
+
mock(Runner).exec('ripl-rails', *args) do
|
|
55
|
+
set_dollar_zero 'ripl-rails'
|
|
56
|
+
ARGV.replace(args)
|
|
57
|
+
Ripl.start
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
it "gets invoked with arguments" do
|
|
62
|
+
mock_exec 'blah'
|
|
63
|
+
ripl("rails", 'blah')
|
|
64
|
+
end
|
|
65
|
+
|
|
66
|
+
it "has -F global option parsed" do
|
|
67
|
+
mock_exec '-F'
|
|
54
68
|
dont_allow(Runner).load_rc(anything)
|
|
55
|
-
ripl("
|
|
56
|
-
|
|
69
|
+
ripl("rails", "-F", :riplrc=>false)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
it "has other global option parsed" do
|
|
73
|
+
mock_exec '-r=blah'
|
|
74
|
+
mock(Runner).require('blah')
|
|
75
|
+
ripl("rails", "-r=blah")
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
it "has automatic --help" do
|
|
79
|
+
mock_exec '--help'
|
|
80
|
+
mock(Runner).exit
|
|
81
|
+
ripl("rails", "--help").chomp.should == "ripl rails [OPTIONS] [ARGS]"
|
|
57
82
|
end
|
|
58
83
|
|
|
59
84
|
it "that is invalid aborts" do
|
|
60
85
|
mock(Runner).abort("`zzz' is not a ripl command.")
|
|
61
|
-
ripl 'zzz'
|
|
86
|
+
ripl 'zzz', :riplrc => false, :loop => false
|
|
62
87
|
end
|
|
88
|
+
after_all { set_dollar_zero 'ripl' }
|
|
63
89
|
end
|
|
64
90
|
|
|
65
91
|
describe "with -I option" do
|
|
@@ -67,33 +93,33 @@ describe "Runner" do
|
|
|
67
93
|
after { $:.replace @old_load_path }
|
|
68
94
|
|
|
69
95
|
it "and equal sign adds to $LOAD_PATH" do
|
|
70
|
-
ripl("-I=blah"
|
|
96
|
+
ripl("-I=blah")
|
|
71
97
|
$:[0].should == 'blah'
|
|
72
98
|
end
|
|
73
99
|
|
|
74
100
|
it "and no equal sign adds to $LOAD_PATH" do
|
|
75
|
-
ripl("-Ispec"
|
|
101
|
+
ripl("-Ispec")
|
|
76
102
|
$:[0].should == 'spec'
|
|
77
103
|
end
|
|
78
104
|
|
|
79
105
|
it "and whitespace delimited argument adds to $LOAD_PATH" do
|
|
80
|
-
ripl("-I", "spec"
|
|
106
|
+
ripl("-I", "spec")
|
|
81
107
|
$:[0].should == 'spec'
|
|
82
108
|
end
|
|
83
109
|
|
|
84
110
|
it "containing multiple paths adds to $LOAD_PATH" do
|
|
85
|
-
ripl("-I=app:lib"
|
|
111
|
+
ripl("-I=app:lib")
|
|
86
112
|
$:[0,2].should == ['app', 'lib']
|
|
87
113
|
end
|
|
88
114
|
|
|
89
115
|
it "called more than once adds to $LOAD_PATH" do
|
|
90
|
-
ripl("-Ilib", "-Ispec"
|
|
116
|
+
ripl("-Ilib", "-Ispec")
|
|
91
117
|
$:[0,2].should == ['spec', 'lib']
|
|
92
118
|
end
|
|
93
119
|
|
|
94
120
|
it "with invalid argument doesn't add to $LOAD_PATH" do
|
|
95
121
|
previous_size = $:.size
|
|
96
|
-
ripl("-I"
|
|
122
|
+
ripl("-I")
|
|
97
123
|
$:.size.should == previous_size
|
|
98
124
|
end
|
|
99
125
|
end
|
|
@@ -101,40 +127,40 @@ describe "Runner" do
|
|
|
101
127
|
describe "with -r option" do
|
|
102
128
|
it "and equal sign requires path" do
|
|
103
129
|
mock(Runner).require('rip')
|
|
104
|
-
ripl("-r=rip"
|
|
130
|
+
ripl("-r=rip")
|
|
105
131
|
end
|
|
106
132
|
|
|
107
133
|
it "and no equal sign requires path" do
|
|
108
134
|
mock(Runner).require('rip')
|
|
109
|
-
ripl("-rrip"
|
|
135
|
+
ripl("-rrip")
|
|
110
136
|
end
|
|
111
137
|
|
|
112
138
|
it "and whitespace delimited argument requires path" do
|
|
113
139
|
mock(Runner).require('rip')
|
|
114
|
-
ripl("-r", "rip"
|
|
140
|
+
ripl("-r", "rip")
|
|
115
141
|
end
|
|
116
142
|
|
|
117
143
|
it "called more than once requires paths" do
|
|
118
144
|
mock(Runner).require('rip')
|
|
119
145
|
mock(Runner).require('dude')
|
|
120
|
-
ripl("-rrip", "-rdude"
|
|
146
|
+
ripl("-rrip", "-rdude")
|
|
121
147
|
end
|
|
122
148
|
|
|
123
149
|
it "with invalid argument requires blank" do
|
|
124
150
|
mock(Runner).require('')
|
|
125
|
-
ripl('-r'
|
|
151
|
+
ripl('-r')
|
|
126
152
|
end
|
|
127
153
|
end
|
|
128
154
|
|
|
129
155
|
it "with -f option doesn't load irbrc" do
|
|
130
156
|
reset_ripl
|
|
157
|
+
reset_config
|
|
131
158
|
stub(Kernel).at_exit()
|
|
132
159
|
mock_shell { |shell|
|
|
133
160
|
mock(shell).loop_once { throw :ripl_exit }
|
|
134
161
|
dont_allow(Runner).load_rc(anything)
|
|
135
162
|
}
|
|
136
|
-
ripl("-f")
|
|
137
|
-
ENV.delete('RIPL_IRBRC')
|
|
163
|
+
ripl("-f", :loop => false)
|
|
138
164
|
Ripl.config[:irbrc] = '~/.irbrc'
|
|
139
165
|
end
|
|
140
166
|
|
|
@@ -146,31 +172,30 @@ describe "Runner" do
|
|
|
146
172
|
mock(shell).before_loop
|
|
147
173
|
mock(shell).loop_once { throw :ripl_exit }
|
|
148
174
|
}
|
|
149
|
-
ripl("-F", :riplrc => false)
|
|
150
|
-
ENV.delete('RIPLRC')
|
|
175
|
+
ripl("-F", :riplrc => false, :loop => false)
|
|
151
176
|
end
|
|
152
177
|
|
|
153
178
|
it "with -d option sets $DEBUG" do
|
|
154
|
-
ripl("-d"
|
|
179
|
+
ripl("-d")
|
|
155
180
|
$DEBUG.should == true
|
|
156
181
|
$DEBUG = nil
|
|
157
182
|
end
|
|
158
183
|
|
|
159
184
|
it "with -v option prints version" do
|
|
160
185
|
mock(Runner).exit
|
|
161
|
-
ripl("-v"
|
|
186
|
+
ripl("-v").chomp.should == Ripl::VERSION
|
|
162
187
|
end
|
|
163
188
|
|
|
164
189
|
it "with -h option prints help" do
|
|
165
190
|
mock(Runner).exit
|
|
166
|
-
actual = ripl("-h"
|
|
191
|
+
actual = ripl("-h")
|
|
167
192
|
actual.should =~ /^Usage: ripl/
|
|
168
193
|
actual.should =~ /Options:\n -f/
|
|
169
194
|
end
|
|
170
195
|
|
|
171
196
|
it "with invalid options prints errors" do
|
|
172
197
|
capture_stderr {
|
|
173
|
-
ripl('--blah', '-z'
|
|
198
|
+
ripl('--blah', '-z')
|
|
174
199
|
}.chomp.should == "ripl: invalid option `blah'\nripl: invalid option `z'"
|
|
175
200
|
end
|
|
176
201
|
|
|
@@ -186,17 +211,17 @@ describe "Runner" do
|
|
|
186
211
|
end
|
|
187
212
|
|
|
188
213
|
it "parses plugin option" do
|
|
189
|
-
ripl("--moo"
|
|
214
|
+
ripl("--moo").chomp.should == 'MOOOO'
|
|
190
215
|
end
|
|
191
216
|
|
|
192
217
|
it "displays plugin option in --help" do
|
|
193
218
|
mock(Runner).exit
|
|
194
|
-
ripl("--help"
|
|
219
|
+
ripl("--help").should =~ /--moo\s*just moos/
|
|
195
220
|
end
|
|
196
221
|
|
|
197
222
|
it "handles invalid option" do
|
|
198
223
|
capture_stderr {
|
|
199
|
-
ripl('--blah'
|
|
224
|
+
ripl('--blah')
|
|
200
225
|
}.chomp.should == "ripl: invalid option `blah'"
|
|
201
226
|
end
|
|
202
227
|
end
|
data/test/shell_test.rb
CHANGED
data/test/test_helper.rb
CHANGED
|
@@ -10,7 +10,7 @@ module Helpers
|
|
|
10
10
|
def ripl(*args)
|
|
11
11
|
options = args[-1].is_a?(Hash) ? args.pop : {}
|
|
12
12
|
mock_riplrc unless options[:riplrc] == false
|
|
13
|
-
mock(
|
|
13
|
+
mock(Ripl.shell).loop unless options[:loop] == false
|
|
14
14
|
capture_stdout { Ripl::Runner.run(args) }
|
|
15
15
|
end
|
|
16
16
|
|
|
@@ -27,7 +27,11 @@ module Helpers
|
|
|
27
27
|
end
|
|
28
28
|
|
|
29
29
|
def reset_ripl
|
|
30
|
-
Ripl.instance_eval "@shell = @riplrc = nil"
|
|
30
|
+
Ripl.instance_eval "@config = @shell = @riplrc = nil"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def reset_config
|
|
34
|
+
Ripl.config.merge! :history => '~/.irb_history', :completion => {}
|
|
31
35
|
end
|
|
32
36
|
|
|
33
37
|
def capture_stdout(&block)
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ripl
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 25
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 0
|
|
8
8
|
- 2
|
|
9
|
-
-
|
|
10
|
-
version: 0.2.
|
|
9
|
+
- 7
|
|
10
|
+
version: 0.2.7
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Gabriel Horner
|
|
@@ -15,7 +15,7 @@ autorequire:
|
|
|
15
15
|
bindir: bin
|
|
16
16
|
cert_chain: []
|
|
17
17
|
|
|
18
|
-
date: 2010-12-
|
|
18
|
+
date: 2010-12-04 00:00:00 -05:00
|
|
19
19
|
default_executable:
|
|
20
20
|
dependencies:
|
|
21
21
|
- !ruby/object:Gem::Dependency
|