[macruby-changes] [4617] DietRB/trunk

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 8 03:49:18 PDT 2010


Revision: 4617
          http://trac.macosforge.org/projects/ruby/changeset/4617
Author:   eloy.de.enige at gmail.com
Date:     2010-10-08 03:49:17 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Use the IRB(object) method to create and run a new context for the given object.

From: Eloy Duran <eloy.de.enige at gmail.com>

Modified Paths:
--------------
    DietRB/trunk/bin/dietrb
    DietRB/trunk/lib/irb.rb
    DietRB/trunk/spec/spec_helper.rb

Added Paths:
-----------
    DietRB/trunk/spec/irb_spec.rb

Modified: DietRB/trunk/bin/dietrb
===================================================================
--- DietRB/trunk/bin/dietrb	2010-10-08 10:49:07 UTC (rev 4616)
+++ DietRB/trunk/bin/dietrb	2010-10-08 10:49:17 UTC (rev 4617)
@@ -1,5 +1,4 @@
 #!/usr/bin/env ruby
 
 require 'irb'
-
-IRB::Context.new(self).run
\ No newline at end of file
+IRB(self)
\ No newline at end of file

Modified: DietRB/trunk/lib/irb.rb
===================================================================
--- DietRB/trunk/lib/irb.rb	2010-10-08 10:49:07 UTC (rev 4616)
+++ DietRB/trunk/lib/irb.rb	2010-10-08 10:49:17 UTC (rev 4617)
@@ -1,6 +1,15 @@
 require 'irb/context'
 require 'irb/source'
 
-# if defined?(RUBY_ENGINE) && RUBY_ENGINE == "macruby"
-#   require 'irb/ext/macruby'
-# end
\ No newline at end of file
+if !ENV['SPECCING'] && defined?(RUBY_ENGINE) && RUBY_ENGINE == "macruby"
+  require 'irb/ext/macruby'
+end
+
+module Kernel
+  # Creates a new IRB::Context with the given +object+ and runs it.
+  def IRB(object)
+    IRB::Context.new(object).run
+  end
+  
+  private :IRB
+end

Added: DietRB/trunk/spec/irb_spec.rb
===================================================================
--- DietRB/trunk/spec/irb_spec.rb	                        (rev 0)
+++ DietRB/trunk/spec/irb_spec.rb	2010-10-08 10:49:17 UTC (rev 4617)
@@ -0,0 +1,10 @@
+require File.expand_path('../spec_helper', __FILE__)
+
+describe "Kernel::IRB()" do
+  it "creates a new context for the given object and runs it" do
+    Readline.stub_input("::IRBRan = self")
+    o = Object.new
+    IRB(o)
+    IRBRan.should == o
+  end
+end
\ No newline at end of file

Modified: DietRB/trunk/spec/spec_helper.rb
===================================================================
--- DietRB/trunk/spec/spec_helper.rb	2010-10-08 10:49:07 UTC (rev 4616)
+++ DietRB/trunk/spec/spec_helper.rb	2010-10-08 10:49:17 UTC (rev 4617)
@@ -1,6 +1,8 @@
 require 'rubygems'
 require 'bacon'
 
+ENV['SPECCING'] = 'true'
+
 ROOT = File.expand_path('../../', __FILE__)
 $:.unshift File.join(ROOT, 'lib')
 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101008/3d37233e/attachment.html>


More information about the macruby-changes mailing list