ripl 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemspec +4 -3
- data/CHANGELOG.rdoc +3 -0
- data/README.rdoc +56 -21
- data/lib/ripl/completion.rb +1 -1
- data/lib/ripl/version.rb +1 -1
- data/man/ripl.1 +236 -0
- data/man/ripl.1.ronn +174 -0
- metadata +11 -9
data/.gemspec
CHANGED
@@ -8,16 +8,17 @@ 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 =
|
11
|
+
s.summary = "Ruby Interactive Print Loop - A light, modular alternative to irb"
|
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. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web)."
|
13
13
|
s.required_rubygems_version = ">= 1.3.6"
|
14
14
|
s.rubyforge_project = 'tagaholic'
|
15
15
|
s.executables = %w(ripl)
|
16
|
-
s.add_dependency 'bond', '~> 0.3.
|
16
|
+
s.add_dependency 'bond', '~> 0.3.3'
|
17
17
|
s.add_development_dependency 'bacon', '>= 1.1.0'
|
18
18
|
s.add_development_dependency 'rr', '= 0.10.10'
|
19
19
|
s.add_development_dependency 'bacon-bits'
|
20
20
|
s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
|
21
|
+
s.files += Dir.glob('man/*')
|
21
22
|
s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
|
22
23
|
s.license = 'MIT'
|
23
24
|
end
|
data/CHANGELOG.rdoc
CHANGED
data/README.rdoc
CHANGED
@@ -1,6 +1,9 @@
|
|
1
1
|
== Description
|
2
2
|
|
3
|
-
|
3
|
+
ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and
|
4
|
+
keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports
|
5
|
+
commands. This customizability makes it easy to build custom shells (i.e. for a gem or application)
|
6
|
+
and complex shells (i.e. for the {web}[http://github.com/cldwalker/nirvana]).
|
4
7
|
|
5
8
|
== Install
|
6
9
|
|
@@ -8,7 +11,46 @@ Install the gem with:
|
|
8
11
|
|
9
12
|
sudo gem install ripl
|
10
13
|
|
11
|
-
|
14
|
+
To make your first ripl experience smoother, also install these plugins:
|
15
|
+
|
16
|
+
# Adds multi-line evaluation
|
17
|
+
sudo gem install ripl-multi_line
|
18
|
+
|
19
|
+
# Ignore errors caused by irb-specific configuration in ~/.irbrc
|
20
|
+
sudo gem install ripl-irb
|
21
|
+
|
22
|
+
# Add to ~/.riplrc
|
23
|
+
require 'ripl/multi_line'
|
24
|
+
require 'ripl/irb'
|
25
|
+
|
26
|
+
== Usage
|
27
|
+
|
28
|
+
$ ripl
|
29
|
+
>> ...
|
30
|
+
|
31
|
+
To view ripl's man page:
|
32
|
+
|
33
|
+
# If installed with rubygems
|
34
|
+
$ gem install gem-man
|
35
|
+
$ gem man ripl
|
36
|
+
|
37
|
+
# If installed with rip, man page is automatically installed
|
38
|
+
$ man ripl
|
39
|
+
|
40
|
+
== Coming from irb
|
41
|
+
|
42
|
+
When first trying ripl, you may experience errors in your ~/.irbrc due to an irb-specific
|
43
|
+
configuration. In order to have ripl and irb coexist peacefully, you should silence these errors.
|
44
|
+
To silence them without touching your ~/.irbrc, install the ripl-irb gem. This ripl plugin fakes
|
45
|
+
irb's existence, effectively ignoring irb-specific configuration. Otherwise, if you don't mind
|
46
|
+
modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:
|
47
|
+
|
48
|
+
if defined? IRB
|
49
|
+
IRB.conf[:BLAH] = 'blah'
|
50
|
+
# ...
|
51
|
+
end
|
52
|
+
|
53
|
+
== Comparison to Irb
|
12
54
|
|
13
55
|
* Similar to irb
|
14
56
|
* Reads ~/.irbrc on startup
|
@@ -21,9 +63,10 @@ Install the gem with:
|
|
21
63
|
* Enhancements over irb
|
22
64
|
* ~200 lines vs irb's 5000+ lines
|
23
65
|
* Easily extendable with plugins
|
66
|
+
* Tests and documentation!
|
24
67
|
* Customizable completion and completion of method arguments (from bond)
|
25
68
|
* Easy to create custom shells for gems and apps i.e. Ripl.start
|
26
|
-
* Easy to create and invoke ripl
|
69
|
+
* Easy to create and invoke ripl commands
|
27
70
|
* ~/.irbrc errors caught
|
28
71
|
* Different from irb
|
29
72
|
* No multi-line evaluation by default (there is a plugin. See Available Plugins below).
|
@@ -32,17 +75,6 @@ Install the gem with:
|
|
32
75
|
|
33
76
|
Note: Irb features not in ripl can be implemented as plugins.
|
34
77
|
|
35
|
-
== Philosophy
|
36
|
-
|
37
|
-
ripl is a light, flexible repl(shell) meant to lay the foundation for customizable ruby shells. It
|
38
|
-
provides an environment for plugins to share and reuse best practices for shells. ripl can be
|
39
|
-
easily customized for gems, applications and is even usable on the web (examples forthcoming).
|
40
|
-
|
41
|
-
== Usage
|
42
|
-
|
43
|
-
$ ripl
|
44
|
-
>> ...
|
45
|
-
|
46
78
|
== Plugins
|
47
79
|
|
48
80
|
A ripl plugin is a module that is included into Ripl::Shell or Ripl::Runner. Being simply modules,
|
@@ -62,7 +94,7 @@ As an example plugin, let's color error messages red:
|
|
62
94
|
Ripl::Shell.send :include, Ripl::RedError
|
63
95
|
|
64
96
|
Note this plugin extends format_error() by invoking the original format_error() with super. This is
|
65
|
-
possible for any method that is available for extension by plugins. To see methods are available for
|
97
|
+
possible for any method that is available for extension by plugins. To see what methods are available for
|
66
98
|
extension, see Ripl::Shell::API and Ripl::Runner::API.
|
67
99
|
|
68
100
|
If we want to add a config for this plugin, we can simply add a key to Ripl.config that matches the
|
@@ -70,6 +102,12 @@ underscored version of the plugin name i.e. Ripl.config[:red_error].
|
|
70
102
|
|
71
103
|
For available plugins, see Available Plugins below.
|
72
104
|
|
105
|
+
== Configuration
|
106
|
+
|
107
|
+
Since ripl is highly customizable, it loads ~/.riplrc before it does anything. This ruby file should
|
108
|
+
require and/or define plugins. Any ripl configurations via Ripl.config should also be done here.
|
109
|
+
For an example riplrc, see {mine}[http://github.com/cldwalker/dotfiles/tree/master/.riplrc].
|
110
|
+
|
73
111
|
== Create Custom Shells
|
74
112
|
|
75
113
|
Creating and starting a custom shell is as simple as:
|
@@ -91,18 +129,15 @@ $PATH. For example, the file 'ripl-my_gem' would be invoked with `ripl my_gem`.
|
|
91
129
|
command you can take arguments and parse your options as you please. For an example command,
|
92
130
|
see {ripl-rails}[http://github.com/cldwalker/ripl-rails].
|
93
131
|
|
94
|
-
== Customize ripl
|
95
|
-
|
96
|
-
Since ripl is highly customizable, it loads ~/.riplrc before it does anything. This ruby file should
|
97
|
-
require and/or define plugins. Any ripl configurations via Ripl.config should also be done here.
|
98
|
-
For an example riplrc, see {mine}[http://github.com/cldwalker/dotfiles/tree/master/.riplrc].
|
99
|
-
|
100
132
|
== Available Plugins
|
101
133
|
|
102
134
|
* {ripl-rails}[http://github.com/cldwalker/ripl-rails] : script/console for ripl
|
103
135
|
* {ripl-color_error}[http://github.com/cldwalker/ripl-color_error] : colorize errors
|
104
136
|
* {ripl-after_rc}[http://github.com/cldwalker/ripl-after_rc] : provide blocks to run after ~/.irbrc is loaded
|
105
137
|
* {ripl-multi_line}[http://github.com/janlelis/ripl-multi_line] : evaluate multiple lines
|
138
|
+
* {ripl-irb}[http://github.com/cldwalker/ripl-irb] : smooths transition from irb
|
139
|
+
* {ripl-color_result}[http://github.com/janlelis/ripl-color_result] : colorizes results
|
140
|
+
* {nirvana}[http://github.com/cldwalker/nirvana]: Not a plugin but rather a web shell built on top of ripl
|
106
141
|
|
107
142
|
== Credits
|
108
143
|
* janlelis for bug fix and tweaks
|
data/lib/ripl/completion.rb
CHANGED
data/lib/ripl/version.rb
CHANGED
data/man/ripl.1
ADDED
@@ -0,0 +1,236 @@
|
|
1
|
+
.\" generated with Ronn/v0.7.3
|
2
|
+
.\" http://github.com/rtomayko/ronn/tree/0.7.3
|
3
|
+
.
|
4
|
+
.TH "RIPL" "1" "November 2010" "CLDWALKER" "Ripl Manual"
|
5
|
+
.
|
6
|
+
.SH "NAME"
|
7
|
+
\fBripl\fR \- Ruby Interactive Print Loop \- A light, modular alternative to irb
|
8
|
+
.
|
9
|
+
.SH "SYNOPSIS"
|
10
|
+
.
|
11
|
+
.nf
|
12
|
+
|
13
|
+
ripl [\-r|\-\-require] [\-I] [\-f] [\-d] [\-h|\-\-help] [\-v|\-\-version] COMMAND [ARGS]
|
14
|
+
.
|
15
|
+
.fi
|
16
|
+
.
|
17
|
+
.SH "DESCRIPTION"
|
18
|
+
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\. This customizability makes it easy to build custom shells (i\.e\. for a gem or application) and complex shells (i\.e\. for the web)\.
|
19
|
+
.
|
20
|
+
.SH "COMING FROM IRB"
|
21
|
+
When first trying ripl, you may experience errors in your ~/\.irbrc due to an irb\-specific configuration\. In order to have ripl and irb coexist peacefully, you should silence these errors\. To silence them without touching your ~/\.irbrc, install the ripl\-irb gem\. This ripl plugin fakes irb\'s existence, effectively ignoring irb\-specific configuration\. Otherwise, if you don\'t mind modifying ~/\.irbrc, wrap your irb\-specific configuration in a block as follow:
|
22
|
+
.
|
23
|
+
.IP "" 4
|
24
|
+
.
|
25
|
+
.nf
|
26
|
+
|
27
|
+
if defined? IRB
|
28
|
+
IRB\.conf[:BLAH] = \'blah\'
|
29
|
+
# \.\.\.
|
30
|
+
end
|
31
|
+
.
|
32
|
+
.fi
|
33
|
+
.
|
34
|
+
.IP "" 0
|
35
|
+
.
|
36
|
+
.SH "CONFIGURATION"
|
37
|
+
All ripl shells load the ruby file ~/\.riplrc if it exists\. In this file, plugins are required and configuration options are set\. To configure ripl and its plugins, use Ripl\.config\. By default, Ripl\.config is a hash with the following keys:
|
38
|
+
.
|
39
|
+
.TP
|
40
|
+
\fB:binding\fR
|
41
|
+
Binding to use for eval()\. Default is TOPLEVEL_BINDING\.
|
42
|
+
.
|
43
|
+
.TP
|
44
|
+
\fB:completion\fR
|
45
|
+
A hash that configures completion via Bond\.start\. See bond for more details\.
|
46
|
+
.
|
47
|
+
.TP
|
48
|
+
\fB:history\fR
|
49
|
+
A file used to store input history\. Default is \'~/\.irb_history\'\.
|
50
|
+
.
|
51
|
+
.TP
|
52
|
+
\fB:irbrc\fR
|
53
|
+
A ruby file to load at startup or false to not load anything\. Default is \'~/\.irbrc\'\.
|
54
|
+
.
|
55
|
+
.TP
|
56
|
+
\fB:name\fR
|
57
|
+
Name of the shell\. Default is \'ripl\'\.
|
58
|
+
.
|
59
|
+
.TP
|
60
|
+
\fB:prompt\fR
|
61
|
+
A string or lambda to generate string that prompts user for input\. Default is \'>> \'\.
|
62
|
+
.
|
63
|
+
.TP
|
64
|
+
\fB:readline\fR
|
65
|
+
A boolean to enable Readline\. Default is true\.
|
66
|
+
.
|
67
|
+
.TP
|
68
|
+
\fB:result_prompt\fR
|
69
|
+
A string that prefixes the result of an eval\. Default is \'=> \'\.
|
70
|
+
.
|
71
|
+
.P
|
72
|
+
Plugins can optionally provide their own config key(s) for use here\. It is strongly recommended that a plugin start with an underscored version of its name i\.e\. Ripl::ColorError \-> Ripl\.config[:color_error]\.
|
73
|
+
.
|
74
|
+
.P
|
75
|
+
An example ~/\.riplrc:
|
76
|
+
.
|
77
|
+
.IP "" 4
|
78
|
+
.
|
79
|
+
.nf
|
80
|
+
|
81
|
+
require \'ripl/multi_line\'
|
82
|
+
require \'ripl/color_error\'
|
83
|
+
Ripl\.config[:color_error] = :blue
|
84
|
+
.
|
85
|
+
.fi
|
86
|
+
.
|
87
|
+
.IP "" 0
|
88
|
+
.
|
89
|
+
.SH "PLUGINS"
|
90
|
+
A ripl plugin is a module that is included into Ripl::Shell or Ripl::Runner\. Being simply modules, they can be packaged as gems and reused across shells as needed\. ripl highly encourages plugins by loading them as early as possible and allowing them to extend most of ripl\'s functionality\. As mentioned in the \fBCONFIGURATION\fR section, a plugin can be configured via Ripl\.config\.
|
91
|
+
.
|
92
|
+
.P
|
93
|
+
To always use a plugin, require it in ~/\.riplrc\. To sometimes use it, require it from the commandline:
|
94
|
+
.
|
95
|
+
.IP "" 4
|
96
|
+
.
|
97
|
+
.nf
|
98
|
+
|
99
|
+
$ ripl \-rripl/multi_line
|
100
|
+
.
|
101
|
+
.fi
|
102
|
+
.
|
103
|
+
.IP "" 0
|
104
|
+
.
|
105
|
+
.P
|
106
|
+
Plugins can also be required in the console but it is not recommended since plugins can depend on initialization that occurs before the console is started\. For this same reason, plugins should not be required in ~/\.irbrc\.
|
107
|
+
.
|
108
|
+
.SH "CREATE PLUGINS"
|
109
|
+
For an example shell plugin, let\'s color error messages red:
|
110
|
+
.
|
111
|
+
.IP "" 4
|
112
|
+
.
|
113
|
+
.nf
|
114
|
+
|
115
|
+
# Place in ~/\.riplrc
|
116
|
+
module Ripl
|
117
|
+
module RedError
|
118
|
+
def format_error(error)
|
119
|
+
"\ee[31m#{super}\ee[m"
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
Ripl::Shell\.send :include, Ripl::RedError
|
124
|
+
.
|
125
|
+
.fi
|
126
|
+
.
|
127
|
+
.IP "" 0
|
128
|
+
.
|
129
|
+
.P
|
130
|
+
Note this plugin extends format_error() by invoking the original format_error() with super\. To see what methods are available for extension, see Ripl::Shell::API and Ripl::Runner::API\.
|
131
|
+
.
|
132
|
+
.P
|
133
|
+
Points to consider when creating plugins:
|
134
|
+
.
|
135
|
+
.IP "\(bu" 4
|
136
|
+
When adding functionality to a method, make sure to call \fBsuper\fR to preserve existing functionality\.
|
137
|
+
.
|
138
|
+
.IP "\(bu" 4
|
139
|
+
When replacing functionality for a method, make sure the method\'s expectations are met i\.e\. setting a specific instance variable\. Failure to do so, will \fBbreak\fR ripl for you and anyone else who uses your plugin!
|
140
|
+
.
|
141
|
+
.IP "\(bu" 4
|
142
|
+
Plugins can setup and teardown anything around a shell by extending Shell#before_loop and Shell#after_loop:
|
143
|
+
.
|
144
|
+
.IP
|
145
|
+
module Ripl::MyPlugin
|
146
|
+
.
|
147
|
+
.IP "" 4
|
148
|
+
.
|
149
|
+
.nf
|
150
|
+
|
151
|
+
def before_loop
|
152
|
+
super
|
153
|
+
Ripl\.config[:my_plugin] ||= :web_scale
|
154
|
+
end
|
155
|
+
|
156
|
+
def after_loop
|
157
|
+
super
|
158
|
+
# Write to files
|
159
|
+
# close a connection
|
160
|
+
# \.\.\.
|
161
|
+
end
|
162
|
+
.
|
163
|
+
.fi
|
164
|
+
.
|
165
|
+
.IP "" 0
|
166
|
+
.
|
167
|
+
.IP
|
168
|
+
end
|
169
|
+
.
|
170
|
+
.IP "\(bu" 4
|
171
|
+
To add configuration for a plugin, add a key to Ripl\.config that matches the underscored version of the plugin name i\.e\. Ripl::RedError \-> Ripl\.config[:red_error]\. To set a default config value, see the previous example\.
|
172
|
+
.
|
173
|
+
.IP "\(bu" 4
|
174
|
+
For more examples of plugins, see gems I\'ve made that start with \'ripl\-\'\.
|
175
|
+
.
|
176
|
+
.IP "" 0
|
177
|
+
.
|
178
|
+
.SH "CREATE CUSTOM SHELLS"
|
179
|
+
Creating and starting a custom shell is as simple as:
|
180
|
+
.
|
181
|
+
.IP "" 4
|
182
|
+
.
|
183
|
+
.nf
|
184
|
+
|
185
|
+
require \'ripl\'
|
186
|
+
# Define plugins, load files, etc\.\.\.
|
187
|
+
Ripl\.start
|
188
|
+
.
|
189
|
+
.fi
|
190
|
+
.
|
191
|
+
.IP "" 0
|
192
|
+
.
|
193
|
+
.P
|
194
|
+
Ripl\.start takes the same config keys mentioned in the \fBCONFIGURATION\fR section\. For example if you wanted to start on a specific binding:
|
195
|
+
.
|
196
|
+
.IP "" 4
|
197
|
+
.
|
198
|
+
.nf
|
199
|
+
|
200
|
+
Ripl\.start :binding => MyClass\.send(:binding)
|
201
|
+
.
|
202
|
+
.fi
|
203
|
+
.
|
204
|
+
.IP "" 0
|
205
|
+
.
|
206
|
+
.P
|
207
|
+
Also, since all shells load ~/\.riplrc, Ripl\.start can be used to override undesirable global configuration for a custom shell\.
|
208
|
+
.
|
209
|
+
.SH "COMMANDS"
|
210
|
+
A ripl command is a command passed to ripl that loads a custom shell\. It\'s a convenient way to package and invoke custom shells\. A ripl command can take standard ripl options as long as they are before the command:
|
211
|
+
.
|
212
|
+
.IP "" 4
|
213
|
+
.
|
214
|
+
.nf
|
215
|
+
|
216
|
+
# Load rails console without ~/\.irbrc
|
217
|
+
$ ripl \-f rails
|
218
|
+
|
219
|
+
# Load rails console with debugger
|
220
|
+
$ ripl \-rrdebug rails
|
221
|
+
.
|
222
|
+
.fi
|
223
|
+
.
|
224
|
+
.IP "" 0
|
225
|
+
.
|
226
|
+
.P
|
227
|
+
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\'\. Any arguments to a ripl command can be parsed as the ripl command pleases i\.e\. into options and arguments\. For an example command, see ripl\-rails \fIhttp://github\.com/cldwalker/ripl\-rails\fR\.
|
228
|
+
.
|
229
|
+
.SH "BUGS"
|
230
|
+
Please report bugs at \fIhttp://github\.com/cldwalker/ripl/issues\fR\.
|
231
|
+
.
|
232
|
+
.SH "COPYRIGHT"
|
233
|
+
\fBripl\fR is Copyright (C) 2010 Gabriel Horner
|
234
|
+
.
|
235
|
+
.SH "SEE ALSO"
|
236
|
+
\fIhttp://github\.com/cldwalker/ripl\fR, \fIhttp://github\.com/cldwalker/bond\fR, \fIhttp://github\.com/cldwalker/nirvana\fR, \fIhttp://github\.com/cldwalker/ripl\-irb\fR, \fIhttp://github\.com/cldwalker/ripl\-rails\fR, \fIhttp://github\.com/janlelis/multi_line\fR
|
data/man/ripl.1.ronn
ADDED
@@ -0,0 +1,174 @@
|
|
1
|
+
ripl(1) -- Ruby Interactive Print Loop - A light, modular alternative to irb
|
2
|
+
====================================
|
3
|
+
|
4
|
+
## SYNOPSIS
|
5
|
+
|
6
|
+
ripl [-r|--require] [-I] [-f] [-d] [-h|--help] [-v|--version] COMMAND [ARGS]
|
7
|
+
|
8
|
+
## DESCRIPTION
|
9
|
+
|
10
|
+
ripl is a light, modular alternative to irb. Like irb, it loads ~/.irbrc, has autocompletion and
|
11
|
+
keeps history in ~/.irb_history. Unlike irb, it is highly customizable via plugins and supports
|
12
|
+
commands. This customizability makes it easy to build custom shells (i.e. for a gem or application)
|
13
|
+
and complex shells (i.e. for the web).
|
14
|
+
|
15
|
+
## COMING FROM IRB
|
16
|
+
|
17
|
+
When first trying ripl, you may experience errors in your ~/.irbrc due to an irb-specific
|
18
|
+
configuration. In order to have ripl and irb coexist peacefully, you should silence these errors.
|
19
|
+
To silence them without touching your ~/.irbrc, install the ripl-irb gem. This ripl plugin fakes
|
20
|
+
irb's existence, effectively ignoring irb-specific configuration. Otherwise, if you don't mind
|
21
|
+
modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:
|
22
|
+
|
23
|
+
if defined? IRB
|
24
|
+
IRB.conf[:BLAH] = 'blah'
|
25
|
+
# ...
|
26
|
+
end
|
27
|
+
|
28
|
+
## CONFIGURATION
|
29
|
+
|
30
|
+
All ripl shells load the ruby file ~/.riplrc if it exists. In this file, plugins are required and
|
31
|
+
configuration options are set. To configure ripl and its plugins, use Ripl.config. By default,
|
32
|
+
Ripl.config is a hash with the following keys:
|
33
|
+
|
34
|
+
* `:binding`:
|
35
|
+
Binding to use for eval(). Default is TOPLEVEL_BINDING.
|
36
|
+
|
37
|
+
* `:completion`:
|
38
|
+
A hash that configures completion via Bond.start. See bond for more details.
|
39
|
+
|
40
|
+
* `:history`:
|
41
|
+
A file used to store input history. Default is '~/.irb_history'.
|
42
|
+
|
43
|
+
* `:irbrc`:
|
44
|
+
A ruby file to load at startup or false to not load anything. Default is '~/.irbrc'.
|
45
|
+
|
46
|
+
* `:name`:
|
47
|
+
Name of the shell. Default is 'ripl'.
|
48
|
+
|
49
|
+
* `:prompt`:
|
50
|
+
A string or lambda to generate string that prompts user for input. Default is '>> '.
|
51
|
+
|
52
|
+
* `:readline`:
|
53
|
+
A boolean to enable Readline. Default is true.
|
54
|
+
|
55
|
+
* `:result_prompt`:
|
56
|
+
A string that prefixes the result of an eval. Default is '=> '.
|
57
|
+
|
58
|
+
Plugins can optionally provide their own config key(s) for use here. It is strongly recommended that
|
59
|
+
a plugin start with an underscored version of its name i.e. Ripl::ColorError -> Ripl.config[:color_error].
|
60
|
+
|
61
|
+
An example ~/.riplrc:
|
62
|
+
|
63
|
+
require 'ripl/multi_line'
|
64
|
+
require 'ripl/color_error'
|
65
|
+
Ripl.config[:color_error] = :blue
|
66
|
+
|
67
|
+
## PLUGINS
|
68
|
+
|
69
|
+
A ripl plugin is a module that is included into Ripl::Shell or Ripl::Runner. Being simply modules,
|
70
|
+
they can be packaged as gems and reused across shells as needed. ripl highly encourages plugins by
|
71
|
+
loading them as early as possible and allowing them to extend most of ripl's functionality. As
|
72
|
+
mentioned in the `CONFIGURATION` section, a plugin can be configured via Ripl.config.
|
73
|
+
|
74
|
+
To always use a plugin, require it in ~/.riplrc. To sometimes use it, require it from
|
75
|
+
the commandline:
|
76
|
+
|
77
|
+
$ ripl -rripl/multi_line
|
78
|
+
|
79
|
+
Plugins can also be required in the console but it is not recommended since plugins can depend on
|
80
|
+
initialization that occurs before the console is started. For this same reason, plugins should not
|
81
|
+
be required in ~/.irbrc.
|
82
|
+
|
83
|
+
## CREATE PLUGINS
|
84
|
+
|
85
|
+
For an example shell plugin, let's color error messages red:
|
86
|
+
|
87
|
+
# Place in ~/.riplrc
|
88
|
+
module Ripl
|
89
|
+
module RedError
|
90
|
+
def format_error(error)
|
91
|
+
"\e[31m#{super}\e[m"
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
Ripl::Shell.send :include, Ripl::RedError
|
96
|
+
|
97
|
+
Note this plugin extends format_error() by invoking the original format_error() with super. To see
|
98
|
+
what methods are available for extension, see Ripl::Shell::API and Ripl::Runner::API.
|
99
|
+
|
100
|
+
Points to consider when creating plugins:
|
101
|
+
|
102
|
+
* When adding functionality to a method, make sure to call `super` to preserve existing functionality.
|
103
|
+
|
104
|
+
* When replacing functionality for a method, make sure the method's expectations are met i.e.
|
105
|
+
setting a specific instance variable. Failure to do so, will `break` ripl for you and anyone else
|
106
|
+
who uses your plugin!
|
107
|
+
|
108
|
+
* Plugins can setup and teardown anything around a shell by extending Shell#before_loop and Shell#after_loop:
|
109
|
+
|
110
|
+
module Ripl::MyPlugin
|
111
|
+
def before_loop
|
112
|
+
super
|
113
|
+
Ripl.config[:my_plugin] ||= :web_scale
|
114
|
+
end
|
115
|
+
|
116
|
+
def after_loop
|
117
|
+
super
|
118
|
+
# Write to files
|
119
|
+
# close a connection
|
120
|
+
# ...
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
* To add configuration for a plugin, add a key to Ripl.config that matches the underscored version
|
125
|
+
of the plugin name i.e. Ripl::RedError -> Ripl.config[:red_error]. To set a default config value, see
|
126
|
+
the previous example.
|
127
|
+
|
128
|
+
* For more examples of plugins, see gems I've made that start with 'ripl-'.
|
129
|
+
|
130
|
+
## CREATE CUSTOM SHELLS
|
131
|
+
|
132
|
+
Creating and starting a custom shell is as simple as:
|
133
|
+
|
134
|
+
require 'ripl'
|
135
|
+
# Define plugins, load files, etc...
|
136
|
+
Ripl.start
|
137
|
+
|
138
|
+
Ripl.start takes the same config keys mentioned in the `CONFIGURATION` section. For example if you wanted to
|
139
|
+
start on a specific binding:
|
140
|
+
|
141
|
+
Ripl.start :binding => MyClass.send(:binding)
|
142
|
+
|
143
|
+
Also, since all shells load ~/.riplrc, Ripl.start can be used to override undesirable global
|
144
|
+
configuration for a custom shell.
|
145
|
+
|
146
|
+
## COMMANDS
|
147
|
+
|
148
|
+
A ripl command is a command passed to ripl that loads a custom shell. It's a convenient way to
|
149
|
+
package and invoke custom shells. A ripl command can take standard ripl options as long as they are
|
150
|
+
before the command:
|
151
|
+
|
152
|
+
# Load rails console without ~/.irbrc
|
153
|
+
$ ripl -f rails
|
154
|
+
|
155
|
+
# Load rails console with debugger
|
156
|
+
$ ripl -rrdebug rails
|
157
|
+
|
158
|
+
To create a ripl command, create an executable in the format ripl-command and make sure it's in your
|
159
|
+
shell's $PATH. For example, the file 'ripl-my_gem' would be invoked with 'ripl my_gem'. Any
|
160
|
+
arguments to a ripl command can be parsed as the ripl command pleases i.e. into options and
|
161
|
+
arguments. For an example command, see [ripl-rails](http://github.com/cldwalker/ripl-rails).
|
162
|
+
|
163
|
+
## BUGS
|
164
|
+
|
165
|
+
Please report bugs at _http://github.com/cldwalker/ripl/issues_.
|
166
|
+
|
167
|
+
## COPYRIGHT
|
168
|
+
|
169
|
+
`ripl` is Copyright (C) 2010 Gabriel Horner
|
170
|
+
|
171
|
+
## SEE ALSO
|
172
|
+
|
173
|
+
<http://github.com/cldwalker/ripl>, <http://github.com/cldwalker/bond>, <http://github.com/cldwalker/nirvana>,
|
174
|
+
<http://github.com/cldwalker/ripl-irb>, <http://github.com/cldwalker/ripl-rails>, <http://github.com/janlelis/multi_line>
|
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
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 2
|
10
|
+
version: 0.2.2
|
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-11-
|
18
|
+
date: 2010-11-14 00:00:00 -05:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,12 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ~>
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 21
|
30
30
|
segments:
|
31
31
|
- 0
|
32
32
|
- 3
|
33
|
-
-
|
34
|
-
version: 0.3.
|
33
|
+
- 3
|
34
|
+
version: 0.3.3
|
35
35
|
type: :runtime
|
36
36
|
version_requirements: *id001
|
37
37
|
- !ruby/object:Gem::Dependency
|
@@ -80,7 +80,7 @@ dependencies:
|
|
80
80
|
version: "0"
|
81
81
|
type: :development
|
82
82
|
version_requirements: *id004
|
83
|
-
description:
|
83
|
+
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. This customizability makes it easy to build custom shells (i.e. for a gem or application) and complex shells (i.e. for the web).
|
84
84
|
email: gabriel.horner@gmail.com
|
85
85
|
executables:
|
86
86
|
- ripl
|
@@ -108,6 +108,8 @@ files:
|
|
108
108
|
- test/deps.rip
|
109
109
|
- Rakefile
|
110
110
|
- .gemspec
|
111
|
+
- man/ripl.1
|
112
|
+
- man/ripl.1.ronn
|
111
113
|
has_rdoc: true
|
112
114
|
homepage: http://github.com/cldwlaker/ripl
|
113
115
|
licenses:
|
@@ -143,6 +145,6 @@ rubyforge_project: tagaholic
|
|
143
145
|
rubygems_version: 1.3.7
|
144
146
|
signing_key:
|
145
147
|
specification_version: 3
|
146
|
-
summary: A light, modular alternative to irb
|
148
|
+
summary: Ruby Interactive Print Loop - A light, modular alternative to irb
|
147
149
|
test_files: []
|
148
150
|
|