2019-05-02 18:17:27 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-01-09 17:10:14 -05:00
|
|
|
module PluginGem
|
|
|
|
def self.load(path, name, version, opts = nil)
|
|
|
|
opts ||= {}
|
|
|
|
|
|
|
|
gems_path = File.dirname(path) + "/gems/#{RUBY_VERSION}"
|
|
|
|
spec_path = gems_path + "/specifications"
|
2020-08-30 22:36:04 -04:00
|
|
|
spec_file = spec_path + "/#{name}-#{version}"
|
|
|
|
spec_file += "-#{opts[:platform]}" if opts[:platform]
|
|
|
|
spec_file += ".gemspec"
|
2017-01-09 17:10:14 -05:00
|
|
|
unless File.exists? spec_file
|
2018-10-17 00:31:45 -04:00
|
|
|
command = "gem install #{name} -v #{version} -i #{gems_path} --no-document --ignore-dependencies --no-user-install"
|
2017-01-09 17:10:14 -05:00
|
|
|
if opts[:source]
|
|
|
|
command << " --source #{opts[:source]}"
|
|
|
|
end
|
|
|
|
puts command
|
|
|
|
puts `#{command}`
|
|
|
|
end
|
|
|
|
if File.exists? spec_file
|
|
|
|
spec = Gem::Specification.load spec_file
|
|
|
|
spec.activate
|
|
|
|
unless opts[:require] == false
|
|
|
|
require opts[:require_name] ? opts[:require_name] : name
|
|
|
|
end
|
|
|
|
else
|
|
|
|
puts "You are specifying the gem #{name} in #{path}, however it does not exist!"
|
2017-08-02 14:00:18 -04:00
|
|
|
puts "Looked for: #{spec_file}"
|
2017-01-09 17:10:14 -05:00
|
|
|
exit(-1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|