bundler 1.13.6 → 1.17.3
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of bundler might be problematic. Click here for more details.
- checksums.yaml +5 -5
- data/CHANGELOG.md +554 -9
- data/README.md +28 -5
- data/bundler.gemspec +40 -11
- data/exe/bundle +4 -8
- data/exe/bundle_ruby +4 -3
- data/lib/bundler.rb +162 -68
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +5 -0
- data/lib/bundler/cli.rb +360 -118
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +18 -10
- data/lib/bundler/cli/cache.rb +6 -5
- data/lib/bundler/cli/check.rb +4 -6
- data/lib/bundler/cli/clean.rb +6 -7
- data/lib/bundler/cli/common.rb +47 -1
- data/lib/bundler/cli/config.rb +26 -7
- data/lib/bundler/cli/console.rb +2 -1
- data/lib/bundler/cli/doctor.rb +63 -18
- data/lib/bundler/cli/exec.rb +12 -5
- data/lib/bundler/cli/gem.rb +59 -21
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +21 -7
- data/lib/bundler/cli/inject.rb +13 -4
- data/lib/bundler/cli/install.rb +72 -101
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +9 -6
- data/lib/bundler/cli/open.rb +4 -3
- data/lib/bundler/cli/outdated.rb +175 -60
- data/lib/bundler/cli/package.rb +9 -6
- data/lib/bundler/cli/platform.rb +2 -1
- data/lib/bundler/cli/plugin.rb +1 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +2 -2
- data/lib/bundler/cli/update.rb +44 -34
- data/lib/bundler/cli/viz.rb +5 -1
- data/lib/bundler/compact_index_client.rb +109 -0
- data/lib/bundler/compact_index_client/cache.rb +118 -0
- data/lib/bundler/compact_index_client/updater.rb +116 -0
- data/lib/bundler/compatibility_guard.rb +14 -0
- data/lib/bundler/constants.rb +1 -0
- data/lib/bundler/current_ruby.rb +17 -8
- data/lib/bundler/definition.rb +353 -182
- data/lib/bundler/dep_proxy.rb +3 -1
- data/lib/bundler/dependency.rb +22 -10
- data/lib/bundler/deployment.rb +1 -1
- data/lib/bundler/deprecate.rb +15 -3
- data/lib/bundler/dsl.rb +122 -64
- data/lib/bundler/endpoint_specification.rb +13 -3
- data/lib/bundler/env.rb +110 -38
- data/lib/bundler/environment_preserver.rb +27 -6
- data/lib/bundler/errors.rb +24 -0
- data/lib/bundler/feature_flag.rb +74 -0
- data/lib/bundler/fetcher.rb +18 -11
- data/lib/bundler/fetcher/base.rb +1 -0
- data/lib/bundler/fetcher/compact_index.rb +7 -5
- data/lib/bundler/fetcher/dependency.rb +3 -2
- data/lib/bundler/fetcher/downloader.rb +25 -7
- data/lib/bundler/fetcher/index.rb +3 -2
- data/lib/bundler/friendly_errors.rb +33 -7
- data/lib/bundler/gem_helper.rb +25 -11
- data/lib/bundler/gem_helpers.rb +70 -1
- data/lib/bundler/gem_remote_fetcher.rb +1 -0
- data/lib/bundler/gem_tasks.rb +1 -0
- data/lib/bundler/gem_version_promoter.rb +17 -2
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +1 -0
- data/lib/bundler/index.rb +28 -15
- data/lib/bundler/injector.rb +216 -33
- data/lib/bundler/inline.rb +12 -12
- data/lib/bundler/installer.rb +139 -53
- data/lib/bundler/installer/gem_installer.rb +15 -5
- data/lib/bundler/installer/parallel_installer.rb +113 -28
- data/lib/bundler/installer/standalone.rb +1 -0
- data/lib/bundler/lazy_specification.rb +31 -3
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +50 -37
- data/lib/bundler/match_platform.rb +13 -3
- data/lib/bundler/mirror.rb +10 -5
- data/lib/bundler/plugin.rb +22 -8
- data/lib/bundler/plugin/api.rb +2 -1
- data/lib/bundler/plugin/api/source.rb +17 -4
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +9 -2
- data/lib/bundler/plugin/installer.rb +7 -6
- data/lib/bundler/plugin/source_list.rb +7 -8
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +10 -0
- data/lib/bundler/remote_specification.rb +30 -1
- data/lib/bundler/resolver.rb +187 -194
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +5 -1
- data/lib/bundler/ruby_dsl.rb +1 -0
- data/lib/bundler/ruby_version.rb +12 -2
- data/lib/bundler/rubygems_ext.rb +23 -8
- data/lib/bundler/rubygems_gem_installer.rb +90 -0
- data/lib/bundler/rubygems_integration.rb +193 -70
- data/lib/bundler/runtime.rb +39 -22
- data/lib/bundler/settings.rb +245 -85
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +4 -7
- data/lib/bundler/shared_helpers.rb +183 -40
- data/lib/bundler/similarity_detector.rb +1 -0
- data/lib/bundler/source.rb +58 -1
- data/lib/bundler/source/gemspec.rb +1 -0
- data/lib/bundler/source/git.rb +52 -23
- data/lib/bundler/source/git/git_proxy.rb +30 -14
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +42 -16
- data/lib/bundler/source/path/installer.rb +4 -2
- data/lib/bundler/source/rubygems.rb +171 -82
- data/lib/bundler/source/rubygems/remote.rb +12 -2
- data/lib/bundler/source_list.rb +75 -15
- data/lib/bundler/spec_set.rb +67 -32
- data/lib/bundler/ssl_certs/certificate_manager.rb +2 -1
- data/lib/bundler/stub_specification.rb +86 -2
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +13 -1
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +5 -5
- data/lib/bundler/templates/Gemfile +3 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -2
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +1 -1
- data/lib/bundler/templates/newgem/README.md.tt +14 -8
- data/lib/bundler/templates/newgem/Rakefile.tt +5 -5
- data/lib/bundler/templates/newgem/bin/console.tt +1 -1
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +4 -4
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +3 -3
- data/lib/bundler/templates/newgem/gitignore.tt +5 -1
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -6
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +4 -4
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -12
- data/lib/bundler/templates/newgem/rspec.tt +1 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +1 -3
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +13 -1
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +1 -1
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +3 -3
- data/lib/bundler/templates/newgem/{.travis.yml.tt → travis.yml.tt} +2 -0
- data/lib/bundler/ui.rb +1 -0
- data/lib/bundler/ui/rg_proxy.rb +1 -0
- data/lib/bundler/ui/shell.rb +30 -10
- data/lib/bundler/ui/silent.rb +21 -1
- data/lib/bundler/uri_credentials_filter.rb +1 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1638 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +2 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +7 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +26 -6
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +2 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +12 -4
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/delete_edge.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/detach_vertex_named.rb +11 -3
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +13 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +3 -2
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +18 -5
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +75 -7
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +2 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +3 -1
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +499 -128
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +1 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +8 -4
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/faster.rb +1 -0
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent.rb +27 -24
- data/lib/bundler/vendor/{net → net-http-persistent/lib/net}/http/persistent/ssl_reuse.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor.rb +46 -21
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +24 -22
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +2 -1
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +2 -2
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +16 -8
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +66 -18
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +17 -15
- data/lib/bundler/vendor/thor/lib/thor/base.rb +55 -32
- data/lib/bundler/vendor/thor/lib/thor/command.rb +13 -11
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +21 -1
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +7 -5
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +94 -63
- data/lib/bundler/vendor/thor/lib/thor/error.rb +3 -3
- data/lib/bundler/vendor/thor/lib/thor/group.rb +13 -13
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +4 -5
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +2 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +4 -7
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +16 -16
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +42 -21
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +13 -10
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +31 -29
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +49 -33
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +1 -1
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +4 -4
- data/lib/bundler/vendor/thor/lib/thor/util.rb +8 -7
- data/lib/bundler/vendor/thor/lib/thor/version.rb +1 -1
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +1 -0
- data/lib/bundler/vendored_persistent.rb +43 -3
- data/lib/bundler/vendored_thor.rb +6 -2
- data/lib/bundler/version.rb +19 -2
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +5 -0
- data/lib/bundler/worker.rb +30 -6
- data/lib/bundler/yaml_serializer.rb +4 -4
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/{lib/bundler/man/bundle-binstubs → man/bundle-binstubs.1} +11 -1
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +15 -1
- data/man/bundle-check.1 +31 -0
- data/man/bundle-check.1.txt +33 -0
- data/man/bundle-check.ronn +26 -0
- data/man/bundle-clean.1 +24 -0
- data/man/bundle-clean.1.txt +26 -0
- data/man/bundle-clean.ronn +18 -0
- data/man/bundle-config.1 +497 -0
- data/man/bundle-config.1.txt +529 -0
- data/man/bundle-config.ronn +233 -61
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/{lib/bundler/man/bundle-exec → man/bundle-exec.1} +6 -3
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +10 -3
- data/{lib/bundler/man/bundle-gem → man/bundle-gem.1} +4 -4
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +3 -2
- data/man/bundle-info.1 +20 -0
- data/man/bundle-info.1.txt +21 -0
- data/man/bundle-info.ronn +17 -0
- data/man/bundle-init.1 +25 -0
- data/man/bundle-init.1.txt +34 -0
- data/man/bundle-init.ronn +29 -0
- data/man/bundle-inject.1 +33 -0
- data/man/bundle-inject.1.txt +32 -0
- data/man/bundle-inject.ronn +22 -0
- data/{lib/bundler/man/bundle-install → man/bundle-install.1} +32 -29
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +45 -36
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/{lib/bundler/man/bundle-lock → man/bundle-lock.1} +43 -2
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +47 -0
- data/man/bundle-open.1 +32 -0
- data/man/bundle-open.1.txt +29 -0
- data/man/bundle-open.ronn +19 -0
- data/man/bundle-outdated.1 +155 -0
- data/man/bundle-outdated.1.txt +131 -0
- data/man/bundle-outdated.ronn +111 -0
- data/{lib/bundler/man/bundle-package → man/bundle-package.1} +6 -3
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +7 -2
- data/{lib/bundler/man/bundle-platform → man/bundle-platform.1} +1 -1
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-pristine.1 +34 -0
- data/man/bundle-pristine.1.txt +44 -0
- data/man/bundle-pristine.ronn +34 -0
- data/man/bundle-remove.1 +31 -0
- data/man/bundle-remove.1.txt +34 -0
- data/man/bundle-remove.ronn +23 -0
- data/man/bundle-show.1 +23 -0
- data/man/bundle-show.1.txt +27 -0
- data/man/bundle-show.ronn +21 -0
- data/man/bundle-update.1 +394 -0
- data/man/bundle-update.1.txt +391 -0
- data/man/bundle-update.ronn +172 -16
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/{lib/bundler/man/bundle → man/bundle.1} +44 -28
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +39 -27
- data/{lib/bundler/man → man}/gemfile.5 +67 -84
- data/man/gemfile.5.ronn +77 -55
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -8
- metadata +118 -58
- data/.codeclimate.yml +0 -25
- data/.gitignore +0 -16
- data/.rspec +0 -3
- data/.rubocop.yml +0 -128
- data/.rubocop_todo.yml +0 -248
- data/.travis.yml +0 -108
- data/CODE_OF_CONDUCT.md +0 -42
- data/CONTRIBUTING.md +0 -36
- data/DEVELOPMENT.md +0 -148
- data/ISSUES.md +0 -100
- data/Rakefile +0 -333
- data/bin/rake +0 -19
- data/bin/rspec +0 -15
- data/bin/rubocop +0 -17
- data/bin/with_rubygems +0 -39
- data/lib/bundler/man/bundle-binstubs.txt +0 -33
- data/lib/bundler/man/bundle-config +0 -254
- data/lib/bundler/man/bundle-config.txt +0 -282
- data/lib/bundler/man/bundle-exec.txt +0 -171
- data/lib/bundler/man/bundle-gem.txt +0 -90
- data/lib/bundler/man/bundle-install.txt +0 -385
- data/lib/bundler/man/bundle-lock.txt +0 -52
- data/lib/bundler/man/bundle-package.txt +0 -74
- data/lib/bundler/man/bundle-platform.txt +0 -57
- data/lib/bundler/man/bundle-update +0 -221
- data/lib/bundler/man/bundle-update.txt +0 -227
- data/lib/bundler/man/bundle.txt +0 -104
- data/lib/bundler/man/gemfile.5.txt +0 -636
- data/lib/bundler/postit_trampoline.rb +0 -68
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client.rb +0 -79
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/cache.rb +0 -112
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/updater.rb +0 -80
- data/lib/bundler/vendor/compact_index_client/lib/compact_index_client/version.rb +0 -4
- data/lib/bundler/vendor/postit/lib/postit.rb +0 -15
- data/lib/bundler/vendor/postit/lib/postit/environment.rb +0 -44
- data/lib/bundler/vendor/postit/lib/postit/installer.rb +0 -28
- data/lib/bundler/vendor/postit/lib/postit/parser.rb +0 -21
- data/lib/bundler/vendor/postit/lib/postit/setup.rb +0 -12
- data/lib/bundler/vendor/postit/lib/postit/version.rb +0 -3
data/lib/bundler/runtime.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require "digest/sha1"
|
3
2
|
|
4
3
|
module Bundler
|
5
4
|
class Runtime
|
@@ -11,6 +10,8 @@ module Bundler
|
|
11
10
|
end
|
12
11
|
|
13
12
|
def setup(*groups)
|
13
|
+
@definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
|
14
|
+
|
14
15
|
groups.map!(&:to_sym)
|
15
16
|
|
16
17
|
# Has to happen first
|
@@ -24,21 +25,10 @@ module Bundler
|
|
24
25
|
# Activate the specs
|
25
26
|
load_paths = specs.map do |spec|
|
26
27
|
unless spec.loaded_from
|
27
|
-
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
|
28
|
+
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
|
28
29
|
end
|
29
30
|
|
30
|
-
|
31
|
-
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
32
|
-
"but your Gemfile requires #{spec.name} #{spec.version}. Prepending " \
|
33
|
-
"`bundle exec` to your command may solve this."
|
34
|
-
e.name = spec.name
|
35
|
-
if e.respond_to?(:requirement=)
|
36
|
-
e.requirement = Gem::Requirement.new(spec.version.to_s)
|
37
|
-
else
|
38
|
-
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
|
39
|
-
end
|
40
|
-
raise e
|
41
|
-
end
|
31
|
+
check_for_activated_spec!(spec)
|
42
32
|
|
43
33
|
Bundler.rubygems.mark_loaded(spec)
|
44
34
|
spec.load_paths.reject {|path| $LOAD_PATH.include?(path) }
|
@@ -89,7 +79,7 @@ module Bundler
|
|
89
79
|
required_file = file
|
90
80
|
begin
|
91
81
|
Kernel.require file
|
92
|
-
rescue => e
|
82
|
+
rescue RuntimeError => e
|
93
83
|
raise e if e.is_a?(LoadError) # we handle this a little later
|
94
84
|
raise Bundler::GemRequireError.new e,
|
95
85
|
"There was an error while trying to load the gem '#{file}'."
|
@@ -127,6 +117,7 @@ module Bundler
|
|
127
117
|
definition_method :requires
|
128
118
|
|
129
119
|
def lock(opts = {})
|
120
|
+
return if @definition.nothing_changed? && !@definition.unlocking?
|
130
121
|
@definition.lock(Bundler.default_lockfile, opts[:preserve_unknown_sections])
|
131
122
|
end
|
132
123
|
|
@@ -140,7 +131,8 @@ module Bundler
|
|
140
131
|
|
141
132
|
Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
|
142
133
|
|
143
|
-
|
134
|
+
specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
|
135
|
+
specs_to_cache.each do |spec|
|
144
136
|
next if spec.name == "bundler"
|
145
137
|
next if spec.source.is_a?(Source::Gemspec)
|
146
138
|
spec.source.send(:fetch_gem, spec) if Bundler.settings[:cache_all_platforms] && spec.source.respond_to?(:fetch_gem, true)
|
@@ -171,6 +163,7 @@ module Bundler
|
|
171
163
|
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
172
164
|
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
|
173
165
|
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
|
166
|
+
extension_dirs = Dir["#{Gem.dir}/extensions/*/*/*"]
|
174
167
|
spec_gem_paths = []
|
175
168
|
# need to keep git sources around
|
176
169
|
spec_git_paths = @definition.spec_git_paths
|
@@ -178,6 +171,7 @@ module Bundler
|
|
178
171
|
spec_gem_executables = []
|
179
172
|
spec_cache_paths = []
|
180
173
|
spec_gemspec_paths = []
|
174
|
+
spec_extension_paths = []
|
181
175
|
specs.each do |spec|
|
182
176
|
spec_gem_paths << spec.full_gem_path
|
183
177
|
# need to check here in case gems are nested like for the rails git repo
|
@@ -189,6 +183,7 @@ module Bundler
|
|
189
183
|
end
|
190
184
|
spec_cache_paths << spec.cache_file
|
191
185
|
spec_gemspec_paths << spec.spec_file
|
186
|
+
spec_extension_paths << spec.extension_dir if spec.respond_to?(:extension_dir)
|
192
187
|
spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
|
193
188
|
end
|
194
189
|
spec_gem_paths.uniq!
|
@@ -200,6 +195,7 @@ module Bundler
|
|
200
195
|
stale_gem_dirs = gem_dirs - spec_gem_paths
|
201
196
|
stale_gem_files = gem_files - spec_cache_paths
|
202
197
|
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
198
|
+
stale_extension_dirs = extension_dirs - spec_extension_paths
|
203
199
|
|
204
200
|
removed_stale_gem_dirs = stale_gem_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
205
201
|
removed_stale_git_dirs = stale_git_dirs.collect {|dir| remove_dir(dir, dry_run) }
|
@@ -212,8 +208,10 @@ module Bundler
|
|
212
208
|
FileUtils.rm(file) if File.exist?(file)
|
213
209
|
end
|
214
210
|
end
|
215
|
-
|
216
|
-
|
211
|
+
|
212
|
+
stale_dirs = stale_git_cache_dirs + stale_extension_dirs
|
213
|
+
stale_dirs.each do |stale_dir|
|
214
|
+
SharedHelpers.filesystem_access(stale_dir) do |dir|
|
217
215
|
FileUtils.rm_rf(dir) if File.exist?(dir)
|
218
216
|
end
|
219
217
|
end
|
@@ -269,9 +267,6 @@ module Bundler
|
|
269
267
|
end
|
270
268
|
|
271
269
|
def setup_manpath
|
272
|
-
# Store original MANPATH for restoration later in with_clean_env()
|
273
|
-
ENV["BUNDLER_ORIG_MANPATH"] = ENV["MANPATH"]
|
274
|
-
|
275
270
|
# Add man/ subdirectories from activated bundles to MANPATH for man(1)
|
276
271
|
manuals = $LOAD_PATH.map do |path|
|
277
272
|
man_subdir = path.sub(/lib$/, "man")
|
@@ -279,7 +274,7 @@ module Bundler
|
|
279
274
|
end.compact
|
280
275
|
|
281
276
|
return if manuals.empty?
|
282
|
-
|
277
|
+
Bundler::SharedHelpers.set_env "MANPATH", manuals.concat(
|
283
278
|
ENV["MANPATH"].to_s.split(File::PATH_SEPARATOR)
|
284
279
|
).uniq.join(File::PATH_SEPARATOR)
|
285
280
|
end
|
@@ -301,5 +296,27 @@ module Bundler
|
|
301
296
|
|
302
297
|
output
|
303
298
|
end
|
299
|
+
|
300
|
+
def check_for_activated_spec!(spec)
|
301
|
+
return unless activated_spec = Bundler.rubygems.loaded_specs(spec.name)
|
302
|
+
return if activated_spec.version == spec.version
|
303
|
+
|
304
|
+
suggestion = if Bundler.rubygems.spec_default_gem?(activated_spec)
|
305
|
+
"Since #{spec.name} is a default gem, you can either remove your dependency on it" \
|
306
|
+
" or try updating to a newer version of bundler that supports #{spec.name} as a default gem."
|
307
|
+
else
|
308
|
+
"Prepending `bundle exec` to your command may solve this."
|
309
|
+
end
|
310
|
+
|
311
|
+
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
312
|
+
"but your Gemfile requires #{spec.name} #{spec.version}. #{suggestion}"
|
313
|
+
e.name = spec.name
|
314
|
+
if e.respond_to?(:requirement=)
|
315
|
+
e.requirement = Gem::Requirement.new(spec.version.to_s)
|
316
|
+
else
|
317
|
+
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
|
318
|
+
end
|
319
|
+
raise e
|
320
|
+
end
|
304
321
|
end
|
305
322
|
end
|
data/lib/bundler/settings.rb
CHANGED
@@ -1,86 +1,149 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
|
2
3
|
require "uri"
|
3
4
|
|
4
5
|
module Bundler
|
5
6
|
class Settings
|
6
|
-
|
7
|
+
autoload :Mirror, "bundler/mirror"
|
8
|
+
autoload :Mirrors, "bundler/mirror"
|
9
|
+
autoload :Validator, "bundler/settings/validator"
|
10
|
+
|
11
|
+
BOOL_KEYS = %w[
|
12
|
+
allow_bundler_dependency_conflicts
|
13
|
+
allow_deployment_source_credential_changes
|
7
14
|
allow_offline_install
|
15
|
+
auto_clean_without_path
|
8
16
|
auto_install
|
17
|
+
auto_config_jobs
|
9
18
|
cache_all
|
19
|
+
cache_all_platforms
|
20
|
+
cache_command_is_package
|
21
|
+
console_command
|
22
|
+
default_install_uses_path
|
23
|
+
deployment
|
24
|
+
deployment_means_frozen
|
25
|
+
disable_checksum_validation
|
10
26
|
disable_exec_load
|
11
27
|
disable_local_branch_check
|
28
|
+
disable_multisource
|
29
|
+
disable_platform_warnings
|
12
30
|
disable_shared_gems
|
31
|
+
disable_version_check
|
32
|
+
error_on_stderr
|
33
|
+
force_ruby_platform
|
34
|
+
forget_cli_options
|
13
35
|
frozen
|
14
36
|
gem.coc
|
15
37
|
gem.mit
|
38
|
+
global_path_appends_ruby_scope
|
39
|
+
global_gem_cache
|
16
40
|
ignore_messages
|
41
|
+
init_gems_rb
|
42
|
+
list_command
|
43
|
+
lockfile_uses_separate_rubygems_sources
|
17
44
|
major_deprecations
|
18
45
|
no_install
|
19
46
|
no_prune
|
20
47
|
only_update_to_newer_versions
|
48
|
+
path_relative_to_cwd
|
49
|
+
path.system
|
21
50
|
plugins
|
51
|
+
prefer_gems_rb
|
52
|
+
print_only_version_number
|
53
|
+
setup_makes_kernel_gem_public
|
22
54
|
silence_root_warning
|
23
|
-
|
24
|
-
|
25
|
-
|
55
|
+
skip_default_git_sources
|
56
|
+
specific_platform
|
57
|
+
suppress_install_using_messages
|
58
|
+
unlock_source_unlocks_spec
|
59
|
+
update_requires_all_flag
|
60
|
+
use_gem_version_promoter_for_major_updates
|
61
|
+
viz_command
|
62
|
+
].freeze
|
63
|
+
|
64
|
+
NUMBER_KEYS = %w[
|
65
|
+
jobs
|
26
66
|
redirect
|
27
67
|
retry
|
28
68
|
ssl_verify_mode
|
29
69
|
timeout
|
30
|
-
|
70
|
+
].freeze
|
71
|
+
|
72
|
+
ARRAY_KEYS = %w[
|
73
|
+
with
|
74
|
+
without
|
75
|
+
].freeze
|
31
76
|
|
32
77
|
DEFAULT_CONFIG = {
|
78
|
+
:disable_version_check => true,
|
33
79
|
:redirect => 5,
|
34
80
|
:retry => 3,
|
35
81
|
:timeout => 10,
|
36
82
|
}.freeze
|
37
83
|
|
38
|
-
attr_accessor :cli_flags_given
|
39
|
-
|
40
84
|
def initialize(root = nil)
|
41
85
|
@root = root
|
42
86
|
@local_config = load_config(local_config_file)
|
43
87
|
@global_config = load_config(global_config_file)
|
44
|
-
@
|
88
|
+
@temporary = {}
|
45
89
|
end
|
46
90
|
|
47
91
|
def [](name)
|
48
92
|
key = key_for(name)
|
49
|
-
value = (
|
93
|
+
value = @temporary.fetch(key) do
|
94
|
+
@local_config.fetch(key) do
|
95
|
+
ENV.fetch(key) do
|
96
|
+
@global_config.fetch(key) do
|
97
|
+
DEFAULT_CONFIG.fetch(name) do
|
98
|
+
nil
|
99
|
+
end end end end end
|
50
100
|
|
51
|
-
|
52
|
-
nil
|
53
|
-
elsif is_bool(name) || value == "false"
|
54
|
-
to_bool(value)
|
55
|
-
elsif is_num(name)
|
56
|
-
value.to_i
|
57
|
-
else
|
58
|
-
value
|
59
|
-
end
|
101
|
+
converted_value(value, name)
|
60
102
|
end
|
61
103
|
|
62
|
-
def
|
63
|
-
if
|
104
|
+
def set_command_option(key, value)
|
105
|
+
if Bundler.feature_flag.forget_cli_options?
|
106
|
+
temporary(key => value)
|
107
|
+
value
|
108
|
+
else
|
64
109
|
command = if value.nil?
|
65
110
|
"bundle config --delete #{key}"
|
66
111
|
else
|
67
112
|
"bundle config #{key} #{Array(value).join(":")}"
|
68
113
|
end
|
69
114
|
|
70
|
-
Bundler::SharedHelpers.major_deprecation
|
115
|
+
Bundler::SharedHelpers.major_deprecation 2,\
|
71
116
|
"flags passed to commands " \
|
72
117
|
"will no longer be automatically remembered. Instead please set flags " \
|
73
118
|
"you want remembered between commands using `bundle config " \
|
74
119
|
"<setting name> <setting value>`, i.e. `#{command}`"
|
120
|
+
|
121
|
+
set_local(key, value)
|
75
122
|
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def set_command_option_if_given(key, value)
|
126
|
+
return if value.nil?
|
127
|
+
set_command_option(key, value)
|
128
|
+
end
|
129
|
+
|
130
|
+
def set_local(key, value)
|
76
131
|
local_config_file || raise(GemfileNotFound, "Could not locate Gemfile")
|
132
|
+
|
77
133
|
set_key(key, value, @local_config, local_config_file)
|
78
134
|
end
|
79
135
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
136
|
+
def temporary(update)
|
137
|
+
existing = Hash[update.map {|k, _| [k, @temporary[key_for(k)]] }]
|
138
|
+
update.each do |k, v|
|
139
|
+
set_key(k, v, @temporary, nil)
|
140
|
+
end
|
141
|
+
return unless block_given?
|
142
|
+
begin
|
143
|
+
yield
|
144
|
+
ensure
|
145
|
+
existing.each {|k, v| set_key(k, v, @temporary, nil) }
|
146
|
+
end
|
84
147
|
end
|
85
148
|
|
86
149
|
def set_global(key, value)
|
@@ -88,9 +151,9 @@ module Bundler
|
|
88
151
|
end
|
89
152
|
|
90
153
|
def all
|
91
|
-
env_keys = ENV.keys.
|
154
|
+
env_keys = ENV.keys.grep(/\ABUNDLE_.+/)
|
92
155
|
|
93
|
-
keys = @global_config.keys | @local_config.keys | env_keys
|
156
|
+
keys = @temporary.keys | @global_config.keys | @local_config.keys | env_keys
|
94
157
|
|
95
158
|
keys.map do |key|
|
96
159
|
key.sub(/^BUNDLE_/, "").gsub(/__/, ".").downcase
|
@@ -116,7 +179,7 @@ module Bundler
|
|
116
179
|
|
117
180
|
def gem_mirrors
|
118
181
|
all.inject(Mirrors.new) do |mirrors, k|
|
119
|
-
mirrors.parse(k, self[k]) if k
|
182
|
+
mirrors.parse(k, self[k]) if k.start_with?("mirror.")
|
120
183
|
mirrors
|
121
184
|
end
|
122
185
|
end
|
@@ -124,6 +187,7 @@ module Bundler
|
|
124
187
|
def locations(key)
|
125
188
|
key = key_for(key)
|
126
189
|
locations = {}
|
190
|
+
locations[:temporary] = @temporary[key] if @temporary.key?(key)
|
127
191
|
locations[:local] = @local_config[key] if @local_config.key?(key)
|
128
192
|
locations[:env] = ENV[key] if ENV[key]
|
129
193
|
locations[:global] = @global_config[key] if @global_config.key?(key)
|
@@ -135,53 +199,91 @@ module Bundler
|
|
135
199
|
key = key_for(exposed_key)
|
136
200
|
|
137
201
|
locations = []
|
202
|
+
|
203
|
+
if @temporary.key?(key)
|
204
|
+
locations << "Set for the current command: #{converted_value(@temporary[key], exposed_key).inspect}"
|
205
|
+
end
|
206
|
+
|
138
207
|
if @local_config.key?(key)
|
139
|
-
locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
|
208
|
+
locations << "Set for your local app (#{local_config_file}): #{converted_value(@local_config[key], exposed_key).inspect}"
|
140
209
|
end
|
141
210
|
|
142
211
|
if value = ENV[key]
|
143
|
-
locations << "Set via #{key}: #{value.inspect}"
|
212
|
+
locations << "Set via #{key}: #{converted_value(value, exposed_key).inspect}"
|
144
213
|
end
|
145
214
|
|
146
215
|
if @global_config.key?(key)
|
147
|
-
locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
|
216
|
+
locations << "Set for the current user (#{global_config_file}): #{converted_value(@global_config[key], exposed_key).inspect}"
|
148
217
|
end
|
149
218
|
|
150
219
|
return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
|
151
220
|
locations
|
152
221
|
end
|
153
222
|
|
154
|
-
|
155
|
-
|
156
|
-
|
223
|
+
# for legacy reasons, in Bundler 1, the ruby scope isnt appended when the setting comes from ENV or the global config,
|
224
|
+
# nor do we respect :disable_shared_gems
|
225
|
+
def path
|
226
|
+
key = key_for(:path)
|
227
|
+
path = ENV[key] || @global_config[key]
|
228
|
+
if path && !@temporary.key?(key) && !@local_config.key?(key)
|
229
|
+
return Path.new(path, Bundler.feature_flag.global_path_appends_ruby_scope?, false, false)
|
230
|
+
end
|
157
231
|
|
158
|
-
|
159
|
-
|
232
|
+
system_path = self["path.system"] || (self[:disable_shared_gems] == false)
|
233
|
+
Path.new(self[:path], true, system_path, Bundler.feature_flag.default_install_uses_path?)
|
160
234
|
end
|
161
235
|
|
162
|
-
|
163
|
-
|
164
|
-
|
236
|
+
Path = Struct.new(:explicit_path, :append_ruby_scope, :system_path, :default_install_uses_path) do
|
237
|
+
def path
|
238
|
+
path = base_path
|
239
|
+
path = File.join(path, Bundler.ruby_scope) if append_ruby_scope && !use_system_gems?
|
240
|
+
path
|
241
|
+
end
|
165
242
|
|
166
|
-
|
167
|
-
|
168
|
-
|
243
|
+
def use_system_gems?
|
244
|
+
return true if system_path
|
245
|
+
return false if explicit_path
|
246
|
+
!default_install_uses_path
|
247
|
+
end
|
169
248
|
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
249
|
+
def base_path
|
250
|
+
path = explicit_path
|
251
|
+
path ||= ".bundle" unless use_system_gems?
|
252
|
+
path ||= Bundler.rubygems.gem_dir
|
253
|
+
path
|
254
|
+
end
|
175
255
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
256
|
+
def base_path_relative_to_pwd
|
257
|
+
base_path = Pathname.new(self.base_path)
|
258
|
+
expanded_base_path = base_path.expand_path(Bundler.root)
|
259
|
+
relative_path = expanded_base_path.relative_path_from(Pathname.pwd)
|
260
|
+
if relative_path.to_s.start_with?("..")
|
261
|
+
relative_path = base_path if base_path.absolute?
|
262
|
+
else
|
263
|
+
relative_path = Pathname.new(File.join(".", relative_path))
|
264
|
+
end
|
265
|
+
relative_path
|
266
|
+
rescue ArgumentError
|
267
|
+
expanded_base_path
|
268
|
+
end
|
269
|
+
|
270
|
+
def validate!
|
271
|
+
return unless explicit_path && system_path
|
272
|
+
path = Bundler.settings.pretty_values_for(:path)
|
273
|
+
path.unshift(nil, "path:") unless path.empty?
|
274
|
+
system_path = Bundler.settings.pretty_values_for("path.system")
|
275
|
+
system_path.unshift(nil, "path.system:") unless system_path.empty?
|
276
|
+
disable_shared_gems = Bundler.settings.pretty_values_for(:disable_shared_gems)
|
277
|
+
disable_shared_gems.unshift(nil, "disable_shared_gems:") unless disable_shared_gems.empty?
|
278
|
+
raise InvalidOption,
|
279
|
+
"Using a custom path while using system gems is unsupported.\n#{path.join("\n")}\n#{system_path.join("\n")}\n#{disable_shared_gems.join("\n")}"
|
180
280
|
end
|
181
281
|
end
|
182
282
|
|
183
283
|
def allow_sudo?
|
184
|
-
|
284
|
+
key = key_for(:path)
|
285
|
+
path_configured = @temporary.key?(key) || @local_config.key?(key)
|
286
|
+
!path_configured
|
185
287
|
end
|
186
288
|
|
187
289
|
def ignore_config?
|
@@ -189,14 +291,17 @@ module Bundler
|
|
189
291
|
end
|
190
292
|
|
191
293
|
def app_cache_path
|
192
|
-
@app_cache_path ||=
|
193
|
-
path = self[:cache_path] || "vendor/cache"
|
194
|
-
raise InvalidOption, "Cache path must be relative to the bundle path" if path.start_with?("/")
|
195
|
-
path
|
196
|
-
end
|
294
|
+
@app_cache_path ||= self[:cache_path] || "vendor/cache"
|
197
295
|
end
|
198
296
|
|
199
|
-
|
297
|
+
def validate!
|
298
|
+
all.each do |raw_key|
|
299
|
+
[@local_config, ENV, @global_config].each do |settings|
|
300
|
+
value = converted_value(settings[key_for(raw_key)], raw_key)
|
301
|
+
Validator.validate!(raw_key, value, settings.to_hash.dup)
|
302
|
+
end
|
303
|
+
end
|
304
|
+
end
|
200
305
|
|
201
306
|
def key_for(key)
|
202
307
|
key = Settings.normalize_uri(key).to_s if key.is_a?(String) && /https?:/ =~ key
|
@@ -204,15 +309,17 @@ module Bundler
|
|
204
309
|
"BUNDLE_#{key}"
|
205
310
|
end
|
206
311
|
|
312
|
+
private
|
313
|
+
|
207
314
|
def parent_setting_for(name)
|
208
|
-
|
315
|
+
split_specific_setting_for(name)[0]
|
209
316
|
end
|
210
317
|
|
211
|
-
def
|
212
|
-
|
318
|
+
def specific_gem_for(name)
|
319
|
+
split_specific_setting_for(name)[1]
|
213
320
|
end
|
214
321
|
|
215
|
-
def
|
322
|
+
def split_specific_setting_for(name)
|
216
323
|
name.split(".")
|
217
324
|
end
|
218
325
|
|
@@ -221,42 +328,77 @@ module Bundler
|
|
221
328
|
end
|
222
329
|
|
223
330
|
def to_bool(value)
|
224
|
-
|
331
|
+
case value
|
332
|
+
when nil, /\A(false|f|no|n|0|)\z/i, false
|
333
|
+
false
|
334
|
+
else
|
335
|
+
true
|
336
|
+
end
|
225
337
|
end
|
226
338
|
|
227
|
-
def is_num(
|
228
|
-
NUMBER_KEYS.include?(
|
339
|
+
def is_num(key)
|
340
|
+
NUMBER_KEYS.include?(key.to_s)
|
229
341
|
end
|
230
342
|
|
231
|
-
def
|
232
|
-
|
343
|
+
def is_array(key)
|
344
|
+
ARRAY_KEYS.include?(key.to_s)
|
233
345
|
end
|
234
346
|
|
235
|
-
def
|
236
|
-
|
347
|
+
def to_array(value)
|
348
|
+
return [] unless value
|
349
|
+
value.split(":").map(&:to_sym)
|
237
350
|
end
|
238
351
|
|
239
|
-
def
|
240
|
-
|
352
|
+
def array_to_s(array)
|
353
|
+
array = Array(array)
|
354
|
+
return nil if array.empty?
|
355
|
+
array.join(":").tr(" ", ":")
|
356
|
+
end
|
241
357
|
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
358
|
+
def set_key(raw_key, value, hash, file)
|
359
|
+
raw_key = raw_key.to_s
|
360
|
+
value = array_to_s(value) if is_array(raw_key)
|
361
|
+
|
362
|
+
key = key_for(raw_key)
|
363
|
+
|
364
|
+
return if hash[key] == value
|
365
|
+
|
366
|
+
hash[key] = value
|
367
|
+
hash.delete(key) if value.nil?
|
368
|
+
|
369
|
+
Validator.validate!(raw_key, converted_value(value, raw_key), hash)
|
370
|
+
|
371
|
+
return unless file
|
372
|
+
SharedHelpers.filesystem_access(file) do |p|
|
373
|
+
FileUtils.mkdir_p(p.dirname)
|
374
|
+
require "bundler/yaml_serializer"
|
375
|
+
p.open("w") {|f| f.write(YAMLSerializer.dump(hash)) }
|
250
376
|
end
|
377
|
+
end
|
251
378
|
|
252
|
-
|
379
|
+
def converted_value(value, key)
|
380
|
+
if is_array(key)
|
381
|
+
to_array(value)
|
382
|
+
elsif value.nil?
|
383
|
+
nil
|
384
|
+
elsif is_bool(key) || value == "false"
|
385
|
+
to_bool(value)
|
386
|
+
elsif is_num(key)
|
387
|
+
value.to_i
|
388
|
+
else
|
389
|
+
value.to_s
|
390
|
+
end
|
253
391
|
end
|
254
392
|
|
255
393
|
def global_config_file
|
256
394
|
if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
|
257
395
|
Pathname.new(ENV["BUNDLE_CONFIG"])
|
258
396
|
else
|
259
|
-
|
397
|
+
begin
|
398
|
+
Bundler.user_bundle_path("config")
|
399
|
+
rescue PermissionError, GenericSystemCallError
|
400
|
+
nil
|
401
|
+
end
|
260
402
|
end
|
261
403
|
end
|
262
404
|
|
@@ -279,25 +421,43 @@ module Bundler
|
|
279
421
|
}xo
|
280
422
|
|
281
423
|
def load_config(config_file)
|
282
|
-
return {}
|
424
|
+
return {} if !config_file || ignore_config?
|
283
425
|
SharedHelpers.filesystem_access(config_file, :read) do |file|
|
284
426
|
valid_file = file.exist? && !file.size.zero?
|
285
|
-
return {}
|
427
|
+
return {} unless valid_file
|
286
428
|
require "bundler/yaml_serializer"
|
287
429
|
YAMLSerializer.load file.read
|
288
430
|
end
|
289
431
|
end
|
290
432
|
|
433
|
+
PER_URI_OPTIONS = %w[
|
434
|
+
fallback_timeout
|
435
|
+
].freeze
|
436
|
+
|
437
|
+
NORMALIZE_URI_OPTIONS_PATTERN =
|
438
|
+
/
|
439
|
+
\A
|
440
|
+
(\w+\.)? # optional prefix key
|
441
|
+
(https?.*?) # URI
|
442
|
+
(\.#{Regexp.union(PER_URI_OPTIONS)})? # optional suffix key
|
443
|
+
\z
|
444
|
+
/ix
|
445
|
+
|
291
446
|
# TODO: duplicates Rubygems#normalize_uri
|
292
447
|
# TODO: is this the correct place to validate mirror URIs?
|
293
448
|
def self.normalize_uri(uri)
|
294
449
|
uri = uri.to_s
|
295
|
-
|
450
|
+
if uri =~ NORMALIZE_URI_OPTIONS_PATTERN
|
451
|
+
prefix = $1
|
452
|
+
uri = $2
|
453
|
+
suffix = $3
|
454
|
+
end
|
455
|
+
uri = "#{uri}/" unless uri.end_with?("/")
|
296
456
|
uri = URI(uri)
|
297
457
|
unless uri.absolute?
|
298
458
|
raise ArgumentError, format("Gem sources must be absolute. You provided '%s'.", uri)
|
299
459
|
end
|
300
|
-
uri
|
460
|
+
"#{prefix}#{uri}#{suffix}"
|
301
461
|
end
|
302
462
|
end
|
303
463
|
end
|