FEATURE: Try to load plugin gems platform variants (#21643)
This commit is contained in:
parent
fa047d928d
commit
3f7105e7cd
|
@ -9,10 +9,8 @@ module PluginGem
|
||||||
spec_path = gems_path + "/specifications"
|
spec_path = gems_path + "/specifications"
|
||||||
|
|
||||||
spec_file = spec_path + "/#{name}-#{version}"
|
spec_file = spec_path + "/#{name}-#{version}"
|
||||||
spec_file += "-#{opts[:platform]}" if opts[:platform]
|
|
||||||
spec_file += ".gemspec"
|
|
||||||
|
|
||||||
unless File.exist? spec_file
|
unless platform_variants(spec_file).find(&File.method(:exist?)).present?
|
||||||
command =
|
command =
|
||||||
"gem install #{name} -v #{version} -i #{gems_path} --no-document --ignore-dependencies --no-user-install"
|
"gem install #{name} -v #{version} -i #{gems_path} --no-document --ignore-dependencies --no-user-install"
|
||||||
command += " --source #{opts[:source]}" if opts[:source]
|
command += " --source #{opts[:source]}" if opts[:source]
|
||||||
|
@ -21,15 +19,27 @@ module PluginGem
|
||||||
Bundler.with_unbundled_env { puts `#{command}` }
|
Bundler.with_unbundled_env { puts `#{command}` }
|
||||||
end
|
end
|
||||||
|
|
||||||
if File.exist? spec_file
|
spec_file_variant = platform_variants(spec_file).find(&File.method(:exist?))
|
||||||
|
if spec_file_variant.present?
|
||||||
Gem.path << gems_path
|
Gem.path << gems_path
|
||||||
Gem::Specification.load(spec_file).activate
|
Gem::Specification.load(spec_file_variant).activate
|
||||||
|
|
||||||
require opts[:require_name] ? opts[:require_name] : name unless opts[:require] == false
|
require opts[:require_name] ? opts[:require_name] : name unless opts[:require] == false
|
||||||
else
|
else
|
||||||
puts "You are specifying the gem #{name} in #{path}, however it does not exist!"
|
puts "You are specifying the gem #{name} in #{path}, however it does not exist!"
|
||||||
puts "Looked for: #{spec_file}"
|
puts "Looked for: \n- #{platform_variants(spec_file).join("\n- ")}"
|
||||||
exit(-1)
|
exit(-1)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def self.platform_variants(spec_file)
|
||||||
|
platform_less = "#{spec_file}.gemspec"
|
||||||
|
|
||||||
|
platform_full = "#{spec_file}-#{RUBY_PLATFORM}.gemspec"
|
||||||
|
|
||||||
|
platform_version_less =
|
||||||
|
"#{spec_file}-#{Gem::Platform.local.cpu}-#{Gem::Platform.local.os}.gemspec"
|
||||||
|
|
||||||
|
[platform_less, platform_full, platform_version_less]
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue