69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
|
# File 'lib/kompo/tasks/install_ruby.rb', line 69
def run
@ruby_version = Taski.args.fetch(:ruby_version, RUBY_VERSION)
@ruby_major_minor = ruby_major_and_minor(@ruby_version)
kompo_cache = Taski.args.fetch(:kompo_cache, File.expand_path("~/.kompo/cache"))
version_cache_dir = File.join(kompo_cache, @ruby_version)
cache_install_dir = File.join(version_cache_dir, "ruby")
work_dir = WorkDir.path
@ruby_install_dir = File.join(work_dir, "_ruby")
@ruby_path = File.join(@ruby_install_dir, "bin", "ruby")
@bundler_path = File.join(@ruby_install_dir, "bin", "bundler")
@ruby_build_path = File.join(@ruby_install_dir, "_build")
@original_ruby_install_dir = @ruby_install_dir
group("Restoring Ruby #{@ruby_version} from cache to #{work_dir}") do
FileUtils.rm_rf(@ruby_install_dir) if Dir.exist?(@ruby_install_dir)
FileUtils.cp_r(cache_install_dir, @ruby_install_dir)
puts "Restored from: #{version_cache_dir}"
end
fix_bin_shebangs(@ruby_install_dir, @ruby_path)
fix_ruby_pc(@ruby_install_dir)
puts "Ruby #{@ruby_version} restored from cache"
version_output, = Open3.capture2(@ruby_path, "--version", err: File::NULL)
puts "Ruby version: #{version_output.chomp}"
end
|