Forums Archived

The forums are being archived. See this topic for more information.

ruby 1.8/1.9 switcher script

Get help and support with Rubygame

ruby 1.8/1.9 switcher script

Postby shawn42 » Sun Feb 15, 2009 6:34 pm

Not for use by the faint of heart, but this may help some of those transitioning to ruby 1.9 that still want to be able to switch back to ruby1.8.

sudo setruby.rb -v
shows current version

sudo setruby.rb 1.8
switches to 1.8

sudo setruby.rb 1.9
switches to 1.9

Code: Select all
#!/usr/bin/env ruby
# script to toggle between ruby 1.8 and ruby 1.9
RUBY_ONE_EIGHT = [
'/usr/local/bin/gem1.8',
'/usr/local/bin/gem_mirror1.8',
'/usr/local/bin/gem_server1.8',
'/usr/local/bin/gemlock1.8',
'/usr/local/bin/gemri1.8',
'/usr/local/bin/gemwhich1.8',
'/usr/local/bin/irb1.8',
'/usr/local/bin/rake1.8',
'/usr/local/bin/ri1.8',
'/usr/local/bin/ruby1.8',
'/Users/sanderson/bin/rsdl1.8'
]

RUBY_ONE_NINE = [
'/usr/local/bin/gem1.9',
'/usr/local/bin/irb1.9',
'/usr/local/bin/ri1.9',
'/usr/local/bin/ruby1.9',
'/usr/local/bin/rake1.9',
'/Users/sanderson/bin/rsdl1.9'
]

VERSIONS = {
  '1.8' => RUBY_ONE_EIGHT,
  '1.9' => RUBY_ONE_NINE
}

target_version = ARGV[0]
if target_version.nil?
  version = `ruby -v`.strip
  puts "CURRENT VERSION IS: #{version}"
  exit 0
end

for ver,files in VERSIONS.select{|k,v|k!=target_version}
  for file in files
    symlink = file.chomp(ver)
    File.delete(symlink) if File.exist?(symlink)

  end
end

for ver,files in VERSIONS.select{|k,v|k==target_version}
  for file in files
    symlink = file.chomp(ver)
    File.delete(symlink) if File.exist?(symlink)
    File.symlink(file,symlink) if File.exist?(file)
  end
end
User avatar
shawn42
 
Posts: 109
Joined: Tue Feb 10, 2009 8:22 pm

Return to Help & Support

Who is online

Users browsing this forum: No registered users and 1 guest

cron