bundler 2.0.2
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 +7 -0
- data/CHANGELOG.md +3111 -0
- data/LICENSE.md +23 -0
- data/README.md +63 -0
- data/bundler.gemspec +65 -0
- data/exe/bundle +31 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +4 -0
- data/lib/bundler.rb +567 -0
- data/lib/bundler/build_metadata.rb +53 -0
- data/lib/bundler/capistrano.rb +22 -0
- data/lib/bundler/cli.rb +792 -0
- data/lib/bundler/cli/add.rb +35 -0
- data/lib/bundler/cli/binstubs.rb +49 -0
- data/lib/bundler/cli/cache.rb +36 -0
- data/lib/bundler/cli/check.rb +38 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +102 -0
- data/lib/bundler/cli/config.rb +119 -0
- data/lib/bundler/cli/console.rb +43 -0
- data/lib/bundler/cli/doctor.rb +140 -0
- data/lib/bundler/cli/exec.rb +105 -0
- data/lib/bundler/cli/gem.rb +252 -0
- data/lib/bundler/cli/info.rb +50 -0
- data/lib/bundler/cli/init.rb +47 -0
- data/lib/bundler/cli/inject.rb +60 -0
- data/lib/bundler/cli/install.rb +218 -0
- data/lib/bundler/cli/issue.rb +40 -0
- data/lib/bundler/cli/list.rb +58 -0
- data/lib/bundler/cli/lock.rb +63 -0
- data/lib/bundler/cli/open.rb +26 -0
- data/lib/bundler/cli/outdated.rb +266 -0
- data/lib/bundler/cli/package.rb +49 -0
- data/lib/bundler/cli/platform.rb +46 -0
- data/lib/bundler/cli/plugin.rb +24 -0
- data/lib/bundler/cli/pristine.rb +47 -0
- data/lib/bundler/cli/remove.rb +18 -0
- data/lib/bundler/cli/show.rb +75 -0
- data/lib/bundler/cli/update.rb +91 -0
- data/lib/bundler/cli/viz.rb +31 -0
- 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 +13 -0
- data/lib/bundler/constants.rb +7 -0
- data/lib/bundler/current_ruby.rb +94 -0
- data/lib/bundler/definition.rb +995 -0
- data/lib/bundler/dep_proxy.rb +48 -0
- data/lib/bundler/dependency.rb +139 -0
- data/lib/bundler/deployment.rb +69 -0
- data/lib/bundler/deprecate.rb +44 -0
- data/lib/bundler/dsl.rb +615 -0
- data/lib/bundler/endpoint_specification.rb +141 -0
- data/lib/bundler/env.rb +149 -0
- data/lib/bundler/environment_preserver.rb +59 -0
- data/lib/bundler/errors.rb +158 -0
- data/lib/bundler/feature_flag.rb +75 -0
- data/lib/bundler/fetcher.rb +312 -0
- data/lib/bundler/fetcher/base.rb +52 -0
- data/lib/bundler/fetcher/compact_index.rb +126 -0
- data/lib/bundler/fetcher/dependency.rb +82 -0
- data/lib/bundler/fetcher/downloader.rb +84 -0
- data/lib/bundler/fetcher/index.rb +52 -0
- data/lib/bundler/friendly_errors.rb +131 -0
- data/lib/bundler/gem_helper.rb +217 -0
- data/lib/bundler/gem_helpers.rb +101 -0
- data/lib/bundler/gem_remote_fetcher.rb +43 -0
- data/lib/bundler/gem_tasks.rb +7 -0
- data/lib/bundler/gem_version_promoter.rb +190 -0
- data/lib/bundler/gemdeps.rb +29 -0
- data/lib/bundler/graph.rb +152 -0
- data/lib/bundler/index.rb +213 -0
- data/lib/bundler/injector.rb +253 -0
- data/lib/bundler/inline.rb +74 -0
- data/lib/bundler/installer.rb +318 -0
- data/lib/bundler/installer/gem_installer.rb +85 -0
- data/lib/bundler/installer/parallel_installer.rb +229 -0
- data/lib/bundler/installer/standalone.rb +53 -0
- data/lib/bundler/lazy_specification.rb +123 -0
- data/lib/bundler/lockfile_generator.rb +95 -0
- data/lib/bundler/lockfile_parser.rb +256 -0
- data/lib/bundler/match_platform.rb +24 -0
- data/lib/bundler/mirror.rb +223 -0
- data/lib/bundler/plugin.rb +294 -0
- data/lib/bundler/plugin/api.rb +81 -0
- data/lib/bundler/plugin/api/source.rb +306 -0
- data/lib/bundler/plugin/dsl.rb +53 -0
- data/lib/bundler/plugin/events.rb +61 -0
- data/lib/bundler/plugin/index.rb +165 -0
- data/lib/bundler/plugin/installer.rb +96 -0
- data/lib/bundler/plugin/installer/git.rb +38 -0
- data/lib/bundler/plugin/installer/rubygems.rb +27 -0
- data/lib/bundler/plugin/source_list.rb +27 -0
- data/lib/bundler/process_lock.rb +24 -0
- data/lib/bundler/psyched_yaml.rb +37 -0
- data/lib/bundler/remote_specification.rb +114 -0
- data/lib/bundler/resolver.rb +373 -0
- data/lib/bundler/resolver/spec_group.rb +106 -0
- data/lib/bundler/retry.rb +66 -0
- data/lib/bundler/ruby_dsl.rb +18 -0
- data/lib/bundler/ruby_version.rb +152 -0
- data/lib/bundler/rubygems_ext.rb +209 -0
- data/lib/bundler/rubygems_gem_installer.rb +99 -0
- data/lib/bundler/rubygems_integration.rb +915 -0
- data/lib/bundler/runtime.rb +322 -0
- data/lib/bundler/settings.rb +464 -0
- data/lib/bundler/settings/validator.rb +102 -0
- data/lib/bundler/setup.rb +28 -0
- data/lib/bundler/shared_helpers.rb +386 -0
- data/lib/bundler/similarity_detector.rb +63 -0
- data/lib/bundler/source.rb +94 -0
- data/lib/bundler/source/gemspec.rb +18 -0
- data/lib/bundler/source/git.rb +329 -0
- data/lib/bundler/source/git/git_proxy.rb +262 -0
- data/lib/bundler/source/metadata.rb +62 -0
- data/lib/bundler/source/path.rb +249 -0
- data/lib/bundler/source/path/installer.rb +74 -0
- data/lib/bundler/source/rubygems.rb +539 -0
- data/lib/bundler/source/rubygems/remote.rb +69 -0
- data/lib/bundler/source_list.rb +186 -0
- data/lib/bundler/spec_set.rb +208 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +66 -0
- data/lib/bundler/ssl_certs/index.rubygems.org/GlobalSignRootCA.pem +21 -0
- data/lib/bundler/ssl_certs/rubygems.global.ssl.fastly.net/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/rubygems.org/AddTrustExternalCARoot.pem +25 -0
- data/lib/bundler/stub_specification.rb +108 -0
- data/lib/bundler/templates/.document +1 -0
- data/lib/bundler/templates/Executable +29 -0
- data/lib/bundler/templates/Executable.bundler +105 -0
- data/lib/bundler/templates/Executable.standalone +14 -0
- data/lib/bundler/templates/Gemfile +7 -0
- data/lib/bundler/templates/gems.rb +8 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +74 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +21 -0
- data/lib/bundler/templates/newgem/README.md.tt +47 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +29 -0
- data/lib/bundler/templates/newgem/bin/console.tt +14 -0
- data/lib/bundler/templates/newgem/bin/setup.tt +8 -0
- data/lib/bundler/templates/newgem/exe/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/extconf.rb.tt +3 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.c.tt +9 -0
- data/lib/bundler/templates/newgem/ext/newgem/newgem.h.tt +6 -0
- data/lib/bundler/templates/newgem/gitignore.tt +20 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +13 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +50 -0
- data/lib/bundler/templates/newgem/rspec.tt +3 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +9 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +14 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +8 -0
- data/lib/bundler/templates/newgem/travis.yml.tt +7 -0
- data/lib/bundler/ui.rb +9 -0
- data/lib/bundler/ui/rg_proxy.rb +19 -0
- data/lib/bundler/ui/shell.rb +146 -0
- data/lib/bundler/ui/silent.rb +69 -0
- data/lib/bundler/uri_credentials_filter.rb +37 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils.rb +1741 -0
- data/lib/bundler/vendor/fileutils/lib/fileutils/version.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +12 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/compatibility.rb +26 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/resolution_state.rb +57 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/delegates/specification_provider.rb +81 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +223 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/action.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_edge_no_circular.rb +66 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/add_vertex.rb +62 -0
- 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 +61 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/log.rb +126 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/set_payload.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/tag.rb +36 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph/vertex.rb +136 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +143 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +6 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +101 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +67 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +837 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +46 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +58 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent.rb +1233 -0
- data/lib/bundler/vendor/net-http-persistent/lib/net/http/persistent/ssl_reuse.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +509 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +331 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +104 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +60 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +143 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +373 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +678 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +97 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +12 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +129 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +114 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +177 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +37 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/lib/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/argument.rb +70 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +146 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +226 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +324 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +482 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/lib/thor/util.rb +268 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_fileutils.rb +9 -0
- data/lib/bundler/vendored_molinillo.rb +4 -0
- data/lib/bundler/vendored_persistent.rb +52 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- data/lib/bundler/version.rb +28 -0
- data/lib/bundler/version_ranges.rb +76 -0
- data/lib/bundler/vlad.rb +17 -0
- data/lib/bundler/worker.rb +106 -0
- data/lib/bundler/yaml_serializer.rb +90 -0
- data/man/bundle-add.1 +58 -0
- data/man/bundle-add.1.txt +52 -0
- data/man/bundle-add.ronn +40 -0
- data/man/bundle-binstubs.1 +40 -0
- data/man/bundle-binstubs.1.txt +48 -0
- data/man/bundle-binstubs.ronn +43 -0
- 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 +397 -0
- data/man/bundle-doctor.1 +44 -0
- data/man/bundle-doctor.1.txt +44 -0
- data/man/bundle-doctor.ronn +33 -0
- data/man/bundle-exec.1 +165 -0
- data/man/bundle-exec.1.txt +178 -0
- data/man/bundle-exec.ronn +152 -0
- data/man/bundle-gem.1 +80 -0
- data/man/bundle-gem.1.txt +91 -0
- data/man/bundle-gem.ronn +78 -0
- 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/man/bundle-install.1 +308 -0
- data/man/bundle-install.1.txt +396 -0
- data/man/bundle-install.ronn +378 -0
- data/man/bundle-list.1 +50 -0
- data/man/bundle-list.1.txt +43 -0
- data/man/bundle-list.ronn +33 -0
- data/man/bundle-lock.1 +84 -0
- data/man/bundle-lock.1.txt +93 -0
- data/man/bundle-lock.ronn +94 -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/man/bundle-package.1 +55 -0
- data/man/bundle-package.1.txt +79 -0
- data/man/bundle-package.ronn +72 -0
- data/man/bundle-platform.1 +61 -0
- data/man/bundle-platform.1.txt +57 -0
- data/man/bundle-platform.ronn +42 -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 +350 -0
- data/man/bundle-viz.1 +39 -0
- data/man/bundle-viz.1.txt +39 -0
- data/man/bundle-viz.ronn +30 -0
- data/man/bundle.1 +136 -0
- data/man/bundle.1.txt +116 -0
- data/man/bundle.ronn +111 -0
- data/man/gemfile.5 +689 -0
- data/man/gemfile.5.ronn +521 -0
- data/man/gemfile.5.txt +653 -0
- data/man/index.txt +25 -0
- metadata +463 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Resolver
|
5
|
+
class SpecGroup
|
6
|
+
include GemHelpers
|
7
|
+
|
8
|
+
attr_accessor :name, :version, :source
|
9
|
+
attr_accessor :ignores_bundler_dependencies
|
10
|
+
|
11
|
+
def initialize(all_specs)
|
12
|
+
raise ArgumentError, "cannot initialize with an empty value" unless exemplary_spec = all_specs.first
|
13
|
+
@name = exemplary_spec.name
|
14
|
+
@version = exemplary_spec.version
|
15
|
+
@source = exemplary_spec.source
|
16
|
+
|
17
|
+
@activated_platforms = []
|
18
|
+
@dependencies = nil
|
19
|
+
@specs = Hash.new do |specs, platform|
|
20
|
+
specs[platform] = select_best_platform_match(all_specs, platform)
|
21
|
+
end
|
22
|
+
@ignores_bundler_dependencies = true
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_specs
|
26
|
+
@activated_platforms.map do |p|
|
27
|
+
next unless s = @specs[p]
|
28
|
+
lazy_spec = LazySpecification.new(name, version, s.platform, source)
|
29
|
+
lazy_spec.dependencies.replace s.dependencies
|
30
|
+
lazy_spec
|
31
|
+
end.compact
|
32
|
+
end
|
33
|
+
|
34
|
+
def activate_platform!(platform)
|
35
|
+
return unless for?(platform)
|
36
|
+
return if @activated_platforms.include?(platform)
|
37
|
+
@activated_platforms << platform
|
38
|
+
end
|
39
|
+
|
40
|
+
def for?(platform)
|
41
|
+
spec = @specs[platform]
|
42
|
+
!spec.nil?
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_s
|
46
|
+
@to_s ||= "#{name} (#{version})"
|
47
|
+
end
|
48
|
+
|
49
|
+
def dependencies_for_activated_platforms
|
50
|
+
dependencies = @activated_platforms.map {|p| __dependencies[p] }
|
51
|
+
metadata_dependencies = @activated_platforms.map do |platform|
|
52
|
+
metadata_dependencies(@specs[platform], platform)
|
53
|
+
end
|
54
|
+
dependencies.concat(metadata_dependencies).flatten
|
55
|
+
end
|
56
|
+
|
57
|
+
def ==(other)
|
58
|
+
return unless other.is_a?(SpecGroup)
|
59
|
+
name == other.name &&
|
60
|
+
version == other.version &&
|
61
|
+
source == other.source
|
62
|
+
end
|
63
|
+
|
64
|
+
def eql?(other)
|
65
|
+
name.eql?(other.name) &&
|
66
|
+
version.eql?(other.version) &&
|
67
|
+
source.eql?(other.source)
|
68
|
+
end
|
69
|
+
|
70
|
+
def hash
|
71
|
+
to_s.hash ^ source.hash
|
72
|
+
end
|
73
|
+
|
74
|
+
private
|
75
|
+
|
76
|
+
def __dependencies
|
77
|
+
@dependencies = Hash.new do |dependencies, platform|
|
78
|
+
dependencies[platform] = []
|
79
|
+
if spec = @specs[platform]
|
80
|
+
spec.dependencies.each do |dep|
|
81
|
+
next if dep.type == :development
|
82
|
+
next if @ignores_bundler_dependencies && dep.name == "bundler".freeze
|
83
|
+
dependencies[platform] << DepProxy.new(dep, platform)
|
84
|
+
end
|
85
|
+
end
|
86
|
+
dependencies[platform]
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def metadata_dependencies(spec, platform)
|
91
|
+
return [] unless spec
|
92
|
+
# Only allow endpoint specifications since they won't hit the network to
|
93
|
+
# fetch the full gemspec when calling required_ruby_version
|
94
|
+
return [] if !spec.is_a?(EndpointSpecification) && !spec.is_a?(Gem::Specification)
|
95
|
+
dependencies = []
|
96
|
+
if !spec.required_ruby_version.nil? && !spec.required_ruby_version.none?
|
97
|
+
dependencies << DepProxy.new(Gem::Dependency.new("ruby\0", spec.required_ruby_version), platform)
|
98
|
+
end
|
99
|
+
if !spec.required_rubygems_version.nil? && !spec.required_rubygems_version.none?
|
100
|
+
dependencies << DepProxy.new(Gem::Dependency.new("rubygems\0", spec.required_rubygems_version), platform)
|
101
|
+
end
|
102
|
+
dependencies
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
# General purpose class for retrying code that may fail
|
5
|
+
class Retry
|
6
|
+
attr_accessor :name, :total_runs, :current_run
|
7
|
+
|
8
|
+
class << self
|
9
|
+
def default_attempts
|
10
|
+
default_retries + 1
|
11
|
+
end
|
12
|
+
alias_method :attempts, :default_attempts
|
13
|
+
|
14
|
+
def default_retries
|
15
|
+
Bundler.settings[:retry]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def initialize(name, exceptions = nil, retries = self.class.default_retries)
|
20
|
+
@name = name
|
21
|
+
@retries = retries
|
22
|
+
@exceptions = Array(exceptions) || []
|
23
|
+
@total_runs = @retries + 1 # will run once, then upto attempts.times
|
24
|
+
end
|
25
|
+
|
26
|
+
def attempt(&block)
|
27
|
+
@current_run = 0
|
28
|
+
@failed = false
|
29
|
+
@error = nil
|
30
|
+
run(&block) while keep_trying?
|
31
|
+
@result
|
32
|
+
end
|
33
|
+
alias_method :attempts, :attempt
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def run(&block)
|
38
|
+
@failed = false
|
39
|
+
@current_run += 1
|
40
|
+
@result = block.call
|
41
|
+
rescue => e
|
42
|
+
fail_attempt(e)
|
43
|
+
end
|
44
|
+
|
45
|
+
def fail_attempt(e)
|
46
|
+
@failed = true
|
47
|
+
if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
|
48
|
+
Bundler.ui.info "" unless Bundler.ui.debug?
|
49
|
+
raise e
|
50
|
+
end
|
51
|
+
return true unless name
|
52
|
+
Bundler.ui.info "" unless Bundler.ui.debug? # Add new line incase dots preceded this
|
53
|
+
Bundler.ui.warn "Retrying #{name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}", Bundler.ui.debug?
|
54
|
+
end
|
55
|
+
|
56
|
+
def keep_trying?
|
57
|
+
return true if current_run.zero?
|
58
|
+
return false if last_attempt?
|
59
|
+
return true if @failed
|
60
|
+
end
|
61
|
+
|
62
|
+
def last_attempt?
|
63
|
+
current_run >= total_runs
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
module RubyDsl
|
5
|
+
def ruby(*ruby_version)
|
6
|
+
options = ruby_version.last.is_a?(Hash) ? ruby_version.pop : {}
|
7
|
+
ruby_version.flatten!
|
8
|
+
raise GemfileError, "Please define :engine_version" if options[:engine] && options[:engine_version].nil?
|
9
|
+
raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
|
10
|
+
|
11
|
+
if options[:engine] == "ruby" && options[:engine_version] &&
|
12
|
+
ruby_version != Array(options[:engine_version])
|
13
|
+
raise GemfileEvalError, "ruby_version must match the :engine_version for MRI"
|
14
|
+
end
|
15
|
+
@ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class RubyVersion
|
5
|
+
attr_reader :versions,
|
6
|
+
:patchlevel,
|
7
|
+
:engine,
|
8
|
+
:engine_versions,
|
9
|
+
:gem_version,
|
10
|
+
:engine_gem_version
|
11
|
+
|
12
|
+
def initialize(versions, patchlevel, engine, engine_version)
|
13
|
+
# The parameters to this method must satisfy the
|
14
|
+
# following constraints, which are verified in
|
15
|
+
# the DSL:
|
16
|
+
#
|
17
|
+
# * If an engine is specified, an engine version
|
18
|
+
# must also be specified
|
19
|
+
# * If an engine version is specified, an engine
|
20
|
+
# must also be specified
|
21
|
+
# * If the engine is "ruby", the engine version
|
22
|
+
# must not be specified, or the engine version
|
23
|
+
# specified must match the version.
|
24
|
+
|
25
|
+
@versions = Array(versions).map do |v|
|
26
|
+
op, v = Gem::Requirement.parse(v)
|
27
|
+
op == "=" ? v.to_s : "#{op} #{v}"
|
28
|
+
end
|
29
|
+
|
30
|
+
@gem_version = Gem::Requirement.create(@versions.first).requirements.first.last
|
31
|
+
@input_engine = engine && engine.to_s
|
32
|
+
@engine = engine && engine.to_s || "ruby"
|
33
|
+
@engine_versions = (engine_version && Array(engine_version)) || @versions
|
34
|
+
@engine_gem_version = Gem::Requirement.create(@engine_versions.first).requirements.first.last
|
35
|
+
@patchlevel = patchlevel
|
36
|
+
end
|
37
|
+
|
38
|
+
def to_s(versions = self.versions)
|
39
|
+
output = String.new("ruby #{versions_string(versions)}")
|
40
|
+
output << "p#{patchlevel}" if patchlevel
|
41
|
+
output << " (#{engine} #{versions_string(engine_versions)})" unless engine == "ruby"
|
42
|
+
|
43
|
+
output
|
44
|
+
end
|
45
|
+
|
46
|
+
# @private
|
47
|
+
PATTERN = /
|
48
|
+
ruby\s
|
49
|
+
([\d.]+) # ruby version
|
50
|
+
(?:p(-?\d+))? # optional patchlevel
|
51
|
+
(?:\s\((\S+)\s(.+)\))? # optional engine info
|
52
|
+
/xo
|
53
|
+
|
54
|
+
# Returns a RubyVersion from the given string.
|
55
|
+
# @param [String] the version string to match.
|
56
|
+
# @return [RubyVersion,Nil] The version if the string is a valid RubyVersion
|
57
|
+
# description, and nil otherwise.
|
58
|
+
def self.from_string(string)
|
59
|
+
new($1, $2, $3, $4) if string =~ PATTERN
|
60
|
+
end
|
61
|
+
|
62
|
+
def single_version_string
|
63
|
+
to_s(gem_version)
|
64
|
+
end
|
65
|
+
|
66
|
+
def ==(other)
|
67
|
+
versions == other.versions &&
|
68
|
+
engine == other.engine &&
|
69
|
+
engine_versions == other.engine_versions &&
|
70
|
+
patchlevel == other.patchlevel
|
71
|
+
end
|
72
|
+
|
73
|
+
def host
|
74
|
+
@host ||= [
|
75
|
+
RbConfig::CONFIG["host_cpu"],
|
76
|
+
RbConfig::CONFIG["host_vendor"],
|
77
|
+
RbConfig::CONFIG["host_os"]
|
78
|
+
].join("-")
|
79
|
+
end
|
80
|
+
|
81
|
+
# Returns a tuple of these things:
|
82
|
+
# [diff, this, other]
|
83
|
+
# The priority of attributes are
|
84
|
+
# 1. engine
|
85
|
+
# 2. ruby_version
|
86
|
+
# 3. engine_version
|
87
|
+
def diff(other)
|
88
|
+
raise ArgumentError, "Can only diff with a RubyVersion, not a #{other.class}" unless other.is_a?(RubyVersion)
|
89
|
+
if engine != other.engine && @input_engine
|
90
|
+
[:engine, engine, other.engine]
|
91
|
+
elsif versions.empty? || !matches?(versions, other.gem_version)
|
92
|
+
[:version, versions_string(versions), versions_string(other.versions)]
|
93
|
+
elsif @input_engine && !matches?(engine_versions, other.engine_gem_version)
|
94
|
+
[:engine_version, versions_string(engine_versions), versions_string(other.engine_versions)]
|
95
|
+
elsif patchlevel && (!patchlevel.is_a?(String) || !other.patchlevel.is_a?(String) || !matches?(patchlevel, other.patchlevel))
|
96
|
+
[:patchlevel, patchlevel, other.patchlevel]
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def versions_string(versions)
|
101
|
+
Array(versions).join(", ")
|
102
|
+
end
|
103
|
+
|
104
|
+
def self.system
|
105
|
+
ruby_engine = if defined?(RUBY_ENGINE) && !RUBY_ENGINE.nil?
|
106
|
+
RUBY_ENGINE.dup
|
107
|
+
else
|
108
|
+
# not defined in ruby 1.8.7
|
109
|
+
"ruby"
|
110
|
+
end
|
111
|
+
# :sob: mocking RUBY_VERSION breaks stuff on 1.8.7
|
112
|
+
ruby_version = ENV.fetch("BUNDLER_SPEC_RUBY_VERSION") { RUBY_VERSION }.dup
|
113
|
+
ruby_engine_version = case ruby_engine
|
114
|
+
when "ruby"
|
115
|
+
ruby_version
|
116
|
+
when "rbx"
|
117
|
+
Rubinius::VERSION.dup
|
118
|
+
when "jruby"
|
119
|
+
JRUBY_VERSION.dup
|
120
|
+
else
|
121
|
+
RUBY_ENGINE_VERSION.dup
|
122
|
+
end
|
123
|
+
patchlevel = RUBY_PATCHLEVEL.to_s
|
124
|
+
|
125
|
+
@ruby_version ||= RubyVersion.new(ruby_version, patchlevel, ruby_engine, ruby_engine_version)
|
126
|
+
end
|
127
|
+
|
128
|
+
def to_gem_version_with_patchlevel
|
129
|
+
@gem_version_with_patch ||= begin
|
130
|
+
Gem::Version.create("#{@gem_version}.#{@patchlevel}")
|
131
|
+
rescue ArgumentError
|
132
|
+
@gem_version
|
133
|
+
end
|
134
|
+
end
|
135
|
+
|
136
|
+
def exact?
|
137
|
+
return @exact if defined?(@exact)
|
138
|
+
@exact = versions.all? {|v| Gem::Requirement.create(v).exact? }
|
139
|
+
end
|
140
|
+
|
141
|
+
private
|
142
|
+
|
143
|
+
def matches?(requirements, version)
|
144
|
+
# Handles RUBY_PATCHLEVEL of -1 for instances like ruby-head
|
145
|
+
return requirements == version if requirements.to_s == "-1" || version.to_s == "-1"
|
146
|
+
|
147
|
+
Array(requirements).all? do |requirement|
|
148
|
+
Gem::Requirement.create(requirement).satisfied_by?(Gem::Version.create(version))
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
@@ -0,0 +1,209 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "pathname"
|
4
|
+
|
5
|
+
if defined?(Gem::QuickLoader)
|
6
|
+
# Gem Prelude makes me a sad panda :'(
|
7
|
+
Gem::QuickLoader.load_full_rubygems_library
|
8
|
+
end
|
9
|
+
|
10
|
+
require "rubygems/specification"
|
11
|
+
|
12
|
+
begin
|
13
|
+
# Possible use in Gem::Specification#source below and require
|
14
|
+
# shouldn't be deferred.
|
15
|
+
require "rubygems/source"
|
16
|
+
rescue LoadError
|
17
|
+
# Not available before RubyGems 2.0.0, ignore
|
18
|
+
nil
|
19
|
+
end
|
20
|
+
|
21
|
+
require "bundler/match_platform"
|
22
|
+
|
23
|
+
module Gem
|
24
|
+
@loaded_stacks = Hash.new {|h, k| h[k] = [] }
|
25
|
+
|
26
|
+
class Specification
|
27
|
+
attr_accessor :remote, :location, :relative_loaded_from
|
28
|
+
|
29
|
+
if instance_methods(false).map(&:to_sym).include?(:source)
|
30
|
+
remove_method :source
|
31
|
+
attr_writer :source
|
32
|
+
def source
|
33
|
+
(defined?(@source) && @source) || Gem::Source::Installed.new
|
34
|
+
end
|
35
|
+
else
|
36
|
+
attr_accessor :source
|
37
|
+
end
|
38
|
+
|
39
|
+
alias_method :rg_full_gem_path, :full_gem_path
|
40
|
+
alias_method :rg_loaded_from, :loaded_from
|
41
|
+
|
42
|
+
attr_writer :full_gem_path unless instance_methods.include?(:full_gem_path=)
|
43
|
+
|
44
|
+
def full_gem_path
|
45
|
+
# this cannot check source.is_a?(Bundler::Plugin::API::Source)
|
46
|
+
# because that _could_ trip the autoload, and if there are unresolved
|
47
|
+
# gems at that time, this method could be called inside another require,
|
48
|
+
# thus raising with that constant being undefined. Better to check a method
|
49
|
+
if source.respond_to?(:path) || (source.respond_to?(:bundler_plugin_api_source?) && source.bundler_plugin_api_source?)
|
50
|
+
Pathname.new(loaded_from).dirname.expand_path(source.root).to_s.untaint
|
51
|
+
else
|
52
|
+
rg_full_gem_path
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def loaded_from
|
57
|
+
if relative_loaded_from
|
58
|
+
source.path.join(relative_loaded_from).to_s
|
59
|
+
else
|
60
|
+
rg_loaded_from
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
def load_paths
|
65
|
+
return full_require_paths if respond_to?(:full_require_paths)
|
66
|
+
|
67
|
+
require_paths.map do |require_path|
|
68
|
+
if require_path.include?(full_gem_path)
|
69
|
+
require_path
|
70
|
+
else
|
71
|
+
File.join(full_gem_path, require_path)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
if method_defined?(:extension_dir)
|
77
|
+
alias_method :rg_extension_dir, :extension_dir
|
78
|
+
def extension_dir
|
79
|
+
@bundler_extension_dir ||= if source.respond_to?(:extension_dir_name)
|
80
|
+
File.expand_path(File.join(extensions_dir, source.extension_dir_name))
|
81
|
+
else
|
82
|
+
rg_extension_dir
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
# RubyGems 1.8+ used only.
|
88
|
+
methods = instance_methods(false)
|
89
|
+
gem_dir = methods.first.is_a?(String) ? "gem_dir" : :gem_dir
|
90
|
+
remove_method :gem_dir if methods.include?(gem_dir)
|
91
|
+
def gem_dir
|
92
|
+
full_gem_path
|
93
|
+
end
|
94
|
+
|
95
|
+
def groups
|
96
|
+
@groups ||= []
|
97
|
+
end
|
98
|
+
|
99
|
+
def git_version
|
100
|
+
return unless loaded_from && source.is_a?(Bundler::Source::Git)
|
101
|
+
" #{source.revision[0..6]}"
|
102
|
+
end
|
103
|
+
|
104
|
+
def to_gemfile(path = nil)
|
105
|
+
gemfile = String.new("source 'https://rubygems.org'\n")
|
106
|
+
gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
|
107
|
+
unless development_dependencies.empty?
|
108
|
+
gemfile << "\n"
|
109
|
+
gemfile << dependencies_to_gemfile(development_dependencies, :development)
|
110
|
+
end
|
111
|
+
gemfile
|
112
|
+
end
|
113
|
+
|
114
|
+
def nondevelopment_dependencies
|
115
|
+
dependencies - development_dependencies
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def dependencies_to_gemfile(dependencies, group = nil)
|
121
|
+
gemfile = String.new
|
122
|
+
if dependencies.any?
|
123
|
+
gemfile << "group :#{group} do\n" if group
|
124
|
+
dependencies.each do |dependency|
|
125
|
+
gemfile << " " if group
|
126
|
+
gemfile << %(gem "#{dependency.name}")
|
127
|
+
req = dependency.requirements_list.first
|
128
|
+
gemfile << %(, "#{req}") if req
|
129
|
+
gemfile << "\n"
|
130
|
+
end
|
131
|
+
gemfile << "end\n" if group
|
132
|
+
end
|
133
|
+
gemfile
|
134
|
+
end
|
135
|
+
end
|
136
|
+
|
137
|
+
class Dependency
|
138
|
+
attr_accessor :source, :groups, :all_sources
|
139
|
+
|
140
|
+
alias_method :eql?, :==
|
141
|
+
|
142
|
+
def encode_with(coder)
|
143
|
+
to_yaml_properties.each do |ivar|
|
144
|
+
coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
def to_yaml_properties
|
149
|
+
instance_variables.reject {|p| ["@source", "@groups", "@all_sources"].include?(p.to_s) }
|
150
|
+
end
|
151
|
+
|
152
|
+
def to_lock
|
153
|
+
out = String.new(" #{name}")
|
154
|
+
unless requirement.none?
|
155
|
+
reqs = requirement.requirements.map {|o, v| "#{o} #{v}" }.sort.reverse
|
156
|
+
out << " (#{reqs.join(", ")})"
|
157
|
+
end
|
158
|
+
out
|
159
|
+
end
|
160
|
+
|
161
|
+
# Backport of performance enhancement added to RubyGems 1.4
|
162
|
+
def matches_spec?(spec)
|
163
|
+
# name can be a Regexp, so use ===
|
164
|
+
return false unless name === spec.name
|
165
|
+
return true if requirement.none?
|
166
|
+
|
167
|
+
requirement.satisfied_by?(spec.version)
|
168
|
+
end unless allocate.respond_to?(:matches_spec?)
|
169
|
+
end
|
170
|
+
|
171
|
+
class Requirement
|
172
|
+
# Backport of performance enhancement added to RubyGems 1.4
|
173
|
+
def none?
|
174
|
+
# note that it might be tempting to replace with with RubyGems 2.0's
|
175
|
+
# improved implementation. Don't. It requires `DefaultRequirement` to be
|
176
|
+
# defined, and more importantantly, these overrides are not used when the
|
177
|
+
# running RubyGems defines these methods
|
178
|
+
to_s == ">= 0"
|
179
|
+
end unless allocate.respond_to?(:none?)
|
180
|
+
|
181
|
+
# Backport of performance enhancement added to RubyGems 2.2
|
182
|
+
def exact?
|
183
|
+
return false unless @requirements.size == 1
|
184
|
+
@requirements[0][0] == "="
|
185
|
+
end unless allocate.respond_to?(:exact?)
|
186
|
+
end
|
187
|
+
|
188
|
+
class Platform
|
189
|
+
JAVA = Gem::Platform.new("java") unless defined?(JAVA)
|
190
|
+
MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
|
191
|
+
MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
|
192
|
+
MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
|
193
|
+
X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
|
194
|
+
|
195
|
+
undef_method :hash if method_defined? :hash
|
196
|
+
def hash
|
197
|
+
@cpu.hash ^ @os.hash ^ @version.hash
|
198
|
+
end
|
199
|
+
|
200
|
+
undef_method :eql? if method_defined? :eql?
|
201
|
+
alias_method :eql?, :==
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
module Gem
|
206
|
+
class Specification
|
207
|
+
include ::Bundler::MatchPlatform
|
208
|
+
end
|
209
|
+
end
|