diff options
author | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-14 06:01:35 +0000 |
---|---|---|
committer | hsbt <hsbt@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2019-04-14 06:01:35 +0000 |
commit | 68ddd4d300e9a88737c4f37af74e1a0312949b2f (patch) | |
tree | 787e1e83d76934ce039eb336995a8d5bb53a89e6 /lib/bundler/plugin | |
parent | d636809c057432e8d42abe30c6c6785eb0721d77 (diff) | |
download | ruby-68ddd4d300e9a88737c4f37af74e1a0312949b2f.tar.gz |
Merge Bundler 2.1.0.pre.1 as developed version from upstream.
https://github.com/bundler/bundler/commit/a53709556b95a914e874b22ed2116a46b0528852
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@67539 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/bundler/plugin')
-rw-r--r-- | lib/bundler/plugin/api/source.rb | 2 | ||||
-rw-r--r-- | lib/bundler/plugin/index.rb | 13 | ||||
-rw-r--r-- | lib/bundler/plugin/installer.rb | 39 |
3 files changed, 39 insertions, 15 deletions
diff --git a/lib/bundler/plugin/api/source.rb b/lib/bundler/plugin/api/source.rb index 586477efb5..b33926a181 100644 --- a/lib/bundler/plugin/api/source.rb +++ b/lib/bundler/plugin/api/source.rb @@ -37,7 +37,7 @@ module Bundler # # @!attribute [rw] dependency_names # @return [Array<String>] Names of dependencies that the source should - # try to resolve. It is not necessary to use this list intenally. This + # try to resolve. It is not necessary to use this list internally. This # is present to be compatible with `Definition` and is used by # rubygems source. module Source diff --git a/lib/bundler/plugin/index.rb b/lib/bundler/plugin/index.rb index f09587dfda..faabf3a8d1 100644 --- a/lib/bundler/plugin/index.rb +++ b/lib/bundler/plugin/index.rb @@ -58,7 +58,10 @@ module Bundler raise SourceConflict.new(name, common) unless common.empty? sources.each {|k| @sources[k] = name } - hooks.each {|e| (@hooks[e] ||= []) << name } + hooks.each do |event| + event_hooks = (@hooks[event] ||= []) << name + event_hooks.uniq! + end @plugin_paths[name] = path @load_paths[name] = load_paths @@ -100,6 +103,14 @@ module Bundler @plugin_paths[name] end + def installed_plugins + @plugin_paths.keys + end + + def plugin_commands(plugin) + @commands.find_all {|_, n| n == plugin }.map(&:first) + end + def source?(source) @sources.key? source end diff --git a/lib/bundler/plugin/installer.rb b/lib/bundler/plugin/installer.rb index 5379c38979..4a262efac2 100644 --- a/lib/bundler/plugin/installer.rb +++ b/lib/bundler/plugin/installer.rb @@ -12,10 +12,15 @@ module Bundler autoload :Git, "bundler/plugin/installer/git" def install(names, options) + check_sources_consistency!(options) + version = options[:version] || [">= 0"] - Bundler.settings.temporary(:lockfile_uses_separate_rubygems_sources => false, :disable_multisource => false) do + + Bundler.settings.temporary(:disable_multisource => false) do if options[:git] install_git(names, version, options) + elsif options[:local_git] + install_local_git(names, version, options) else sources = options[:source] || Bundler.rubygems.sources install_rubygems(names, version, sources) @@ -38,22 +43,24 @@ module Bundler private + def check_sources_consistency!(options) + if options.key?(:git) && options.key?(:local_git) + raise InvalidOption, "Remote and local plugin git sources can't be both specified" + end + end + def install_git(names, version, options) uri = options.delete(:git) options["uri"] = uri - source_list = SourceList.new - source_list.add_git_source(options) - - # To support both sources - if options[:source] - source_list.add_rubygems_source("remotes" => options[:source]) - end + install_all_sources(names, version, options, options[:source]) + end - deps = names.map {|name| Dependency.new name, version } + def install_local_git(names, version, options) + uri = options.delete(:local_git) + options["uri"] = uri - definition = Definition.new(nil, deps, source_list, true) - install_definition(definition) + install_all_sources(names, version, options, options[:source]) end # Installs the plugin from rubygems source and returns the path where the @@ -65,10 +72,16 @@ module Bundler # # @return [Hash] map of names to the specs of plugins installed def install_rubygems(names, version, sources) - deps = names.map {|name| Dependency.new name, version } + install_all_sources(names, version, nil, sources) + end + def install_all_sources(names, version, git_source_options, rubygems_source) source_list = SourceList.new - source_list.add_rubygems_source("remotes" => sources) + + source_list.add_git_source(git_source_options) if git_source_options + source_list.add_rubygems_source("remotes" => rubygems_source) if rubygems_source + + deps = names.map {|name| Dependency.new name, version } definition = Definition.new(nil, deps, source_list, true) install_definition(definition) |