[macruby-changes] [4604] DietRB/trunk
source_changes at macosforge.org
source_changes at macosforge.org
Fri Oct 8 03:47:22 PDT 2010
Revision: 4604
http://trac.macosforge.org/projects/ruby/changeset/4604
Author: eloy.de.enige at gmail.com
Date: 2010-10-08 03:47:21 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Evaluate the given code once it's valid.
From: Eloy Duran <eloy.de.enige at gmail.com>
Modified Paths:
--------------
DietRB/trunk/lib/irb/context.rb
DietRB/trunk/spec/context_spec.rb
Modified: DietRB/trunk/lib/irb/context.rb
===================================================================
--- DietRB/trunk/lib/irb/context.rb 2010-10-08 10:47:12 UTC (rev 4603)
+++ DietRB/trunk/lib/irb/context.rb 2010-10-08 10:47:21 UTC (rev 4604)
@@ -22,6 +22,10 @@
def run
while line = readline
@source << line
+ if @source.valid?
+ evaluate(@source)
+ clear_buffer
+ end
end
end
Modified: DietRB/trunk/spec/context_spec.rb
===================================================================
--- DietRB/trunk/spec/context_spec.rb 2010-10-08 10:47:12 UTC (rev 4603)
+++ DietRB/trunk/spec/context_spec.rb 2010-10-08 10:47:21 UTC (rev 4604)
@@ -64,7 +64,7 @@
end
end
-describe "IRB::Context, running in a simple readline loop" do
+describe "IRB::Context, when receiving input" do
before do
@context = IRB::Context.new(main)
end
@@ -80,4 +80,14 @@
@context.run
@context.source.to_s.should == "def foo\np :ok"
end
+
+ it "evaluates the buffered source once it's a valid code block" do
+ Readline.stub_input("def foo", ":ok", "end; p foo")
+ def @context.evaluate(source)
+ @evaled_source = source
+ end
+ @context.run
+ source = @context.instance_variable_get(:@evaled_source)
+ source.to_s.should == "def foo\n:ok\nend; p foo"
+ 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/cd4cc036/attachment.html>
More information about the macruby-changes
mailing list