Added: MacRuby/branches/experimental/bin/ruby_select (0 => 1897)
--- MacRuby/branches/experimental/bin/ruby_select (rev 0)
+++ MacRuby/branches/experimental/bin/ruby_select 2009-06-20 02:29:48 UTC (rev 1897)
@@ -0,0 +1,28 @@
+#!/usr/bin/ruby
+
+MACRUBY_FRAMEWORK = '/Library/Frameworks/MacRuby.framework'
+
+unless File.exist?(MACRUBY_FRAMEWORK)
+ $stderr.puts "Can't locate '#{MACRUBY_FRAMEWORK}'."
+ exit 1
+end
+
+versions = Dir.glob(File.join(MACRUBY_FRAMEWORK, 'Versions/*'))
+
+if ARGV.empty?
+ $stderr.puts "Usage: $ macruby_select [version] [ruby args ...]"
+ $stderr.puts "Example: $ macruby_select 0.4 -e 'p 42'"
+ $stderr.puts "Versions: #{versions.map{|x|File.basename(x)}.join(', ')}"
+ exit 1
+end
+
+vers = ARGV.shift
+path = versions.find { |x| File.basename(x) == vers }
+if path.nil?
+ $stderr.puts "Given version '#{vers}' cannot be found."
+ exit 1
+end
+
+line = "#{path}/usr/bin/macruby"
+ARGV.each { |x| line << ' \'' << x << '\' ' }
+system(line)
Property changes on: MacRuby/branches/experimental/bin/ruby_select
___________________________________________________________________