[macruby-changes] [4657] DietRB/trunk/bin/dietrb

source_changes at macosforge.org source_changes at macosforge.org
Fri Oct 8 03:55:10 PDT 2010


Revision: 4657
          http://trac.macosforge.org/projects/ruby/changeset/4657
Author:   eloy.de.enige at gmail.com
Date:     2010-10-08 03:55:09 -0700 (Fri, 08 Oct 2010)
Log Message:
-----------
Added support for passing a file to irb. Not sure yet about this simple way of handling it in the binary, or that it should be a library abbility.

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

Modified Paths:
--------------
    DietRB/trunk/bin/dietrb

Modified: DietRB/trunk/bin/dietrb
===================================================================
--- DietRB/trunk/bin/dietrb	2010-10-08 10:55:01 UTC (rev 4656)
+++ DietRB/trunk/bin/dietrb	2010-10-08 10:55:09 UTC (rev 4657)
@@ -21,4 +21,16 @@
 end
 
 IRB.formatter.filter_from_backtrace << /^#{__FILE__}/
-irb(self, TOPLEVEL_BINDING)
\ No newline at end of file
+
+if ARGV.empty?
+  irb(self, TOPLEVEL_BINDING.dup)
+else
+  path = ARGV.shift
+  context = IRB::Context.new(self, TOPLEVEL_BINDING.dup)
+  File.open(path, 'r') do |file|
+    file.each_line do |line|
+      puts IRB.formatter.prompt(context) + line
+      context.process_line(line)
+    end
+  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/dc57f08e/attachment.html>


More information about the macruby-changes mailing list