auto gem install
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
module Kernel | |
def ruiby_require(*gems) | |
w=Ruiby_dialog.new | |
gems.flatten.each do|gem| | |
begin | |
require gem | |
rescue LoadError => e | |
rep=w.ask("<em>Loading #{gems.join(', ')}</em>\n\n'#{gem}' package is missing. Can I load it from internet ?") | |
exit! unless rep | |
require 'open3' | |
w.log("gem install #{gem} --no-ri --no-rdoc") | |
Gtk.main_iteration while Gtk.events_pending? | |
Open3.popen3("gem install #{gem}") { |si,so,se| | |
q=Queue.new | |
Thread.new { loop {q.push(so.gets) } rescue nil; q.push(nil)} | |
Thread.new { loop {q.push(se.gets) } rescue nil; q.push(nil)} | |
str="" | |
while str | |
timeout(1) { str=q.pop } rescue nil | |
(w.log(str);str="") if str && str.size>0 | |
Ruiby.update | |
end | |
} | |
w.log "done!" | |
Ruiby.update | |
Gem.clear_paths() | |
require(gem) | |
w.log("loading '#{gem}' ok!") | |
end | |
end | |
w.destroy() | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment