summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-05-26 17:58:58 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-05-26 17:59:01 +0530
commit3202fb947ab4ce91169ac9ffc509696b4acbebbb (patch)
tree7c8b7d11b262edc2a697a542d4b0d868e3013789
parentcb66151d1f8ebe788ed4a605e9bfc13f451dbe1f (diff)
downloadbundler-3202fb947ab4ce91169ac9ffc509696b4acbebbb.tar.gz
Shifted rubygems installation to bundler class
-rw-r--r--lib/bundler/plugin/installer.rb31
-rw-r--r--lib/bundler/source/rubygems.rb30
-rw-r--r--spec/plugins/install.rb16
3 files changed, 31 insertions, 46 deletions
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 49d2f12f35..e7c5a7be3d 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -48,7 +48,7 @@ module Bundler
#
# @return [String] the path where the plugin was installed
def install_rubygems(name, source, version = [">= 0"])
- rg_source = Source::Rubygems.new "remotes" => source, :ignore_app_cache => true
+ rg_source = Source::Rubygems.new "remotes" => source, :plugin => true
rg_source.remote!
rg_source.dependency_names << name
@@ -58,10 +58,9 @@ module Bundler
idx = rg_source.specs
specs = Resolver.resolve(deps_proxies, idx).materialize([dep])
+ paths = install_from_spec specs
- raise InstallError, "Plugin dependencies are not supported currently" unless specs.size == 1
-
- install_from_spec specs.first
+ paths[name]
end
# Installs the plugin from the provided spec and returns the path where the
@@ -71,26 +70,18 @@ module Bundler
# @raise [ArgumentError] if the spec object has no remote set
#
# @return [String] the path where the plugin was installed
- def install_from_spec(spec)
- raise ArgumentError, "Spec #{spec.name} doesn't have remote set" unless spec.remote
-
- uri = spec.remote.uri
- spec.fetch_platform
+ def install_from_spec(specs)
+ paths = {}
- download_path = Plugin.cache
+ specs.each do |spec|
+ raise ArgumentError, "Spec #{spec.name} doesn't have remote set" unless spec.remote
- path = Bundler.rubygems.download_gem(spec, uri, download_path)
+ spec.source.install spec
- Bundler.rubygems.preserve_paths do
- Bundler::RubyGemsGemInstaller.new(
- path,
- :install_dir => Plugin.root.to_s,
- :ignore_dependencies => true,
- :wrappers => true,
- :env_shebang => true
-
- ).install.full_gem_path
+ paths[spec.name] = spec.full_gem_path
end
+
+ paths
end
end
end
diff --git a/lib/bundler/source/rubygems.rb b/lib/bundler/source/rubygems.rb
index 33e0e0be3f..0b5327ee12 100644
--- a/lib/bundler/source/rubygems.rb
+++ b/lib/bundler/source/rubygems.rb
@@ -22,7 +22,8 @@ module Bundler
@allow_remote = false
@allow_cached = false
@caches = [*Bundler.rubygems.gem_cache]
- @caches << Bundler.app_cache unless options[:ignore_app_cache] # To use this class for installing plugins
+ @caches << Bundler.app_cache unless options[:plugin] # To use this class for installing plugins
+ @caches << Bundler::Plugin.cache if options[:plugin]
Array(options["remotes"] || []).reverse_each {|r| add_remote(r) }
end
@@ -81,7 +82,7 @@ module Bundler
# sources, and large_idx.use small_idx is way faster than
# small_idx.use large_idx.
idx = @allow_remote ? remote_specs.dup : Index.new
- idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote && !@options[:ignore_app_cache]
+ idx.use(cached_specs, :override_dupes) if @allow_cached || @allow_remote
idx.use(installed_specs, :override_dupes)
idx
end
@@ -124,7 +125,10 @@ module Bundler
Bundler.ui.confirm message
path = cached_gem(spec)
- if Bundler.requires_sudo?
+ if @options[:plugin]
+ install_path = Bundler::Plugin.root
+ bin_path = install_path.join("bin")
+ elsif Bundler.requires_sudo?
install_path = Bundler.tmp(spec.full_name)
bin_path = install_path.join("bin")
else
@@ -143,9 +147,10 @@ module Bundler
:env_shebang => true
).install
end
+ spec.full_gem_path = installed_spec.full_gem_path
# SUDO HAX
- if Bundler.requires_sudo?
+ if !@options[:plugin] && Bundler.requires_sudo?
Bundler.rubygems.repository_subdirectories.each do |name|
src = File.join(install_path, name, "*")
dst = File.join(Bundler.rubygems.gem_dir, name)
@@ -174,7 +179,7 @@ module Bundler
spec.post_install_message
ensure
- Bundler.rm_rf(install_path) if Bundler.requires_sudo?
+ Bundler.rm_rf(install_path) if !@options[:plugin] && Bundler.requires_sudo?
end
def cache(spec, custom_path = nil)
@@ -316,7 +321,7 @@ module Bundler
@cached_specs ||= begin
idx = installed_specs.dup
- path = Bundler.app_cache
+ path = @options[:plugin] ? Bundler::Plugin.cache : Bundler.app_cache
Dir["#{path}/*.gem"].each do |gemfile|
next if gemfile =~ /^bundler\-[\d\.]+?\.gem/
s ||= Bundler.rubygems.spec_from_gem(gemfile)
@@ -402,15 +407,20 @@ module Bundler
uri = spec.remote.uri
spec.fetch_platform
- download_path = Bundler.requires_sudo? ? Bundler.tmp(spec.full_name) : Bundler.rubygems.gem_dir
- gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
+ if @options[:plugin]
+ download_path = Bundler::Plugin.root
+ gem_path = "#{download_path}/cache/#{spec.full_name}.gem"
+ else
+ download_path = Bundler.requires_sudo? ? Bundler.tmp(spec.full_name) : Bundler.rubygems.gem_dir
+ gem_path = "#{Bundler.rubygems.gem_dir}/cache/#{spec.full_name}.gem"
+ end
SharedHelpers.filesystem_access("#{download_path}/cache") do |p|
FileUtils.mkdir_p(p)
end
Bundler.rubygems.download_gem(spec, uri, download_path)
- if Bundler.requires_sudo?
+ if !@options[:plugin] && Bundler.requires_sudo?
SharedHelpers.filesystem_access("#{Bundler.rubygems.gem_dir}/cache") do |p|
Bundler.mkdir_p(p)
end
@@ -419,7 +429,7 @@ module Bundler
gem_path
ensure
- Bundler.rm_rf(download_path) if Bundler.requires_sudo?
+ Bundler.rm_rf(download_path) if !@options[:plugin] && Bundler.requires_sudo?
end
def builtin_gem?(spec)
diff --git a/spec/plugins/install.rb b/spec/plugins/install.rb
index e1d9d80498..33d3b58b9b 100644
--- a/spec/plugins/install.rb
+++ b/spec/plugins/install.rb
@@ -28,22 +28,6 @@ describe "bundler plugin install" do
expect(out).to include("Installed plugin foo")
end
- it "shows error for plugins with dependencies" do
- build_repo2 do
- build_plugin "kung-foo" do |s|
- s.add_dependency "rake"
- end
- end
-
- bundle "plugin install kung-foo --source file://#{gem_repo2}"
-
- expect(out).to include("Plugin dependencies are not supported")
-
- expect(out).not_to include("Installed plugin")
-
- expect(plugin_gems("kung-foo-1.0")).not_to be_directory
- end
-
context "malformatted plugin" do
it "fails when plugin.rb is missing" do
build_repo2 do