Last active
December 15, 2017 09:06
-
-
Save unak/6b5838644fa629c5a58212097c274a19 to your computer and use it in GitHub Desktop.
allruby script for Windows
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@echo off | |
C:\opt\ruby\bin\ruby.exe -x %~f0 %* | |
goto :EOF | |
#!ruby | |
require "yaml" | |
cache = File.join(File.dirname(__FILE__), "allruby.cache") | |
if File.exist?(cache) | |
rubies = YAML.load(File.read(cache)) | |
else | |
rubies = {} | |
end | |
changed = false | |
Dir.glob("C:/opt/*/bin/ruby.exe").each do |ruby| | |
unless rubies.include?(ruby) | |
rubies[ruby] = `#{ruby} -v`.chomp.chomp | |
changed = true | |
end | |
end | |
File.write(cache, rubies.to_yaml) if changed | |
rubies.sort_by{|_, v| v}.each do |ruby, _| | |
puts rubies[ruby] | |
system(ruby, *ARGV) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
expects that all rubies are installed in
C:/opt/*
directory (likeC:/opt/ruby-2.4.3
), and there is "base ruby" inC:/opt/ruby
.Change line 2 and 14 for your environment.