aboutsummaryrefslogtreecommitdiffstats
path: root/lib/bundler/plugin
diff options
context:
space:
mode:
authorAsutosh Palai <asupalai@gmail.com>2016-06-01 23:33:47 +0530
committerAsutosh Palai <asupalai@gmail.com>2016-06-01 23:44:16 +0530
commitcb7286d8815d774fdabcae91e5f987260d9871e0 (patch)
tree31fb2fb87bfabb5c52154faa3627c57ed5eac137 /lib/bundler/plugin
parent0c1296df7b268af9e335bf6f73f220f5f29c4fee (diff)
downloadbundler-cb7286d8815d774fdabcae91e5f987260d9871e0.tar.gz
Removed `@options[:plugin]` from source class
Diffstat (limited to 'lib/bundler/plugin')
-rw-r--r--lib/bundler/plugin/installer.rb8
-rw-r--r--lib/bundler/plugin/installer/git.rb34
-rw-r--r--lib/bundler/plugin/installer/rubygems.rb23
-rw-r--r--lib/bundler/plugin/source_list.rb6
4 files changed, 65 insertions, 6 deletions
diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb
index 605d272d..d4de0be5 100644
--- a/lib/bundler/plugin/installer.rb
+++ b/lib/bundler/plugin/installer.rb
@@ -7,6 +7,9 @@ module Bundler
# but currently it itself handles everything as the Source's subclasses (e.g. Source::RubyGems)
# are heavily dependent on the Gemfile.
class Plugin::Installer
+ autoload :Rubygems, "bundler/plugin/installer/rubygems"
+ autoload :Git, "bundler/plugin/installer/git"
+
def install(name, options)
if options[:git]
install_git(name, options)
@@ -43,9 +46,8 @@ module Bundler
options[:name] = name
options[:uri] = uri
- options[:plugin] = true
- git_source = Source::Git.new options
+ git_source = Git.new options
git_source.remote!
git_source.install(git_source.specs.first)
@@ -62,7 +64,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, :plugin => true
+ rg_source = Rubygems.new "remotes" => source
rg_source.remote!
rg_source.dependency_names << name
diff --git a/lib/bundler/plugin/installer/git.rb b/lib/bundler/plugin/installer/git.rb
new file mode 100644
index 00000000..3bff5111
--- /dev/null
+++ b/lib/bundler/plugin/installer/git.rb
@@ -0,0 +1,34 @@
+# frozen_string_literal: true
+
+module Bundler
+ class Plugin::Installer::Git < Bundler::Source::Git
+ def cache_path
+ @cache_path ||= begin
+ git_scope = "#{base_name}-#{uri_hash}"
+
+ Plugin.cache.join("bundler", "git", git_scope)
+ end
+ end
+
+ def install_path
+ @install_path ||= begin
+ git_scope = "#{base_name}-#{shortref_for_path(revision)}"
+
+ Plugin.root.join("bundler", "gems", git_scope)
+ end
+ end
+
+ def version_message(spec)
+ "#{spec.name} #{spec.version}"
+ end
+
+ def root
+ Plugin.root
+ end
+
+ def generate_bin(spec, disable_extensions = false)
+ # Need to find a way without code duplication
+ # For now, we can ignore this
+ end
+ end
+end
diff --git a/lib/bundler/plugin/installer/rubygems.rb b/lib/bundler/plugin/installer/rubygems.rb
new file mode 100644
index 00000000..3b44210b
--- /dev/null
+++ b/lib/bundler/plugin/installer/rubygems.rb
@@ -0,0 +1,23 @@
+# frozen_string_literal: true
+
+module Bundler
+ class Plugin::Installer::Rubygems < Bundler::Source::Rubygems
+ def version_message(spec)
+ "#{spec.name} #{spec.version}"
+ end
+
+ private
+
+ def requires_sudo?
+ false # Will change on implementation of project level plugins
+ end
+
+ def rubygems_dir
+ Plugin.root
+ end
+
+ def cache_path
+ Plugin.cache
+ end
+ end
+end
diff --git a/lib/bundler/plugin/source_list.rb b/lib/bundler/plugin/source_list.rb
index 2959a408..b29cf57b 100644
--- a/lib/bundler/plugin/source_list.rb
+++ b/lib/bundler/plugin/source_list.rb
@@ -6,15 +6,15 @@ module Bundler
class Plugin::SourceList < Bundler::SourceList
def initialize
super
- @rubygems_aggregate = Source::Rubygems.new :plugin => true
+ @rubygems_aggregate = Plugin::Installer::Rubygems.new
end
def add_git_source(options = {})
- add_source_to_list Source::Git.new(options.merge(:plugin => true)), git_sources
+ add_source_to_list Plugin::Installer::Git.new(options), git_sources
end
def add_rubygems_source(options = {})
- add_source_to_list Source::Rubygems.new(options.merge(:plugin => true)), @rubygems_sources
+ add_source_to_list Plugin::Installer::Rubygems.new(options), @rubygems_sources
end
end
end