ripl 0.2.8 → 0.2.9

Sign up to get free protection for your applications and to get access to all the features.
data/.gemspec CHANGED
@@ -13,10 +13,11 @@ Gem::Specification.new do |s|
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.3'
16
+ s.add_dependency 'bond', '~> 0.3.4'
17
17
  s.add_development_dependency 'bacon', '>= 1.1.0'
18
18
  s.add_development_dependency 'rr', '>= 1.0.0'
19
19
  s.add_development_dependency 'bacon-bits'
20
+ s.add_development_dependency 'bacon-rr'
20
21
  s.files = Dir.glob(%w[{lib,test}/**/*.rb bin/* [A-Z]*.{txt,rdoc} ext/**/*.{rb,c} **/deps.rip]) + %w{Rakefile .gemspec}
21
22
  s.files += Dir.glob('man/*')
22
23
  s.extra_rdoc_files = ["README.rdoc", "LICENSE.txt"]
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,8 @@
1
+ == 0.2.9
2
+ * Add autoloaded plugin completions
3
+ * Make Shell#include public for plugins
4
+ * Rescue LoadError in .rc files
5
+
1
6
  == 0.2.8
2
7
  * Allow completion to be optional
3
8
  * Save commandline args to Ripl::Runner.argv
data/README.rdoc CHANGED
@@ -43,7 +43,7 @@ To view ripl's man page:
43
43
  When first trying ripl, you may experience errors in your ~/.irbrc due to an irb-specific
44
44
  configuration. In order to have ripl and irb coexist peacefully, you should silence these errors.
45
45
  To silence them without touching your ~/.irbrc, install the ripl-irb gem. This ripl plugin fakes
46
- irb's existence, effectively ignoring irb-specific configuration. Otherwise, if you don't mind
46
+ irb's existence and points to ripl equivalents for your irb configurations. Otherwise, if you don't mind
47
47
  modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:
48
48
 
49
49
  if defined? IRB
@@ -63,7 +63,7 @@ modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:
63
63
  * IRB.conf -> Ripl.config
64
64
  * Handles Ctrl-C quietly
65
65
  * Enhancements over irb
66
- * ~260 lines (doc included) vs irb's 5000+ lines
66
+ * ~270 lines (doc included) vs irb's 5000+ lines
67
67
  * Easily extendable with plugins
68
68
  * Tests and documentation!
69
69
  * Customizable completion and completion of method arguments (from bond)
@@ -100,7 +100,7 @@ As an example plugin, let's color error messages red:
100
100
  end
101
101
  end
102
102
  end
103
- Ripl::Shell.send :include, Ripl::RedError
103
+ Ripl::Shell.include Ripl::RedError
104
104
 
105
105
  Note this plugin extends format_error() by invoking the original format_error() with super. This is
106
106
  possible for any method that is available for extension by plugins. To see what methods are available for
@@ -156,14 +156,23 @@ see {ripl-rails}[http://github.com/cldwalker/ripl-rails].
156
156
  * {ripl-color_result}[http://github.com/janlelis/ripl-color_result] : colorizes results
157
157
  * {ripl-auto_indent}[http://github.com/janlelis/ripl-auto_indent] : auto indents multi-line input
158
158
  * {ripl-hirb}[http://github.com/cldwalker/hirb] : comes with hirb to make it a proper riplzen
159
+ * {ripl-hijack}[http://github.com/cldwalker/ripl-hijack] : ripl console to a ruby process
159
160
  * {ripl-misc}[http://github.com/cldwalker/ripl-misc] : a playground for ripl plugins
160
161
  * {ripl-profiles}[https://github.com/janlelis/ripl-profiles]: load ripl profiles with a --profile option
162
+ * {ripl-short_errors}[https://github.com/janlelis/ripl-misc/blob/master/lib/ripl/short_errors.rb]:
163
+ display short backtrace
161
164
 
162
165
  == Ripl Shells
163
166
  Shells built on top of ripl:
164
167
 
165
168
  * {nirvana}[http://github.com/cldwalker/nirvana]: A ruby web shell complete with autocomplete
166
169
  * {fresh}[http://github.com/janlelis/fresh]: An interesting ruby/system hybrid shell
170
+ * {ripl-johnson}[http://github.com/cldwalker/ripl-johnson]: A js shell based on johnson (firefox tracemonkey)
171
+
172
+ == More Ripl Links
173
+
174
+ * {ripl screencast}[http://www.rubypulse.com/ep0.51_ripl.html]
175
+ * {overview of ripl features}[http://rbjl.net/44-ripl-why-should-you-use-an-irb-alternative]
167
176
 
168
177
  == Irb Alternatives
169
178
  Some other irb alternatives to check out:
data/deps.rip CHANGED
@@ -1 +1 @@
1
- bond ~>0.3.3
1
+ bond ~>0.3.4
data/lib/ripl.rb CHANGED
@@ -5,10 +5,19 @@ module Ripl
5
5
 
6
6
  def self.start(*args); Runner.start(*args); end
7
7
 
8
+ def self.plugins
9
+ file = File.symlink?(__FILE__) ? File.readlink(__FILE__) : __FILE__
10
+ $".map {|e| e[/ripl\/[^\/]+$/] }.compact -
11
+ Dir["#{File.dirname(file)}/ripl/*.rb"].map {|e| e[/ripl\/[^\/]+$/] }
12
+ end
13
+
8
14
  def self.shell(options={})
9
15
  @shell ||= Shell.create(config.merge!(options))
10
16
  end
11
- module Commands; end
17
+
18
+ module Commands
19
+ class<<self; public :include; end
20
+ end
12
21
  end
13
22
 
14
23
  require 'ripl/shell'
@@ -3,8 +3,9 @@ require 'bond'
3
3
  module Ripl::Completion
4
4
  def before_loop
5
5
  super
6
+ (config[:completion][:gems] ||= []).concat Ripl.plugins
6
7
  Bond.restart config[:completion]
7
8
  end
8
9
  end
9
- Ripl::Shell.send :include, Ripl::Completion
10
+ Ripl::Shell.include Ripl::Completion
10
11
  Ripl.config[:completion][:eval_binding] = lambda { Ripl.shell.binding }
data/lib/ripl/history.rb CHANGED
@@ -21,5 +21,5 @@ module Ripl::History
21
21
  File.open(history_file, 'w') {|f| f.write Array(history).join("\n") }
22
22
  end
23
23
  end
24
- Ripl::Shell.send :include, Ripl::History
24
+ Ripl::Shell.include Ripl::History
25
25
  Ripl.config[:history] = '~/.irb_history'
data/lib/ripl/readline.rb CHANGED
@@ -6,4 +6,4 @@ module Ripl::Readline
6
6
 
7
7
  def history; Readline::HISTORY; end
8
8
  end
9
- Ripl::Shell.send :include, Ripl::Readline
9
+ Ripl::Shell.include Ripl::Readline
data/lib/ripl/runner.rb CHANGED
@@ -64,7 +64,7 @@ module Ripl::Runner
64
64
 
65
65
  def load_rc(file)
66
66
  load file if File.exists?(File.expand_path(file))
67
- rescue StandardError, SyntaxError
67
+ rescue StandardError, SyntaxError, LoadError
68
68
  warn "ripl: Error while loading #{file}:\n"+ format_error($!)
69
69
  end
70
70
 
data/lib/ripl/shell.rb CHANGED
@@ -1,8 +1,4 @@
1
1
  class Ripl::Shell
2
- OPTIONS = {:name=>'ripl', :result_prompt=>'=> ', :prompt=>'>> ',
3
- :binding=>TOPLEVEL_BINDING, :irbrc=>'~/.irbrc'}
4
- EXIT_WORDS = [nil, 'exit', 'quit']
5
-
6
2
  def self.create(options={})
7
3
  require 'ripl/readline' if options[:readline]
8
4
  require 'ripl/completion' if options[:completion]
@@ -11,6 +7,12 @@ class Ripl::Shell
11
7
  new(options)
12
8
  end
13
9
 
10
+ class <<self; public :include; end
11
+
12
+ OPTIONS = {:name=>'ripl', :result_prompt=>'=> ', :prompt=>'>> ',
13
+ :binding=>TOPLEVEL_BINDING, :irbrc=>'~/.irbrc'}
14
+ EXIT_WORDS = [nil, 'exit', 'quit']
15
+
14
16
  attr_accessor :line, :binding, :result, :name
15
17
  def initialize(options={})
16
18
  options = OPTIONS.merge options
data/lib/ripl/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Ripl
2
- VERSION = '0.2.8'
2
+ VERSION = '0.2.9'
3
3
  end
data/man/ripl.1 CHANGED
@@ -18,7 +18,7 @@ ripl [COMMAND] [\-r|\-\-require] [\-I] [\-f] [\-d] [\-h|\-\-help] [\-v|\-\-versi
18
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
19
  .
20
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:
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 and points to ripl equivalents for your irb configurations\. Otherwise, if you don\'t mind modifying ~/\.irbrc, wrap your irb\-specific configuration in a block as follow:
22
22
  .
23
23
  .IP "" 4
24
24
  .
@@ -122,7 +122,7 @@ module Ripl
122
122
  end
123
123
  end
124
124
  end
125
- Ripl::Shell\.send :include, Ripl::RedError
125
+ Ripl::Shell\.include Ripl::RedError
126
126
  .
127
127
  .fi
128
128
  .
@@ -196,12 +196,18 @@ end
196
196
  end
197
197
  .
198
198
  .IP
199
- Ripl::Commands\.send :include, Ripl::SuperHistory::Commands
199
+ Ripl::Commands\.include Ripl::SuperHistory::Commands
200
200
  .
201
201
  .IP
202
202
  >> history # use command in ripl
203
203
  .
204
204
  .IP "\(bu" 4
205
+ To define custom autocompletion for a plugin and its commands, create a completion file in lib/ripl/completions/plugin_name i\.e\. ripl\-super_history plugin \-> lib/ripl/completions/super_history\.rb\. The syntax of this file is explained in bond\'s docs \fIhttp://tagaholic\.me/bond/doc/Bond/Rc\.html\fR\. To autocomplete a console command, define a :method completion\. For an example plugin that uses this, see ripl\-commands \fIhttp://github\.com/cldwalker/ripl\-commands\fR\.
206
+ .
207
+ .IP "\(bu" 4
208
+ 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
+ .IP "\(bu" 4
205
211
  For more examples of plugins, see gems I\'ve made that start with \'ripl\-\'\.
206
212
  .
207
213
  .IP "" 0
data/man/ripl.1.html CHANGED
@@ -95,7 +95,7 @@ and complex shells (i.e. for the web).</p>
95
95
  <p>When first trying ripl, you may experience errors in your ~/.irbrc due to an irb-specific
96
96
  configuration. In order to have ripl and irb coexist peacefully, you should silence these errors.
97
97
  To silence them without touching your ~/.irbrc, install the ripl-irb gem. This ripl plugin fakes
98
- irb's existence, effectively ignoring irb-specific configuration. Otherwise, if you don't mind
98
+ irb's existence and points to ripl equivalents for your irb configurations. Otherwise, if you don't mind
99
99
  modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:</p>
100
100
 
101
101
  <pre><code>if defined? IRB
@@ -164,7 +164,7 @@ module Ripl
164
164
  end
165
165
  end
166
166
  end
167
- Ripl::Shell.send :include, Ripl::RedError
167
+ Ripl::Shell.include Ripl::RedError
168
168
  </code></pre>
169
169
 
170
170
  <p>Note this plugin extends format_error() by invoking the original format_error() with super. To see
@@ -211,9 +211,16 @@ end
211
211
 
212
212
  <p> end</p>
213
213
 
214
- <p> Ripl::Commands.send :include, Ripl::SuperHistory::Commands</p>
214
+ <p> Ripl::Commands.include Ripl::SuperHistory::Commands</p>
215
215
 
216
216
  <p> >> history # use command in ripl</p></li>
217
+ <li><p>To define custom autocompletion for a plugin and its commands, create a completion file in
218
+ lib/ripl/completions/plugin_name i.e. ripl-super_history plugin -> lib/ripl/completions/super_history.rb.
219
+ The syntax of this file is explained <a href="http://tagaholic.me/bond/doc/Bond/Rc.html">in bond's docs</a>.
220
+ To autocomplete a console command, define a :method completion. For an example plugin that uses this, see
221
+ <a href="http://github.com/cldwalker/ripl-commands">ripl-commands</a>.</p></li>
222
+ <li><p>For plugins with console commands, commands aren't immediately recognized if the plugin is required within ripl.
223
+ To fix this: Ripl.shell.add_commands(self).</p></li>
217
224
  <li><p>For more examples of plugins, see gems I've made that start with 'ripl-'.</p></li>
218
225
  </ul>
219
226
 
data/man/ripl.1.ronn CHANGED
@@ -17,7 +17,7 @@ and complex shells (i.e. for the web).
17
17
  When first trying ripl, you may experience errors in your ~/.irbrc due to an irb-specific
18
18
  configuration. In order to have ripl and irb coexist peacefully, you should silence these errors.
19
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
20
+ irb's existence and points to ripl equivalents for your irb configurations. Otherwise, if you don't mind
21
21
  modifying ~/.irbrc, wrap your irb-specific configuration in a block as follow:
22
22
 
23
23
  if defined? IRB
@@ -95,7 +95,7 @@ For an example shell plugin, let's color error messages red:
95
95
  end
96
96
  end
97
97
  end
98
- Ripl::Shell.send :include, Ripl::RedError
98
+ Ripl::Shell.include Ripl::RedError
99
99
 
100
100
  Note this plugin extends format_error() by invoking the original format_error() with super. To see
101
101
  what methods are available for extension, see Ripl::Shell::API and Ripl::Runner::API.
@@ -138,10 +138,19 @@ Points to consider when creating plugins:
138
138
  end
139
139
  end
140
140
 
141
- Ripl::Commands.send :include, Ripl::SuperHistory::Commands
141
+ Ripl::Commands.include Ripl::SuperHistory::Commands
142
142
 
143
143
  \>\> history # use command in ripl
144
144
 
145
+ * To define custom autocompletion for a plugin and its commands, create a completion file in
146
+ lib/ripl/completions/plugin_name i.e. ripl-super_history plugin -> lib/ripl/completions/super_history.rb.
147
+ The syntax of this file is explained [in bond's docs](http://tagaholic.me/bond/doc/Bond/Rc.html).
148
+ To autocomplete a console command, define a :method completion. For an example plugin that uses this, see
149
+ [ripl-commands](http://github.com/cldwalker/ripl-commands).
150
+
151
+ * For plugins with console commands, commands aren't immediately recognized if the plugin is required within ripl.
152
+ To fix this: Ripl.shell.add_commands(self).
153
+
145
154
  * For more examples of plugins, see gems I've made that start with 'ripl-'.
146
155
 
147
156
  ## CREATE CUSTOM SHELLS
@@ -0,0 +1,29 @@
1
+ require File.join(File.dirname(__FILE__), 'test_helper')
2
+
3
+ describe "Completion" do
4
+ describe "#before_loop" do
5
+ before_all do
6
+ require 'ripl/completion'
7
+ @shell = Object.new.extend(
8
+ Module.new {
9
+ attr_accessor :config
10
+ def before_loop; end
11
+ }).extend Ripl::Completion
12
+ end
13
+
14
+ before { @shell.config = {:completion => {}} }
15
+ after { $".pop }
16
+
17
+ it "adds gem plugin to config" do
18
+ $" << '/dir/ripl/some_plugin.rb'
19
+ mock(Bond).restart(:gems =>['ripl/some_plugin.rb'])
20
+ @shell.before_loop
21
+ end
22
+
23
+ it "doesn't add local plugin to config" do
24
+ $" << '/dir/ripl/completion.rb'
25
+ mock(Bond).restart(:gems =>[])
26
+ @shell.before_loop
27
+ end
28
+ end
29
+ end
data/test/deps.rip CHANGED
@@ -1,3 +1,4 @@
1
1
  bacon >=1.1.0
2
2
  rr >=1.0.0
3
- bacon-bits >=0
3
+ bacon-bits >=0
4
+ bacon-rr >=0
data/test/runner_test.rb CHANGED
@@ -49,11 +49,17 @@ describe "Runner" do
49
49
  Ripl.config[:blah].should == true
50
50
  end
51
51
 
52
- it "catches and prints error" do
52
+ it "rescues and prints SyntaxError" do
53
53
  mock(Runner).load(anything) { raise SyntaxError }
54
54
  mock_shell
55
55
  capture_stderr { Runner.run([]) }.should =~ %r{^ripl: Error while loading ~/.riplrc:\nSyntaxError:}
56
56
  end
57
+
58
+ it "rescues and prints LoadError" do
59
+ mock(Runner).load(anything) { raise LoadError }
60
+ mock_shell
61
+ capture_stderr { Runner.run([]) }.should =~ %r{^ripl: Error while loading ~/.riplrc:\nLoadError:}
62
+ end
57
63
  end
58
64
 
59
65
  describe "with subcommand" do
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: 7
4
+ hash: 5
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 8
10
- version: 0.2.8
9
+ - 9
10
+ version: 0.2.9
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-13 00:00:00 -05:00
18
+ date: 2010-12-24 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: 21
29
+ hash: 27
30
30
  segments:
31
31
  - 0
32
32
  - 3
33
- - 3
34
- version: 0.3.3
33
+ - 4
34
+ version: 0.3.4
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
@@ -80,6 +80,20 @@ dependencies:
80
80
  version: "0"
81
81
  type: :development
82
82
  version_requirements: *id004
83
+ - !ruby/object:Gem::Dependency
84
+ name: bacon-rr
85
+ prerelease: false
86
+ requirement: &id005 !ruby/object:Gem::Requirement
87
+ none: false
88
+ requirements:
89
+ - - ">="
90
+ - !ruby/object:Gem::Version
91
+ hash: 3
92
+ segments:
93
+ - 0
94
+ version: "0"
95
+ type: :development
96
+ version_requirements: *id005
83
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).
84
98
  email: gabriel.horner@gmail.com
85
99
  executables:
@@ -97,6 +111,7 @@ files:
97
111
  - lib/ripl/shell.rb
98
112
  - lib/ripl/version.rb
99
113
  - lib/ripl.rb
114
+ - test/completion_test.rb
100
115
  - test/runner_test.rb
101
116
  - test/shell_test.rb
102
117
  - test/test_helper.rb