[macruby-changes] [4646] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 03:53:32 PDT 2010
Revision: 4646
http://trac.macosforge.org/projects/ruby/changeset/4646
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 03:53:31 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Add the --simple-prompt option.
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/bin/dietrb
DietRB/trunk/lib/irb/formatter.rb
DietRB/trunk/spec/formatter_spec.rb
Modified: DietRB/trunk/bin/dietrb
===================================================================
--- DietRB/trunk/bin/dietrb 2010-10-08 10:53:21 UTC (rev 4645)
+++ DietRB/trunk/bin/dietrb 2010-10-08 10:53:31 UTC (rev 4646)
@@ -1,5 +1,7 @@
#!/usr/bin/env ruby
+require 'irb'
+
unless ARGV.empty?
require 'optparse'
@@ -9,6 +11,7 @@
opt.on("-r load-lib", "Loads the given library (same as `ruby -r')") { |lib| require lib }
opt.on("-d", "Set $DEBUG to true (same as `ruby -d')") { $DEBUG = true }
opt.on("-I path", "Add path to $LOAD_PATH") { |path| $LOAD_PATH.unshift(path) }
+ opt.on("--simple-prompt", "Simple prompt mode") { IRB.formatter = IRB::Formatter::SimplePrompt.new }
opt.on("-v", "--version", "Print the version of #{bin}") do
puts File.read(File.expand_path('../../VERSION', __FILE__))
exit
@@ -16,5 +19,4 @@
end.parse!(ARGV)
end
-require 'irb'
irb(self, TOPLEVEL_BINDING)
\ No newline at end of file
Modified: DietRB/trunk/lib/irb/formatter.rb
===================================================================
--- DietRB/trunk/lib/irb/formatter.rb 2010-10-08 10:53:21 UTC (rev 4645)
+++ DietRB/trunk/lib/irb/formatter.rb 2010-10-08 10:53:31 UTC (rev 4646)
@@ -1,5 +1,7 @@
module IRB
class << self
+ attr_writer :formatter
+
def formatter
@formatter ||= Formatter::Default.new
end
@@ -27,5 +29,13 @@
SYNTAX_ERROR % [line, message]
end
end
+
+ class SimplePrompt < Default
+ PROMPT = ">> "
+
+ def prompt(_)
+ PROMPT
+ end
+ end
end
end
\ No newline at end of file
Modified: DietRB/trunk/spec/formatter_spec.rb
===================================================================
--- DietRB/trunk/spec/formatter_spec.rb 2010-10-08 10:53:21 UTC (rev 4645)
+++ DietRB/trunk/spec/formatter_spec.rb 2010-10-08 10:53:31 UTC (rev 4646)
@@ -35,4 +35,14 @@
@formatter.syntax_error(2, "syntax error, unexpected '}'").should ==
"SyntaxError: compile error\n(irb):2: syntax error, unexpected '}'"
end
+end
+
+describe "IRB::Formatter::SimplePrompt" do
+ before do
+ @formatter = IRB::Formatter::SimplePrompt.new
+ end
+
+ it "returns a very simple prompt" do
+ @formatter.prompt(nil).should == ">> "
+ end
end
\ No newline at end of file
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/b9f9b962/attachment-0001.html>
More information about the macruby-changes
mailing list