ripl 0.2.9 → 0.3.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/.gemspec +2 -2
- data/CHANGELOG.rdoc +5 -0
- data/README.rdoc +1 -1
- data/lib/ripl/history.rb +1 -1
- data/lib/ripl/runner.rb +33 -31
- data/lib/ripl/shell.rb +2 -2
- data/lib/ripl/version.rb +1 -1
- data/lib/ripl.rb +1 -1
- data/man/ripl.1 +7 -3
- data/man/ripl.1.html +12 -6
- data/man/ripl.1.ronn +11 -4
- data/test/history_test.rb +38 -0
- data/test/runner_test.rb +21 -4
- data/test/shell_test.rb +21 -9
- metadata +8 -7
data/.gemspec
CHANGED
@@ -8,8 +8,8 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.authors = ["Gabriel Horner"]
|
9
9
|
s.email = "gabriel.horner@gmail.com"
|
10
10
|
s.homepage = "http://github.com/cldwlaker/ripl"
|
11
|
-
s.summary = "
|
12
|
-
s.description = "ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports commands i.e. ripl-play. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web)."
|
11
|
+
s.summary = "ruby interactive print loop - A light, modular alternative to irb and a shell framework"
|
12
|
+
s.description = "ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports commands i.e. ripl-play. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web). In other words, ripl is also a shell framework."
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
14
|
s.rubyforge_project = 'tagaholic'
|
15
15
|
s.executables = %w(ripl)
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -4,7 +4,7 @@ ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has au
|
|
4
4
|
keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports
|
5
5
|
commands i.e. {ripl-play}[http://github.com/cldwalker/ripl-play]. This customizability makes it
|
6
6
|
easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the
|
7
|
-
{web}[http://github.com/cldwalker/nirvana]).
|
7
|
+
{web}[http://github.com/cldwalker/nirvana]). In other words, ripl is also a shell framework.
|
8
8
|
|
9
9
|
== Install
|
10
10
|
|
data/lib/ripl/history.rb
CHANGED
@@ -12,7 +12,6 @@ module Ripl::History
|
|
12
12
|
def before_loop
|
13
13
|
@history = []
|
14
14
|
super
|
15
|
-
Kernel.at_exit { write_history }
|
16
15
|
File.exists?(history_file) &&
|
17
16
|
IO.readlines(history_file).each {|e| history << e.chomp }
|
18
17
|
end
|
@@ -20,6 +19,7 @@ module Ripl::History
|
|
20
19
|
def write_history
|
21
20
|
File.open(history_file, 'w') {|f| f.write Array(history).join("\n") }
|
22
21
|
end
|
22
|
+
alias_method :after_loop, :write_history
|
23
23
|
end
|
24
24
|
Ripl::Shell.include Ripl::History
|
25
25
|
Ripl.config[:history] = '~/.irb_history'
|
data/lib/ripl/runner.rb
CHANGED
@@ -1,25 +1,48 @@
|
|
1
|
-
|
1
|
+
class Ripl::Runner
|
2
2
|
OPTIONS = [
|
3
3
|
['-f', 'Suppress loading ~/.irbrc'],
|
4
4
|
['-F', 'Suppress loading ~/.riplrc'],
|
5
5
|
['-d, --debug', "Set $DEBUG to true (same as `ruby -d')"],
|
6
6
|
['-I PATH', "Add to front of $LOAD_PATH. Delimit multiple paths with ':'"],
|
7
7
|
['-r, --require FILE', "Require file (same as `ruby -r')"],
|
8
|
-
['-v, --version', 'Print
|
8
|
+
['-v, --version', 'Print version'],
|
9
9
|
['-h, --help', 'Print help']
|
10
10
|
]
|
11
|
+
class <<self; attr_accessor :argv, :app; end
|
12
|
+
self.app = 'ripl'
|
11
13
|
|
12
14
|
# Adds commandline options for --help
|
13
15
|
def self.add_options(*options)
|
14
16
|
OPTIONS.concat(options)
|
15
17
|
end
|
16
18
|
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
19
|
+
def self.run(argv=ARGV)
|
20
|
+
argv[0].to_s[/^[^-]/] ? run_command(argv) : start(:argv => argv)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.run_command(argv)
|
24
|
+
exec "#{app}-#{argv.shift}", *argv
|
25
|
+
rescue Errno::ENOENT
|
26
|
+
raise unless $!.message =~ /No such file or directory.*#{app}-(\w+)/
|
27
|
+
abort "`#{$1}' is not a #{app} command."
|
28
|
+
end
|
29
|
+
|
30
|
+
def self.start(options={})
|
31
|
+
@argv = options.delete(:argv) || ARGV
|
32
|
+
argv = @argv.dup
|
33
|
+
load_rc(Ripl.config[:riplrc]) unless argv.delete('-F') || options[:riplrc] == false
|
34
|
+
argv.each {|e| e[/^-/] ? break : argv.shift } if $0[/#{app}-\w+$/]
|
35
|
+
parse_options(argv) if $0[/#{app}$|#{app}-\w+$/]
|
36
|
+
Ripl.shell(options).loop
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.load_rc(file)
|
40
|
+
load file if File.exists?(File.expand_path(file))
|
41
|
+
rescue StandardError, SyntaxError, LoadError
|
42
|
+
warn "#{app}: Error while loading #{file}:\n"+ format_error($!)
|
43
|
+
end
|
22
44
|
|
45
|
+
module API
|
23
46
|
def parse_options(argv)
|
24
47
|
while argv[0] =~ /^-/
|
25
48
|
case argv.shift
|
@@ -36,36 +59,15 @@ module Ripl::Runner
|
|
36
59
|
end
|
37
60
|
|
38
61
|
def help
|
39
|
-
return("
|
62
|
+
return("#{app} #{$1} [ARGS] [OPTIONS]") if $0[/#{app}-(\w+)/]
|
40
63
|
name_max = OPTIONS.map {|e| e[0].length }.max
|
41
64
|
desc_max = OPTIONS.map {|e| e[1].length }.max
|
42
|
-
["Usage:
|
65
|
+
["Usage: #{app} [COMMAND] [ARGS] [OPTIONS]", "\nOptions:",
|
43
66
|
OPTIONS.map {|k,v| " %-*s %-*s" % [name_max, k, desc_max, v] }]
|
44
67
|
end
|
45
68
|
|
46
69
|
def parse_option(option, argv)
|
47
|
-
warn "
|
48
|
-
end
|
49
|
-
|
50
|
-
def run_command(argv)
|
51
|
-
exec "ripl-#{argv.shift}", *argv
|
52
|
-
rescue Errno::ENOENT
|
53
|
-
raise unless $!.message =~ /No such file or directory.*ripl-(\w+)/
|
54
|
-
abort "`#{$1}' is not a ripl command."
|
55
|
-
end
|
56
|
-
|
57
|
-
def start(options={})
|
58
|
-
@argv = options.delete(:argv) || ARGV
|
59
|
-
argv = @argv.dup
|
60
|
-
load_rc(Ripl.config[:riplrc]) unless argv.delete('-F') || options[:riplrc] == false
|
61
|
-
parse_options(argv) if $0[/ripl$|ripl-\w+$/]
|
62
|
-
Ripl.shell(options).loop
|
63
|
-
end
|
64
|
-
|
65
|
-
def load_rc(file)
|
66
|
-
load file if File.exists?(File.expand_path(file))
|
67
|
-
rescue StandardError, SyntaxError, LoadError
|
68
|
-
warn "ripl: Error while loading #{file}:\n"+ format_error($!)
|
70
|
+
warn "#{app}: invalid option `#{option.sub(/^-+/, '')}'"
|
69
71
|
end
|
70
72
|
|
71
73
|
def format_error(err)
|
data/lib/ripl/shell.rb
CHANGED
@@ -9,8 +9,8 @@ class Ripl::Shell
|
|
9
9
|
|
10
10
|
class <<self; public :include; end
|
11
11
|
|
12
|
-
OPTIONS = {:name=>'ripl', :result_prompt=>'=> ', :prompt=>'>> ',
|
13
|
-
:binding=>TOPLEVEL_BINDING, :irbrc=>'~/.irbrc'}
|
12
|
+
OPTIONS = {:name => 'ripl', :result_prompt => '=> ', :prompt => '>> ',
|
13
|
+
:binding => TOPLEVEL_BINDING, :irbrc=>'~/.irbrc'}
|
14
14
|
EXIT_WORDS = [nil, 'exit', 'quit']
|
15
15
|
|
16
16
|
attr_accessor :line, :binding, :result, :name
|
data/lib/ripl/version.rb
CHANGED
data/lib/ripl.rb
CHANGED
data/man/ripl.1
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
.\" generated with Ronn/v0.7.3
|
2
2
|
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
3
|
.
|
4
|
-
.TH "RIPL" "1" "
|
4
|
+
.TH "RIPL" "1" "January 2011" "CLDWALKER" "Ripl Manual"
|
5
5
|
.
|
6
6
|
.SH "NAME"
|
7
7
|
\fBripl\fR \- Ruby Interactive Print Loop \- A light, modular alternative to irb
|
@@ -10,7 +10,7 @@
|
|
10
10
|
.
|
11
11
|
.nf
|
12
12
|
|
13
|
-
ripl [COMMAND] [\-r|\-\-require] [\-I] [\-f] [\-d] [\-h|\-\-help] [\-v|\-\-version]
|
13
|
+
ripl [COMMAND] [ARGS] [\-r|\-\-require] [\-I] [\-f] [\-d] [\-h|\-\-help] [\-v|\-\-version]
|
14
14
|
.
|
15
15
|
.fi
|
16
16
|
.
|
@@ -150,6 +150,7 @@ module Ripl::MyPlugin
|
|
150
150
|
.
|
151
151
|
.nf
|
152
152
|
|
153
|
+
# When requiring a plugin within ripl, this callback isn\'t called
|
153
154
|
def before_loop
|
154
155
|
super
|
155
156
|
# Open file, open connection \.\.\.
|
@@ -208,6 +209,9 @@ To define custom autocompletion for a plugin and its commands, create a completi
|
|
208
209
|
For plugins with console commands, commands aren\'t immediately recognized if the plugin is required within ripl\. To fix this: Ripl\.shell\.add_commands(self)\.
|
209
210
|
.
|
210
211
|
.IP "\(bu" 4
|
212
|
+
A plugin should not have Ripl\.shell in the top\-level i\.e\. touch Ripl\.shell when it\'s required\. Doing this can make commandline options buggy\.
|
213
|
+
.
|
214
|
+
.IP "\(bu" 4
|
211
215
|
For more examples of plugins, see gems I\'ve made that start with \'ripl\-\'\.
|
212
216
|
.
|
213
217
|
.IP "" 0
|
@@ -261,7 +265,7 @@ $ ripl rails \-rrdebug
|
|
261
265
|
.IP "" 0
|
262
266
|
.
|
263
267
|
.P
|
264
|
-
To create a ripl command, create an executable in the format ripl\-command and make sure it\'s in your shell\'s $PATH\. For example, the file \'ripl\-my_gem\' would be invoked with \'ripl my_gem\'\.
|
268
|
+
To create a ripl command, create an executable in the format ripl\-command and make sure it\'s in your shell\'s $PATH\. For example, the file \'ripl\-my_gem\' would be invoked with \'ripl my_gem\'\. A ripl command can take arguments, local options and global options (i\.e\. \-f)\. To avoid conflicts between local and global options, local options \fImust be parsed and deleted\fR by the command before Ripl\.start is invoked\. For example commands, see ripl\-rails \fIhttp://github\.com/cldwalker/ripl\-rails\fR and ripl\-play \fIhttp://github\.com/cldwalker/ripl\-play\fR\.
|
265
269
|
.
|
266
270
|
.SH "BUGS"
|
267
271
|
Please report bugs at \fIhttp://github\.com/cldwalker/ripl/issues\fR\.
|
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 [COMMAND] [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version]
|
83
|
+
<pre><code>ripl [COMMAND] [ARGS] [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version]
|
84
84
|
</code></pre>
|
85
85
|
|
86
86
|
<h2 id="DESCRIPTION">DESCRIPTION</h2>
|
@@ -181,7 +181,8 @@ for you and anyone else who uses your plugin!</p></li>
|
|
181
181
|
|
182
182
|
<p> module Ripl::MyPlugin</p>
|
183
183
|
|
184
|
-
<pre><code
|
184
|
+
<pre><code># When requiring a plugin within ripl, this callback isn't called
|
185
|
+
def before_loop
|
185
186
|
super
|
186
187
|
# Open file, open connection ...
|
187
188
|
end
|
@@ -221,6 +222,8 @@ To autocomplete a console command, define a :method completion. For an example p
|
|
221
222
|
<a href="http://github.com/cldwalker/ripl-commands">ripl-commands</a>.</p></li>
|
222
223
|
<li><p>For plugins with console commands, commands aren't immediately recognized if the plugin is required within ripl.
|
223
224
|
To fix this: Ripl.shell.add_commands(self).</p></li>
|
225
|
+
<li><p>A plugin should not have Ripl.shell in the top-level i.e. touch Ripl.shell when it's required. Doing
|
226
|
+
this can make commandline options buggy.</p></li>
|
224
227
|
<li><p>For more examples of plugins, see gems I've made that start with 'ripl-'.</p></li>
|
225
228
|
</ul>
|
226
229
|
|
@@ -257,9 +260,12 @@ $ ripl rails -rrdebug
|
|
257
260
|
</code></pre>
|
258
261
|
|
259
262
|
<p>To create a ripl command, create an executable in the format ripl-command and make sure it's in your
|
260
|
-
shell's $PATH. For example, the file 'ripl-my_gem' would be invoked with 'ripl my_gem'.
|
261
|
-
|
262
|
-
|
263
|
+
shell's $PATH. For example, the file 'ripl-my_gem' would be invoked with 'ripl my_gem'. A ripl
|
264
|
+
command can take arguments, local options and global options (i.e. -f). To avoid conflicts between
|
265
|
+
local and global options, local options <em>must be parsed and deleted</em> by the command before
|
266
|
+
Ripl.start is invoked. For example commands, see
|
267
|
+
<a href="http://github.com/cldwalker/ripl-rails">ripl-rails</a> and
|
268
|
+
<a href="http://github.com/cldwalker/ripl-play">ripl-play</a>.</p>
|
263
269
|
|
264
270
|
<h2 id="BUGS">BUGS</h2>
|
265
271
|
|
@@ -277,7 +283,7 @@ arguments. For an example command, see <a href="http://github.com/cldwalker/ripl
|
|
277
283
|
|
278
284
|
<ol class='man-decor man-foot man foot'>
|
279
285
|
<li class='tl'>CLDWALKER</li>
|
280
|
-
<li class='tc'>
|
286
|
+
<li class='tc'>January 2011</li>
|
281
287
|
<li class='tr'>ripl(1)</li>
|
282
288
|
</ol>
|
283
289
|
|
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 [COMMAND] [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version]
|
6
|
+
ripl [COMMAND] [ARGS] [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version]
|
7
7
|
|
8
8
|
## DESCRIPTION
|
9
9
|
|
@@ -111,6 +111,7 @@ Points to consider when creating plugins:
|
|
111
111
|
* Plugins can setup and teardown anything around a shell by extending Shell#before_loop and Shell#after_loop:
|
112
112
|
|
113
113
|
module Ripl::MyPlugin
|
114
|
+
# When requiring a plugin within ripl, this callback isn't called
|
114
115
|
def before_loop
|
115
116
|
super
|
116
117
|
# Open file, open connection ...
|
@@ -151,6 +152,9 @@ Points to consider when creating plugins:
|
|
151
152
|
* For plugins with console commands, commands aren't immediately recognized if the plugin is required within ripl.
|
152
153
|
To fix this: Ripl.shell.add_commands(self).
|
153
154
|
|
155
|
+
* A plugin should not have Ripl.shell in the top-level i.e. touch Ripl.shell when it's required. Doing
|
156
|
+
this can make commandline options buggy.
|
157
|
+
|
154
158
|
* For more examples of plugins, see gems I've made that start with 'ripl-'.
|
155
159
|
|
156
160
|
## CREATE CUSTOM SHELLS
|
@@ -182,9 +186,12 @@ before the command:
|
|
182
186
|
$ ripl rails -rrdebug
|
183
187
|
|
184
188
|
To create a ripl command, create an executable in the format ripl-command and make sure it's in your
|
185
|
-
shell's $PATH. For example, the file 'ripl-my_gem' would be invoked with 'ripl my_gem'.
|
186
|
-
|
187
|
-
|
189
|
+
shell's $PATH. For example, the file 'ripl-my_gem' would be invoked with 'ripl my_gem'. A ripl
|
190
|
+
command can take arguments, local options and global options (i.e. -f). To avoid conflicts between
|
191
|
+
local and global options, local options *must be parsed and deleted* by the command before
|
192
|
+
Ripl.start is invoked. For example commands, see
|
193
|
+
[ripl-rails](http://github.com/cldwalker/ripl-rails) and
|
194
|
+
[ripl-play](http://github.com/cldwalker/ripl-play).
|
188
195
|
|
189
196
|
## BUGS
|
190
197
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
require File.join(File.dirname(__FILE__), 'test_helper')
|
2
|
+
require 'fileutils'
|
3
|
+
|
4
|
+
HISTORY_FILE = File.dirname(__FILE__) + '/ripl_history'
|
5
|
+
|
6
|
+
describe "History with readline" do
|
7
|
+
def shell(options={})
|
8
|
+
Ripl.shell(options.merge(:history => HISTORY_FILE))
|
9
|
+
end
|
10
|
+
|
11
|
+
before do
|
12
|
+
reset_ripl
|
13
|
+
if defined? Readline
|
14
|
+
1.upto(Readline::HISTORY.size) { Readline::HISTORY.shift }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
after { FileUtils.rm_f HISTORY_FILE }
|
18
|
+
|
19
|
+
it "#after_loop saves history" do
|
20
|
+
inputs = %w{blih blah}
|
21
|
+
inputs.each {|e| shell.history << e }
|
22
|
+
shell.after_loop
|
23
|
+
File.read(HISTORY_FILE).should == inputs.join("\n")
|
24
|
+
end
|
25
|
+
|
26
|
+
it "#before_loop loads previous history" do
|
27
|
+
File.open(HISTORY_FILE, 'w') {|f| f.write "check\nthe\nmike" }
|
28
|
+
stub(Ripl::Runner).load_rc
|
29
|
+
shell.before_loop
|
30
|
+
shell.history.to_a.should == %w{check the mike}
|
31
|
+
end
|
32
|
+
|
33
|
+
it "#before_loop has empty history if no history file exists" do
|
34
|
+
stub(Ripl::Runner).load_rc
|
35
|
+
shell.before_loop
|
36
|
+
shell.history.to_a.should == []
|
37
|
+
end
|
38
|
+
end
|
data/test/runner_test.rb
CHANGED
@@ -94,16 +94,22 @@ describe "Runner" do
|
|
94
94
|
Ripl::Runner.argv.should == ['blah', '-F']
|
95
95
|
end
|
96
96
|
|
97
|
-
it "has
|
97
|
+
it "has global option parsed" do
|
98
98
|
mock_exec '-r=blah'
|
99
99
|
mock(Runner).require('blah')
|
100
100
|
ripl("rails", "-r=blah")
|
101
101
|
end
|
102
102
|
|
103
|
+
it "has global option parsed after arguments" do
|
104
|
+
mock_exec 'test', '-r=blah'
|
105
|
+
mock(Runner).require('blah')
|
106
|
+
ripl("rails", "test", "-r=blah", :riplrc=>false)
|
107
|
+
end
|
108
|
+
|
103
109
|
it "has automatic --help" do
|
104
110
|
mock_exec '--help'
|
105
111
|
mock(Runner).exit
|
106
|
-
ripl("rails", "--help").chomp.should == "ripl rails [
|
112
|
+
ripl("rails", "--help").chomp.should == "ripl rails [ARGS] [OPTIONS]"
|
107
113
|
end
|
108
114
|
|
109
115
|
it "that is invalid aborts" do
|
@@ -180,7 +186,6 @@ describe "Runner" do
|
|
180
186
|
it "with -f option doesn't load irbrc" do
|
181
187
|
reset_ripl
|
182
188
|
reset_config
|
183
|
-
stub(Kernel).at_exit()
|
184
189
|
mock_shell { |shell|
|
185
190
|
mock(shell).loop_once { throw :ripl_exit }
|
186
191
|
dont_allow(Runner).load_rc(anything)
|
@@ -193,9 +198,9 @@ describe "Runner" do
|
|
193
198
|
reset_ripl
|
194
199
|
dont_allow(Runner).load_rc(anything)
|
195
200
|
mock_shell { |shell|
|
196
|
-
stub(Kernel).at_exit
|
197
201
|
mock(shell).before_loop
|
198
202
|
mock(shell).loop_once { throw :ripl_exit }
|
203
|
+
mock(shell).after_loop
|
199
204
|
}
|
200
205
|
ripl("-F", :riplrc => false, :loop => false)
|
201
206
|
end
|
@@ -251,4 +256,16 @@ describe "Runner" do
|
|
251
256
|
end
|
252
257
|
end
|
253
258
|
end
|
259
|
+
|
260
|
+
describe "API" do
|
261
|
+
Runner::API.instance_methods.each do |meth|
|
262
|
+
it "##{meth} is accessible to plugins" do
|
263
|
+
mod = Object.const_set "Ping_#{meth}", Module.new
|
264
|
+
mod.send(:define_method, meth) { "pong_#{meth}" }
|
265
|
+
Runner.extend mod
|
266
|
+
Runner.send(meth).should == "pong_#{meth}"
|
267
|
+
end
|
268
|
+
end
|
269
|
+
after_all { Runner.extend Runner::API }
|
270
|
+
end
|
254
271
|
end
|
data/test/shell_test.rb
CHANGED
@@ -8,7 +8,7 @@ describe "Shell" do
|
|
8
8
|
end
|
9
9
|
|
10
10
|
describe "#loop" do
|
11
|
-
before { mock(shell).before_loop }
|
11
|
+
before { mock(shell).before_loop; mock(shell).after_loop }
|
12
12
|
it "exits with exit" do
|
13
13
|
mock(shell).get_input { 'exit' }
|
14
14
|
dont_allow(shell).eval_input
|
@@ -28,10 +28,24 @@ describe "Shell" do
|
|
28
28
|
end
|
29
29
|
end
|
30
30
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
31
|
+
describe "#loop_once" do
|
32
|
+
it "handles Control-C" do
|
33
|
+
mock(shell).get_input { raise Interrupt }
|
34
|
+
dont_allow(shell).eval_input
|
35
|
+
capture_stdout { shell.loop_once }.should == "\n"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "prints result" do
|
39
|
+
mock(shell).get_input { '"m" * 2' }
|
40
|
+
capture_stdout { shell.loop_once }.should == %[=> "mm"\n]
|
41
|
+
end
|
42
|
+
|
43
|
+
it "prints error" do
|
44
|
+
mock(shell).get_input { "raise 'blah'" }
|
45
|
+
capture_stderr {
|
46
|
+
capture_stdout { shell.loop_once }.should == ""
|
47
|
+
}.should =~ /RuntimeError/
|
48
|
+
end
|
35
49
|
end
|
36
50
|
|
37
51
|
describe "#prompt" do
|
@@ -55,7 +69,6 @@ describe "Shell" do
|
|
55
69
|
before { reset_config }
|
56
70
|
it "adds commands to main from Commands" do
|
57
71
|
stub(Ripl::Runner).load_rc
|
58
|
-
stub(Kernel).at_exit
|
59
72
|
Ripl.shell.before_loop
|
60
73
|
Ripl.shell.loop_eval("ping").should == 'pong'
|
61
74
|
end
|
@@ -63,7 +76,6 @@ describe "Shell" do
|
|
63
76
|
it "adds commands to fixnum from Commands" do
|
64
77
|
stub(Ripl::Runner).load_rc
|
65
78
|
Ripl.shell.binding = 1.send(:binding)
|
66
|
-
stub(Kernel).at_exit
|
67
79
|
Ripl.shell.before_loop
|
68
80
|
Ripl.shell.loop_eval("ping").should == 'pong'
|
69
81
|
end
|
@@ -107,9 +119,9 @@ describe "Shell" do
|
|
107
119
|
end
|
108
120
|
end
|
109
121
|
|
110
|
-
describe "API
|
122
|
+
describe "API" do
|
111
123
|
Shell::API.instance_methods.delete_if {|e| e[/=$/]}.each do |meth|
|
112
|
-
it "
|
124
|
+
it "##{meth} is accessible to plugins" do
|
113
125
|
mod = Object.const_set "Ping_#{meth}", Module.new
|
114
126
|
mod.send(:define_method, meth) { "pong_#{meth}" }
|
115
127
|
Shell.send :include, mod
|
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: 19
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
-
|
10
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
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:
|
18
|
+
date: 2011-01-03 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -94,7 +94,7 @@ dependencies:
|
|
94
94
|
version: "0"
|
95
95
|
type: :development
|
96
96
|
version_requirements: *id005
|
97
|
-
description: ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports commands i.e. ripl-play. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web).
|
97
|
+
description: ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports commands i.e. ripl-play. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web). In other words, ripl is also a shell framework.
|
98
98
|
email: gabriel.horner@gmail.com
|
99
99
|
executables:
|
100
100
|
- ripl
|
@@ -112,6 +112,7 @@ files:
|
|
112
112
|
- lib/ripl/version.rb
|
113
113
|
- lib/ripl.rb
|
114
114
|
- test/completion_test.rb
|
115
|
+
- test/history_test.rb
|
115
116
|
- test/runner_test.rb
|
116
117
|
- test/shell_test.rb
|
117
118
|
- test/test_helper.rb
|
@@ -161,6 +162,6 @@ rubyforge_project: tagaholic
|
|
161
162
|
rubygems_version: 1.3.7
|
162
163
|
signing_key:
|
163
164
|
specification_version: 3
|
164
|
-
summary:
|
165
|
+
summary: ruby interactive print loop - A light, modular alternative to irb and a shell framework
|
165
166
|
test_files: []
|
166
167
|
|