shopify-bundler 1.10.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +16 -0
- data/.rspec +3 -0
- data/.rubocop.yml +96 -0
- data/.rubocop_todo.yml +177 -0
- data/.travis.yml +104 -0
- data/CHANGELOG.md +2131 -0
- data/CODE_OF_CONDUCT.md +42 -0
- data/CONTRIBUTING.md +32 -0
- data/DEVELOPMENT.md +118 -0
- data/ISSUES.md +96 -0
- data/LICENSE.md +23 -0
- data/README.md +40 -0
- data/Rakefile +309 -0
- data/bin/rake +14 -0
- data/bin/rspec +10 -0
- data/bin/rubocop +11 -0
- data/bundler.gemspec +34 -0
- data/exe/bundle +21 -0
- data/exe/bundle_ruby +60 -0
- data/exe/bundler +21 -0
- data/lib/bundler.rb +499 -0
- data/lib/bundler/capistrano.rb +16 -0
- data/lib/bundler/cli.rb +435 -0
- data/lib/bundler/cli/binstubs.rb +37 -0
- data/lib/bundler/cli/cache.rb +34 -0
- data/lib/bundler/cli/check.rb +37 -0
- data/lib/bundler/cli/clean.rb +25 -0
- data/lib/bundler/cli/common.rb +56 -0
- data/lib/bundler/cli/config.rb +88 -0
- data/lib/bundler/cli/console.rb +37 -0
- data/lib/bundler/cli/exec.rb +51 -0
- data/lib/bundler/cli/gem.rb +208 -0
- data/lib/bundler/cli/init.rb +32 -0
- data/lib/bundler/cli/inject.rb +32 -0
- data/lib/bundler/cli/install.rb +188 -0
- data/lib/bundler/cli/lock.rb +35 -0
- data/lib/bundler/cli/open.rb +22 -0
- data/lib/bundler/cli/outdated.rb +86 -0
- data/lib/bundler/cli/package.rb +45 -0
- data/lib/bundler/cli/platform.rb +42 -0
- data/lib/bundler/cli/show.rb +74 -0
- data/lib/bundler/cli/update.rb +72 -0
- data/lib/bundler/cli/viz.rb +26 -0
- data/lib/bundler/constants.rb +5 -0
- data/lib/bundler/current_ruby.rb +218 -0
- data/lib/bundler/definition.rb +675 -0
- data/lib/bundler/dep_proxy.rb +45 -0
- data/lib/bundler/dependency.rb +119 -0
- data/lib/bundler/deployment.rb +62 -0
- data/lib/bundler/deprecate.rb +17 -0
- data/lib/bundler/dsl.rb +478 -0
- data/lib/bundler/endpoint_specification.rb +100 -0
- data/lib/bundler/env.rb +82 -0
- data/lib/bundler/environment.rb +41 -0
- data/lib/bundler/fetcher.rb +288 -0
- data/lib/bundler/fetcher/base.rb +26 -0
- data/lib/bundler/fetcher/dependency.rb +88 -0
- data/lib/bundler/fetcher/downloader.rb +60 -0
- data/lib/bundler/fetcher/index.rb +32 -0
- data/lib/bundler/friendly_errors.rb +92 -0
- data/lib/bundler/gem_helper.rb +191 -0
- data/lib/bundler/gem_helpers.rb +26 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_path_manipulation.rb +8 -0
- data/lib/bundler/gem_tasks.rb +5 -0
- data/lib/bundler/graph.rb +173 -0
- data/lib/bundler/index.rb +199 -0
- data/lib/bundler/injector.rb +62 -0
- data/lib/bundler/inline.rb +58 -0
- data/lib/bundler/installer.rb +242 -0
- data/lib/bundler/installer/parallel_installer.rb +122 -0
- data/lib/bundler/installer/standalone.rb +48 -0
- data/lib/bundler/lazy_specification.rb +82 -0
- data/lib/bundler/lockfile_parser.rb +199 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +26 -0
- data/lib/bundler/remote_specification.rb +82 -0
- data/lib/bundler/resolver.rb +350 -0
- data/lib/bundler/retry.rb +60 -0
- data/lib/bundler/ruby_dsl.rb +11 -0
- data/lib/bundler/ruby_version.rb +116 -0
- data/lib/bundler/rubygems_ext.rb +175 -0
- data/lib/bundler/rubygems_integration.rb +674 -0
- data/lib/bundler/runtime.rb +285 -0
- data/lib/bundler/settings.rb +263 -0
- data/lib/bundler/setup.rb +26 -0
- data/lib/bundler/shared_helpers.rb +176 -0
- data/lib/bundler/similarity_detector.rb +61 -0
- data/lib/bundler/source.rb +35 -0
- data/lib/bundler/source/git.rb +286 -0
- data/lib/bundler/source/git/git_proxy.rb +190 -0
- data/lib/bundler/source/path.rb +224 -0
- data/lib/bundler/source/path/installer.rb +43 -0
- data/lib/bundler/source/rubygems.rb +436 -0
- data/lib/bundler/source/rubygems/remote.rb +38 -0
- data/lib/bundler/source_list.rb +101 -0
- data/lib/bundler/spec_set.rb +156 -0
- data/lib/bundler/ssl_certs/.document +1 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot-2048.pem +25 -0
- data/lib/bundler/ssl_certs/AddTrustExternalCARoot.pem +32 -0
- data/lib/bundler/ssl_certs/Class3PublicPrimaryCertificationAuthority.pem +14 -0
- data/lib/bundler/ssl_certs/DigiCertHighAssuranceEVRootCA.pem +23 -0
- data/lib/bundler/ssl_certs/EntrustnetSecureServerCertificationAuthority.pem +28 -0
- data/lib/bundler/ssl_certs/GeoTrustGlobalCA.pem +20 -0
- data/lib/bundler/ssl_certs/certificate_manager.rb +64 -0
- data/lib/bundler/stub_specification.rb +23 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Executable.standalone +12 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/.travis.yml.tt +4 -0
- data/lib/bundler/templates/newgem/CODE_OF_CONDUCT.md.tt +22 -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 +41 -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 +16 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +12 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +43 -0
- data/lib/bundler/templates/newgem/rspec.tt +2 -0
- data/lib/bundler/templates/newgem/spec/newgem_spec.rb.tt +11 -0
- data/lib/bundler/templates/newgem/spec/spec_helper.rb.tt +2 -0
- data/lib/bundler/templates/newgem/test/newgem_test.rb.tt +11 -0
- data/lib/bundler/templates/newgem/test/test_helper.rb.tt +4 -0
- data/lib/bundler/ui.rb +7 -0
- data/lib/bundler/ui/rg_proxy.rb +17 -0
- data/lib/bundler/ui/shell.rb +108 -0
- data/lib/bundler/ui/silent.rb +44 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo.rb +5 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb +277 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/errors.rb +69 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/gem_metadata.rb +3 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/specification_provider.rb +99 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/modules/ui.rb +63 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolution.rb +434 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/resolver.rb +43 -0
- data/lib/bundler/vendor/molinillo/lib/molinillo/state.rb +51 -0
- data/lib/bundler/vendor/net/http/faster.rb +26 -0
- data/lib/bundler/vendor/net/http/persistent.rb +1230 -0
- data/lib/bundler/vendor/net/http/persistent/ssl_reuse.rb +128 -0
- data/lib/bundler/vendor/thor/lib/thor.rb +484 -0
- data/lib/bundler/vendor/thor/lib/thor/actions.rb +319 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_file.rb +103 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/create_link.rb +59 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/empty_directory.rb +135 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/file_manipulation.rb +316 -0
- data/lib/bundler/vendor/thor/lib/thor/actions/inject_into_file.rb +107 -0
- data/lib/bundler/vendor/thor/lib/thor/base.rb +656 -0
- data/lib/bundler/vendor/thor/lib/thor/command.rb +133 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/io_binary_read.rb +10 -0
- data/lib/bundler/vendor/thor/lib/thor/core_ext/ordered_hash.rb +98 -0
- data/lib/bundler/vendor/thor/lib/thor/error.rb +32 -0
- data/lib/bundler/vendor/thor/lib/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/lib/thor/invocation.rb +178 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/lib/thor/line_editor/basic.rb +35 -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 +73 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/option.rb +125 -0
- data/lib/bundler/vendor/thor/lib/thor/parser/options.rb +218 -0
- data/lib/bundler/vendor/thor/lib/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/lib/thor/runner.rb +322 -0
- data/lib/bundler/vendor/thor/lib/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/lib/thor/shell/basic.rb +421 -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 +267 -0
- data/lib/bundler/vendor/thor/lib/thor/version.rb +3 -0
- data/lib/bundler/vendored_molinillo.rb +2 -0
- data/lib/bundler/vendored_persistent.rb +11 -0
- data/lib/bundler/vendored_thor.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/lib/bundler/worker.rb +72 -0
- data/man/bundle-config.ronn +187 -0
- data/man/bundle-exec.ronn +136 -0
- data/man/bundle-gem.ronn +77 -0
- data/man/bundle-install.ronn +398 -0
- data/man/bundle-package.ronn +66 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-update.ronn +188 -0
- data/man/bundle.ronn +98 -0
- data/man/gemfile.5.ronn +495 -0
- data/man/index.txt +8 -0
- metadata +346 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
module Bundler
|
2
|
+
# General purpose class for retrying code that may fail
|
3
|
+
class Retry
|
4
|
+
attr_accessor :name, :total_runs, :current_run
|
5
|
+
|
6
|
+
class << self
|
7
|
+
def default_attempts
|
8
|
+
default_retries + 1
|
9
|
+
end
|
10
|
+
alias_method :attempts, :default_attempts
|
11
|
+
|
12
|
+
def default_retries
|
13
|
+
Bundler.settings[:retry]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(name, exceptions = nil, retries = self.class.default_retries)
|
18
|
+
@name = name
|
19
|
+
@retries = retries
|
20
|
+
@exceptions = Array(exceptions) || []
|
21
|
+
@total_runs = @retries + 1 # will run once, then upto attempts.times
|
22
|
+
end
|
23
|
+
|
24
|
+
def attempt(&block)
|
25
|
+
@current_run = 0
|
26
|
+
@failed = false
|
27
|
+
@error = nil
|
28
|
+
run(&block) while keep_trying?
|
29
|
+
@result
|
30
|
+
end
|
31
|
+
alias_method :attempts, :attempt
|
32
|
+
|
33
|
+
private
|
34
|
+
|
35
|
+
def run(&block)
|
36
|
+
@failed = false
|
37
|
+
@current_run += 1
|
38
|
+
@result = block.call
|
39
|
+
rescue => e
|
40
|
+
fail_attempt(e)
|
41
|
+
end
|
42
|
+
|
43
|
+
def fail_attempt(e)
|
44
|
+
@failed = true
|
45
|
+
raise e if last_attempt? || @exceptions.any? {|k| e.is_a?(k) }
|
46
|
+
return true unless name
|
47
|
+
Bundler.ui.warn "Retrying#{" #{name}" if name} due to error (#{current_run.next}/#{total_runs}): #{e.class} #{e.message}"
|
48
|
+
end
|
49
|
+
|
50
|
+
def keep_trying?
|
51
|
+
return true if current_run.zero?
|
52
|
+
return false if last_attempt?
|
53
|
+
return true if @failed
|
54
|
+
end
|
55
|
+
|
56
|
+
def last_attempt?
|
57
|
+
current_run >= total_runs
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Bundler
|
2
|
+
module RubyDsl
|
3
|
+
def ruby(ruby_version, options = {})
|
4
|
+
raise GemfileError, "Please define :engine_version" if options[:engine] && options[:engine_version].nil?
|
5
|
+
raise GemfileError, "Please define :engine" if options[:engine_version] && options[:engine].nil?
|
6
|
+
|
7
|
+
raise GemfileEvalError, "ruby_version must match the :engine_version for MRI" if options[:engine] == "ruby" && options[:engine_version] && ruby_version != options[:engine_version]
|
8
|
+
@ruby_version = RubyVersion.new(ruby_version, options[:patchlevel], options[:engine], options[:engine_version])
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
module Bundler
|
2
|
+
class RubyVersion
|
3
|
+
attr_reader :version, :patchlevel, :engine, :engine_version
|
4
|
+
|
5
|
+
def initialize(version, patchlevel, engine, engine_version)
|
6
|
+
# The parameters to this method must satisfy the
|
7
|
+
# following constraints, which are verified in
|
8
|
+
# the DSL:
|
9
|
+
#
|
10
|
+
# * If an engine is specified, an engine version
|
11
|
+
# must also be specified
|
12
|
+
# * If an engine version is specified, an engine
|
13
|
+
# must also be specified
|
14
|
+
# * If the engine is "ruby", the engine version
|
15
|
+
# must not be specified, or the engine version
|
16
|
+
# specified must match the version.
|
17
|
+
|
18
|
+
@version = version
|
19
|
+
@engine = engine || "ruby"
|
20
|
+
# keep track of the engine specified by the user
|
21
|
+
@input_engine = engine
|
22
|
+
@engine_version = engine_version || version
|
23
|
+
@patchlevel = patchlevel
|
24
|
+
end
|
25
|
+
|
26
|
+
def to_s
|
27
|
+
output = "ruby #{version}"
|
28
|
+
output << "p#{patchlevel}" if patchlevel
|
29
|
+
output << " (#{engine} #{engine_version})" unless engine == "ruby"
|
30
|
+
|
31
|
+
output
|
32
|
+
end
|
33
|
+
|
34
|
+
def ==(other)
|
35
|
+
version == other.version &&
|
36
|
+
engine == other.engine &&
|
37
|
+
engine_version == other.engine_version &&
|
38
|
+
patchlevel == other.patchlevel
|
39
|
+
end
|
40
|
+
|
41
|
+
# Returns a tuple of these things:
|
42
|
+
# [diff, this, other]
|
43
|
+
# The priority of attributes are
|
44
|
+
# 1. engine
|
45
|
+
# 2. ruby_version
|
46
|
+
# 3. engine_version
|
47
|
+
def diff(other)
|
48
|
+
if engine != other.engine && @input_engine
|
49
|
+
[:engine, engine, other.engine]
|
50
|
+
elsif version != other.version
|
51
|
+
[:version, version, other.version]
|
52
|
+
elsif engine_version != other.engine_version && @input_engine
|
53
|
+
[:engine_version, engine_version, other.engine_version]
|
54
|
+
elsif patchlevel != other.patchlevel && @patchlevel
|
55
|
+
[:patchlevel, patchlevel, other.patchlevel]
|
56
|
+
else
|
57
|
+
nil
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def host
|
62
|
+
@host ||= [
|
63
|
+
RbConfig::CONFIG["host_cpu"],
|
64
|
+
RbConfig::CONFIG["host_vendor"],
|
65
|
+
RbConfig::CONFIG["host_os"]
|
66
|
+
].join("-")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# A subclass of RubyVersion that implements version,
|
71
|
+
# engine and engine_version based upon the current
|
72
|
+
# information in the system. It can be used anywhere
|
73
|
+
# a RubyVersion object is expected, and can be
|
74
|
+
# compared with a RubyVersion object.
|
75
|
+
class SystemRubyVersion < RubyVersion
|
76
|
+
def initialize(*)
|
77
|
+
# override the default initialize, because
|
78
|
+
# we will implement version, engine and
|
79
|
+
# engine_version dynamically
|
80
|
+
end
|
81
|
+
|
82
|
+
def version
|
83
|
+
RUBY_VERSION.dup
|
84
|
+
end
|
85
|
+
|
86
|
+
def gem_version
|
87
|
+
@gem_version ||= Gem::Version.new(version)
|
88
|
+
end
|
89
|
+
|
90
|
+
def engine
|
91
|
+
if defined?(RUBY_ENGINE)
|
92
|
+
RUBY_ENGINE.dup
|
93
|
+
else
|
94
|
+
# not defined in ruby 1.8.7
|
95
|
+
"ruby"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def engine_version
|
100
|
+
case engine
|
101
|
+
when "ruby"
|
102
|
+
RUBY_VERSION.dup
|
103
|
+
when "rbx"
|
104
|
+
Rubinius::VERSION.dup
|
105
|
+
when "jruby"
|
106
|
+
JRUBY_VERSION.dup
|
107
|
+
else
|
108
|
+
raise BundlerError, "RUBY_ENGINE value #{RUBY_ENGINE} is not recognized"
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
def patchlevel
|
113
|
+
RUBY_PATCHLEVEL.to_s
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,175 @@
|
|
1
|
+
require "pathname"
|
2
|
+
|
3
|
+
if defined?(Gem::QuickLoader)
|
4
|
+
# Gem Prelude makes me a sad panda :'(
|
5
|
+
Gem::QuickLoader.load_full_rubygems_library
|
6
|
+
end
|
7
|
+
|
8
|
+
require "rubygems"
|
9
|
+
require "rubygems/specification"
|
10
|
+
require "bundler/match_platform"
|
11
|
+
|
12
|
+
module Gem
|
13
|
+
@loaded_stacks = Hash.new {|h, k| h[k] = [] }
|
14
|
+
|
15
|
+
class Specification
|
16
|
+
attr_accessor :remote, :location, :relative_loaded_from
|
17
|
+
|
18
|
+
remove_method :source if instance_methods(false).include?(:source)
|
19
|
+
attr_accessor :source
|
20
|
+
|
21
|
+
alias_method :rg_full_gem_path, :full_gem_path
|
22
|
+
alias_method :rg_loaded_from, :loaded_from
|
23
|
+
|
24
|
+
def full_gem_path
|
25
|
+
if source.respond_to?(:path)
|
26
|
+
Pathname.new(loaded_from).dirname.expand_path(Bundler.root).to_s.untaint
|
27
|
+
else
|
28
|
+
rg_full_gem_path
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def loaded_from
|
33
|
+
if relative_loaded_from
|
34
|
+
source.path.join(relative_loaded_from).to_s
|
35
|
+
else
|
36
|
+
rg_loaded_from
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def load_paths
|
41
|
+
return full_require_paths if respond_to?(:full_require_paths)
|
42
|
+
|
43
|
+
require_paths.map do |require_path|
|
44
|
+
if require_path.include?(full_gem_path)
|
45
|
+
require_path
|
46
|
+
else
|
47
|
+
File.join(full_gem_path, require_path)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
if method_defined?(:extension_dir)
|
53
|
+
alias_method :rg_extension_dir, :extension_dir
|
54
|
+
def extension_dir
|
55
|
+
@extension_dir ||= if source.respond_to?(:extension_dir_name)
|
56
|
+
File.expand_path(File.join(extensions_dir, source.extension_dir_name))
|
57
|
+
else
|
58
|
+
rg_extension_dir
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
# RubyGems 1.8+ used only.
|
64
|
+
methods = instance_methods(false)
|
65
|
+
gem_dir = methods.first.is_a?(String) ? "gem_dir" : :gem_dir
|
66
|
+
remove_method :gem_dir if methods.include?(gem_dir)
|
67
|
+
def gem_dir
|
68
|
+
full_gem_path
|
69
|
+
end
|
70
|
+
|
71
|
+
def groups
|
72
|
+
@groups ||= []
|
73
|
+
end
|
74
|
+
|
75
|
+
def git_version
|
76
|
+
return unless loaded_from && source.is_a?(Bundler::Source::Git)
|
77
|
+
" #{source.revision[0..6]}"
|
78
|
+
end
|
79
|
+
|
80
|
+
def to_gemfile(path = nil)
|
81
|
+
gemfile = "source 'https://rubygems.org'\n"
|
82
|
+
gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
|
83
|
+
unless development_dependencies.empty?
|
84
|
+
gemfile << "\n"
|
85
|
+
gemfile << dependencies_to_gemfile(development_dependencies, :development)
|
86
|
+
end
|
87
|
+
gemfile
|
88
|
+
end
|
89
|
+
|
90
|
+
def nondevelopment_dependencies
|
91
|
+
dependencies - development_dependencies
|
92
|
+
end
|
93
|
+
|
94
|
+
private
|
95
|
+
|
96
|
+
def dependencies_to_gemfile(dependencies, group = nil)
|
97
|
+
gemfile = ""
|
98
|
+
if dependencies.any?
|
99
|
+
gemfile << "group :#{group} do\n" if group
|
100
|
+
dependencies.each do |dependency|
|
101
|
+
gemfile << " " if group
|
102
|
+
gemfile << %|gem "#{dependency.name}"|
|
103
|
+
req = dependency.requirements_list.first
|
104
|
+
gemfile << %|, "#{req}"| if req
|
105
|
+
gemfile << "\n"
|
106
|
+
end
|
107
|
+
gemfile << "end\n" if group
|
108
|
+
end
|
109
|
+
gemfile
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
class Dependency
|
114
|
+
attr_accessor :source, :groups
|
115
|
+
|
116
|
+
alias_method :eql?, :==
|
117
|
+
|
118
|
+
def encode_with(coder)
|
119
|
+
to_yaml_properties.each do |ivar|
|
120
|
+
coder[ivar.to_s.sub(/^@/, "")] = instance_variable_get(ivar)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def to_yaml_properties
|
125
|
+
instance_variables.reject {|p| ["@source", "@groups"].include?(p.to_s) }
|
126
|
+
end
|
127
|
+
|
128
|
+
def to_lock
|
129
|
+
out = " #{name}"
|
130
|
+
unless requirement == Gem::Requirement.default
|
131
|
+
reqs = requirement.requirements.map {|o, v| "#{o} #{v}" }.sort.reverse
|
132
|
+
out << " (#{reqs.join(", ")})"
|
133
|
+
end
|
134
|
+
out
|
135
|
+
end
|
136
|
+
|
137
|
+
# Backport of performance enhancement added to Rubygems 1.4
|
138
|
+
def matches_spec?(spec)
|
139
|
+
# name can be a Regexp, so use ===
|
140
|
+
return false unless name === spec.name
|
141
|
+
return true if requirement.none?
|
142
|
+
|
143
|
+
requirement.satisfied_by?(spec.version)
|
144
|
+
end unless allocate.respond_to?(:matches_spec?)
|
145
|
+
end
|
146
|
+
|
147
|
+
class Requirement
|
148
|
+
# Backport of performance enhancement added to Rubygems 1.4
|
149
|
+
def none?
|
150
|
+
@none ||= (to_s == ">= 0")
|
151
|
+
end unless allocate.respond_to?(:none?)
|
152
|
+
end
|
153
|
+
|
154
|
+
class Platform
|
155
|
+
JAVA = Gem::Platform.new("java") unless defined?(JAVA)
|
156
|
+
MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
|
157
|
+
MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
|
158
|
+
MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
|
159
|
+
X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
|
160
|
+
|
161
|
+
undef_method :hash if method_defined? :hash
|
162
|
+
def hash
|
163
|
+
@cpu.hash ^ @os.hash ^ @version.hash
|
164
|
+
end
|
165
|
+
|
166
|
+
undef_method :eql? if method_defined? :eql?
|
167
|
+
alias_method :eql?, :==
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
module Gem
|
172
|
+
class Specification
|
173
|
+
include ::Bundler::MatchPlatform
|
174
|
+
end
|
175
|
+
end
|
@@ -0,0 +1,674 @@
|
|
1
|
+
require "monitor"
|
2
|
+
require "rubygems"
|
3
|
+
require "rubygems/config_file"
|
4
|
+
|
5
|
+
module Bundler
|
6
|
+
class RubygemsIntegration
|
7
|
+
if defined?(Gem::Ext::Builder::CHDIR_MONITOR)
|
8
|
+
EXT_LOCK = Gem::Ext::Builder::CHDIR_MONITOR
|
9
|
+
else
|
10
|
+
EXT_LOCK = Monitor.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.version
|
14
|
+
@version ||= Gem::Version.new(Gem::VERSION)
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.provides?(req_str)
|
18
|
+
Gem::Requirement.new(req_str).satisfied_by?(version)
|
19
|
+
end
|
20
|
+
|
21
|
+
def version
|
22
|
+
self.class.version
|
23
|
+
end
|
24
|
+
|
25
|
+
def provides?(req_str)
|
26
|
+
self.class.provides?(req_str)
|
27
|
+
end
|
28
|
+
|
29
|
+
def build_args
|
30
|
+
Gem::Command.build_args
|
31
|
+
end
|
32
|
+
|
33
|
+
def build_args=(args)
|
34
|
+
Gem::Command.build_args = args
|
35
|
+
end
|
36
|
+
|
37
|
+
def loaded_specs(name)
|
38
|
+
Gem.loaded_specs[name]
|
39
|
+
end
|
40
|
+
|
41
|
+
def mark_loaded(spec)
|
42
|
+
if spec.respond_to?(:activated=)
|
43
|
+
current = Gem.loaded_specs[spec.name]
|
44
|
+
current.activated = false if current
|
45
|
+
spec.activated = true
|
46
|
+
end
|
47
|
+
Gem.loaded_specs[spec.name] = spec
|
48
|
+
end
|
49
|
+
|
50
|
+
def validate(spec)
|
51
|
+
Bundler.ui.silence { spec.validate(false) }
|
52
|
+
rescue Errno::ENOENT
|
53
|
+
nil
|
54
|
+
end
|
55
|
+
|
56
|
+
def path(obj)
|
57
|
+
obj.to_s
|
58
|
+
end
|
59
|
+
|
60
|
+
def platforms
|
61
|
+
Gem.platforms
|
62
|
+
end
|
63
|
+
|
64
|
+
def configuration
|
65
|
+
Gem.configuration
|
66
|
+
rescue Gem::SystemExitException => e
|
67
|
+
Bundler.ui.error "#{e.class}: #{e.message}"
|
68
|
+
Bundler.ui.trace e
|
69
|
+
raise Gem::SystemExitException
|
70
|
+
end
|
71
|
+
|
72
|
+
def ruby_engine
|
73
|
+
Gem.ruby_engine
|
74
|
+
end
|
75
|
+
|
76
|
+
def read_binary(path)
|
77
|
+
Gem.read_binary(path)
|
78
|
+
end
|
79
|
+
|
80
|
+
def inflate(obj)
|
81
|
+
Gem.inflate(obj)
|
82
|
+
end
|
83
|
+
|
84
|
+
def sources=(val)
|
85
|
+
# Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
|
86
|
+
# If that file exists, its settings (including sources) will overwrite the values we
|
87
|
+
# are about to set here. In order to avoid that, we force memoizing the config file now.
|
88
|
+
configuration
|
89
|
+
|
90
|
+
Gem.sources = val
|
91
|
+
end
|
92
|
+
|
93
|
+
def sources
|
94
|
+
Gem.sources
|
95
|
+
end
|
96
|
+
|
97
|
+
def gem_dir
|
98
|
+
Gem.dir
|
99
|
+
end
|
100
|
+
|
101
|
+
def gem_bindir
|
102
|
+
Gem.bindir
|
103
|
+
end
|
104
|
+
|
105
|
+
def user_home
|
106
|
+
Gem.user_home
|
107
|
+
end
|
108
|
+
|
109
|
+
def gem_path
|
110
|
+
Gem.path
|
111
|
+
end
|
112
|
+
|
113
|
+
def gem_cache
|
114
|
+
gem_path.map {|p| File.expand_path("cache", p) }
|
115
|
+
end
|
116
|
+
|
117
|
+
def spec_cache_dirs
|
118
|
+
@spec_cache_dirs ||= begin
|
119
|
+
dirs = gem_path.map {|dir| File.join(dir, "specifications") }
|
120
|
+
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in Rubygems 2.0.3 or earlier
|
121
|
+
dirs.uniq.select {|dir| File.directory? dir }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
def marshal_spec_dir
|
126
|
+
Gem::MARSHAL_SPEC_DIR
|
127
|
+
end
|
128
|
+
|
129
|
+
def config_map
|
130
|
+
Gem::ConfigMap
|
131
|
+
end
|
132
|
+
|
133
|
+
def repository_subdirectories
|
134
|
+
%w[cache doc gems specifications]
|
135
|
+
end
|
136
|
+
|
137
|
+
def clear_paths
|
138
|
+
Gem.clear_paths
|
139
|
+
end
|
140
|
+
|
141
|
+
def bin_path(gem, bin, ver)
|
142
|
+
Gem.bin_path(gem, bin, ver)
|
143
|
+
end
|
144
|
+
|
145
|
+
def preserve_paths
|
146
|
+
# this is a no-op outside of Rubygems 1.8
|
147
|
+
yield
|
148
|
+
end
|
149
|
+
|
150
|
+
def loaded_gem_paths
|
151
|
+
# RubyGems 2.2+ can put binary extension into dedicated folders,
|
152
|
+
# therefore use RubyGems facilities to obtain their load paths.
|
153
|
+
if Gem::Specification.method_defined? :full_require_paths
|
154
|
+
loaded_gem_paths = Gem.loaded_specs.map {|_, s| s.full_require_paths }
|
155
|
+
loaded_gem_paths.flatten
|
156
|
+
else
|
157
|
+
$LOAD_PATH.select do |p|
|
158
|
+
Bundler.rubygems.gem_path.any? {|gp| p =~ /^#{Regexp.escape(gp)}/ }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
|
163
|
+
def ui=(obj)
|
164
|
+
Gem::DefaultUserInteraction.ui = obj
|
165
|
+
end
|
166
|
+
|
167
|
+
def ext_lock
|
168
|
+
EXT_LOCK
|
169
|
+
end
|
170
|
+
|
171
|
+
def fetch_specs(all, pre, &blk)
|
172
|
+
specs = Gem::SpecFetcher.new.list(all, pre)
|
173
|
+
specs.each { yield } if block_given?
|
174
|
+
specs
|
175
|
+
end
|
176
|
+
|
177
|
+
def fetch_prerelease_specs
|
178
|
+
fetch_specs(false, true)
|
179
|
+
rescue Gem::RemoteFetcher::FetchError
|
180
|
+
[] # if we can't download them, there aren't any
|
181
|
+
end
|
182
|
+
|
183
|
+
def fetch_all_remote_specs
|
184
|
+
# Fetch all specs, minus prerelease specs
|
185
|
+
spec_list = fetch_specs(true, false)
|
186
|
+
# Then fetch the prerelease specs
|
187
|
+
fetch_prerelease_specs.each {|k, v| spec_list[k] += v }
|
188
|
+
|
189
|
+
spec_list
|
190
|
+
end
|
191
|
+
|
192
|
+
def with_build_args(args)
|
193
|
+
ext_lock.synchronize do
|
194
|
+
old_args = self.build_args
|
195
|
+
begin
|
196
|
+
self.build_args = args
|
197
|
+
yield
|
198
|
+
ensure
|
199
|
+
self.build_args = old_args
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|
203
|
+
|
204
|
+
def gem_from_path(path, policy = nil)
|
205
|
+
require "rubygems/format"
|
206
|
+
Gem::Format.from_file_by_path(path, policy)
|
207
|
+
end
|
208
|
+
|
209
|
+
def spec_from_gem(path, policy = nil)
|
210
|
+
require "rubygems/security"
|
211
|
+
gem_from_path(path, security_policies[policy]).spec
|
212
|
+
rescue Gem::Package::FormatError
|
213
|
+
raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
|
214
|
+
rescue Exception, Gem::Exception, Gem::Security::Exception => e
|
215
|
+
if e.is_a?(Gem::Security::Exception) ||
|
216
|
+
e.message =~ /unknown trust policy|unsigned gem/i ||
|
217
|
+
e.message =~ /couldn't verify (meta)?data signature/i
|
218
|
+
raise SecurityError,
|
219
|
+
"The gem #{File.basename(path, ".gem")} can't be installed because " \
|
220
|
+
"the security policy didn't allow it, with the message: #{e.message}"
|
221
|
+
else
|
222
|
+
raise e
|
223
|
+
end
|
224
|
+
end
|
225
|
+
|
226
|
+
def build(spec, skip_validation = false)
|
227
|
+
require "rubygems/builder"
|
228
|
+
Gem::Builder.new(spec).build
|
229
|
+
end
|
230
|
+
|
231
|
+
def build_gem(gem_dir, spec)
|
232
|
+
build(spec)
|
233
|
+
end
|
234
|
+
|
235
|
+
def download_gem(spec, uri, path)
|
236
|
+
uri = Bundler.settings.mirror_for(uri)
|
237
|
+
fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
|
238
|
+
fetcher.download(spec, uri, path)
|
239
|
+
end
|
240
|
+
|
241
|
+
def security_policy_keys
|
242
|
+
%w{High Medium Low AlmostNo No}.map {|level| "#{level}Security" }
|
243
|
+
end
|
244
|
+
|
245
|
+
def security_policies
|
246
|
+
@security_policies ||= begin
|
247
|
+
require "rubygems/security"
|
248
|
+
Gem::Security::Policies
|
249
|
+
rescue LoadError, NameError
|
250
|
+
{}
|
251
|
+
end
|
252
|
+
end
|
253
|
+
|
254
|
+
def reverse_rubygems_kernel_mixin
|
255
|
+
# Disable rubygems' gem activation system
|
256
|
+
::Kernel.class_eval do
|
257
|
+
if private_method_defined?(:gem_original_require)
|
258
|
+
alias_method :rubygems_require, :require
|
259
|
+
alias_method :require, :gem_original_require
|
260
|
+
end
|
261
|
+
|
262
|
+
undef gem
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
266
|
+
def replace_gem(specs)
|
267
|
+
reverse_rubygems_kernel_mixin
|
268
|
+
|
269
|
+
executables = specs.map(&:executables).flatten
|
270
|
+
|
271
|
+
::Kernel.send(:define_method, :gem) do |dep, *reqs|
|
272
|
+
if executables.include? File.basename(caller.first.split(":").first)
|
273
|
+
return
|
274
|
+
end
|
275
|
+
reqs.pop if reqs.last.is_a?(Hash)
|
276
|
+
|
277
|
+
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
278
|
+
dep = Gem::Dependency.new(dep, reqs)
|
279
|
+
end
|
280
|
+
|
281
|
+
spec = specs.find {|s| s.name == dep.name }
|
282
|
+
|
283
|
+
if spec.nil?
|
284
|
+
|
285
|
+
e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
|
286
|
+
e.name = dep.name
|
287
|
+
if e.respond_to?(:requirement=)
|
288
|
+
e.requirement = dep.requirement
|
289
|
+
else
|
290
|
+
e.version_requirement = dep.requirement
|
291
|
+
end
|
292
|
+
raise e
|
293
|
+
elsif dep !~ spec
|
294
|
+
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
|
295
|
+
"Make sure all dependencies are added to Gemfile."
|
296
|
+
e.name = dep.name
|
297
|
+
if e.respond_to?(:requirement=)
|
298
|
+
e.requirement = dep.requirement
|
299
|
+
else
|
300
|
+
e.version_requirement = dep.requirement
|
301
|
+
end
|
302
|
+
raise e
|
303
|
+
end
|
304
|
+
|
305
|
+
true
|
306
|
+
end
|
307
|
+
end
|
308
|
+
|
309
|
+
def stub_source_index(specs)
|
310
|
+
Gem::SourceIndex.send(:alias_method, :old_initialize, :initialize)
|
311
|
+
redefine_method(Gem::SourceIndex, :initialize) do |*args|
|
312
|
+
@gems = {}
|
313
|
+
# You're looking at this thinking: Oh! This is how I make those
|
314
|
+
# rubygems deprecations go away!
|
315
|
+
#
|
316
|
+
# You'd be correct BUT using of this method in production code
|
317
|
+
# must be approved by the rubygems team itself!
|
318
|
+
#
|
319
|
+
# This is your warning. If you use this and don't have approval
|
320
|
+
# we can't protect you.
|
321
|
+
#
|
322
|
+
Deprecate.skip_during do
|
323
|
+
self.spec_dirs = *args
|
324
|
+
add_specs(*specs)
|
325
|
+
end
|
326
|
+
end
|
327
|
+
end
|
328
|
+
|
329
|
+
# Used to make bin stubs that are not created by bundler work
|
330
|
+
# under bundler. The new Gem.bin_path only considers gems in
|
331
|
+
# +specs+
|
332
|
+
def replace_bin_path(specs)
|
333
|
+
gem_class = (class << Gem; self; end)
|
334
|
+
redefine_method(gem_class, :bin_path) do |name, *args|
|
335
|
+
exec_name = args.first
|
336
|
+
|
337
|
+
if exec_name == "bundle"
|
338
|
+
return ENV["BUNDLE_BIN_PATH"]
|
339
|
+
end
|
340
|
+
|
341
|
+
spec = nil
|
342
|
+
|
343
|
+
if exec_name
|
344
|
+
spec = specs.find {|s| s.executables.include?(exec_name) }
|
345
|
+
spec or raise Gem::Exception, "can't find executable #{exec_name}"
|
346
|
+
unless spec.name == name
|
347
|
+
warn "Bundler is using a binstub that was created for a different gem.\n" \
|
348
|
+
"This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
|
349
|
+
"to work around a system/bundle conflict."
|
350
|
+
end
|
351
|
+
else
|
352
|
+
spec = specs.find {|s| s.name == name }
|
353
|
+
exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
|
354
|
+
end
|
355
|
+
|
356
|
+
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
357
|
+
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
358
|
+
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
359
|
+
end
|
360
|
+
end
|
361
|
+
|
362
|
+
# Because Bundler has a static view of what specs are available,
|
363
|
+
# we don't #refresh, so stub it out.
|
364
|
+
def replace_refresh
|
365
|
+
gem_class = (class << Gem; self; end)
|
366
|
+
redefine_method(gem_class, :refresh) {}
|
367
|
+
end
|
368
|
+
|
369
|
+
# Replace or hook into Rubygems to provide a bundlerized view
|
370
|
+
# of the world.
|
371
|
+
def replace_entrypoints(specs)
|
372
|
+
replace_gem(specs)
|
373
|
+
|
374
|
+
stub_rubygems(specs)
|
375
|
+
|
376
|
+
replace_bin_path(specs)
|
377
|
+
replace_refresh
|
378
|
+
|
379
|
+
Gem.clear_paths
|
380
|
+
end
|
381
|
+
|
382
|
+
# This backports the correct segment generation code from Rubygems 1.4+
|
383
|
+
# by monkeypatching it into the method in Rubygems 1.3.6 and 1.3.7.
|
384
|
+
def backport_segment_generation
|
385
|
+
redefine_method(Gem::Version, :segments) do
|
386
|
+
@segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
|
387
|
+
/^\d+$/ =~ s ? s.to_i : s
|
388
|
+
end
|
389
|
+
end
|
390
|
+
end
|
391
|
+
|
392
|
+
# This backport fixes the marshaling of @segments.
|
393
|
+
def backport_yaml_initialize
|
394
|
+
redefine_method(Gem::Version, :yaml_initialize) do |_, map|
|
395
|
+
@version = map["version"]
|
396
|
+
@segments = nil
|
397
|
+
@hash = nil
|
398
|
+
end
|
399
|
+
end
|
400
|
+
|
401
|
+
# This backports base_dir which replaces installation path
|
402
|
+
# Rubygems 1.8+
|
403
|
+
def backport_base_dir
|
404
|
+
redefine_method(Gem::Specification, :base_dir) do
|
405
|
+
return Gem.dir unless loaded_from
|
406
|
+
File.dirname File.dirname loaded_from
|
407
|
+
end
|
408
|
+
end
|
409
|
+
|
410
|
+
def backport_cache_file
|
411
|
+
redefine_method(Gem::Specification, :cache_dir) do
|
412
|
+
@cache_dir ||= File.join base_dir, "cache"
|
413
|
+
end
|
414
|
+
|
415
|
+
redefine_method(Gem::Specification, :cache_file) do
|
416
|
+
@cache_file ||= File.join cache_dir, "#{full_name}.gem"
|
417
|
+
end
|
418
|
+
end
|
419
|
+
|
420
|
+
def backport_spec_file
|
421
|
+
redefine_method(Gem::Specification, :spec_dir) do
|
422
|
+
@spec_dir ||= File.join base_dir, "specifications"
|
423
|
+
end
|
424
|
+
|
425
|
+
redefine_method(Gem::Specification, :spec_file) do
|
426
|
+
@spec_file ||= File.join spec_dir, "#{full_name}.gemspec"
|
427
|
+
end
|
428
|
+
end
|
429
|
+
|
430
|
+
def redefine_method(klass, method, &block)
|
431
|
+
if klass.instance_methods(false).include?(method)
|
432
|
+
klass.send(:remove_method, method)
|
433
|
+
end
|
434
|
+
klass.send(:define_method, method, &block)
|
435
|
+
end
|
436
|
+
|
437
|
+
# Rubygems 1.4 through 1.6
|
438
|
+
class Legacy < RubygemsIntegration
|
439
|
+
def initialize
|
440
|
+
super
|
441
|
+
backport_base_dir
|
442
|
+
backport_cache_file
|
443
|
+
backport_spec_file
|
444
|
+
backport_yaml_initialize
|
445
|
+
end
|
446
|
+
|
447
|
+
def stub_rubygems(specs)
|
448
|
+
# Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
|
449
|
+
source_index_class = (class << Gem::SourceIndex; self; end)
|
450
|
+
source_index_class.send(:define_method, :from_gems_in) do |*args|
|
451
|
+
source_index = Gem::SourceIndex.new
|
452
|
+
source_index.spec_dirs = *args
|
453
|
+
source_index.add_specs(*specs)
|
454
|
+
source_index
|
455
|
+
end
|
456
|
+
end
|
457
|
+
|
458
|
+
def all_specs
|
459
|
+
Gem.source_index.gems.values
|
460
|
+
end
|
461
|
+
|
462
|
+
def find_name(name)
|
463
|
+
Gem.source_index.find_name(name)
|
464
|
+
end
|
465
|
+
|
466
|
+
def validate(spec)
|
467
|
+
# These versions of RubyGems always validate in "packaging" mode,
|
468
|
+
# which is too strict for the kinds of checks we care about. As a
|
469
|
+
# result, validation is disabled on versions of RubyGems below 1.7.
|
470
|
+
end
|
471
|
+
end
|
472
|
+
|
473
|
+
# Rubygems versions 1.3.6 and 1.3.7
|
474
|
+
class Ancient < Legacy
|
475
|
+
def initialize
|
476
|
+
super
|
477
|
+
backport_segment_generation
|
478
|
+
end
|
479
|
+
end
|
480
|
+
|
481
|
+
# Rubygems 1.7
|
482
|
+
class Transitional < Legacy
|
483
|
+
def stub_rubygems(specs)
|
484
|
+
stub_source_index(specs)
|
485
|
+
end
|
486
|
+
|
487
|
+
def validate(spec)
|
488
|
+
# Missing summary is downgraded to a warning in later versions,
|
489
|
+
# so we set it to an empty string to prevent an exception here.
|
490
|
+
spec.summary ||= ""
|
491
|
+
Bundler.ui.silence { spec.validate(false) }
|
492
|
+
rescue Errno::ENOENT
|
493
|
+
nil
|
494
|
+
end
|
495
|
+
end
|
496
|
+
|
497
|
+
# Rubygems 1.8.5-1.8.19
|
498
|
+
class Modern < RubygemsIntegration
|
499
|
+
def stub_rubygems(specs)
|
500
|
+
Gem::Specification.all = specs
|
501
|
+
|
502
|
+
Gem.post_reset {
|
503
|
+
Gem::Specification.all = specs
|
504
|
+
}
|
505
|
+
|
506
|
+
stub_source_index(specs)
|
507
|
+
end
|
508
|
+
|
509
|
+
def all_specs
|
510
|
+
Gem::Specification.to_a
|
511
|
+
end
|
512
|
+
|
513
|
+
def find_name(name)
|
514
|
+
Gem::Specification.find_all_by_name name
|
515
|
+
end
|
516
|
+
end
|
517
|
+
|
518
|
+
# Rubygems 1.8.0 to 1.8.4
|
519
|
+
class AlmostModern < Modern
|
520
|
+
# Rubygems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
|
521
|
+
# you call Gem::Installer#install with an :install_dir set. We have to
|
522
|
+
# change it back for our sudo mode to work.
|
523
|
+
def preserve_paths
|
524
|
+
old_dir = gem_dir
|
525
|
+
old_path = gem_path
|
526
|
+
yield
|
527
|
+
Gem.use_paths(old_dir, old_path)
|
528
|
+
end
|
529
|
+
end
|
530
|
+
|
531
|
+
# Rubygems 1.8.20+
|
532
|
+
class MoreModern < Modern
|
533
|
+
# Rubygems 1.8.20 and adds the skip_validation parameter, so that's
|
534
|
+
# when we start passing it through.
|
535
|
+
def build(spec, skip_validation = false)
|
536
|
+
require "rubygems/builder"
|
537
|
+
Gem::Builder.new(spec).build(skip_validation)
|
538
|
+
end
|
539
|
+
end
|
540
|
+
|
541
|
+
# Rubygems 2.0
|
542
|
+
class Future < RubygemsIntegration
|
543
|
+
def stub_rubygems(specs)
|
544
|
+
Gem::Specification.all = specs
|
545
|
+
|
546
|
+
Gem.post_reset do
|
547
|
+
Gem::Specification.all = specs
|
548
|
+
end
|
549
|
+
end
|
550
|
+
|
551
|
+
def all_specs
|
552
|
+
Gem::Specification.to_a
|
553
|
+
end
|
554
|
+
|
555
|
+
def find_name(name)
|
556
|
+
Gem::Specification.find_all_by_name name
|
557
|
+
end
|
558
|
+
|
559
|
+
def fetch_specs(source, name)
|
560
|
+
path = source + "#{name}.#{Gem.marshal_version}.gz"
|
561
|
+
string = Gem::RemoteFetcher.fetcher.fetch_path(path)
|
562
|
+
Bundler.load_marshal(string)
|
563
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
564
|
+
# it's okay for prerelease to fail
|
565
|
+
raise e unless name == "prerelease_specs"
|
566
|
+
end
|
567
|
+
|
568
|
+
def fetch_all_remote_specs
|
569
|
+
# Since SpecFetcher now returns NameTuples, we just fetch directly
|
570
|
+
# and unmarshal the array ourselves.
|
571
|
+
hash = {}
|
572
|
+
|
573
|
+
Gem.sources.each do |source|
|
574
|
+
source = URI.parse(source.to_s) unless source.is_a?(URI)
|
575
|
+
hash[source] = fetch_specs(source, "specs")
|
576
|
+
|
577
|
+
pres = fetch_specs(source, "prerelease_specs")
|
578
|
+
hash[source].push(*pres) if pres && !pres.empty?
|
579
|
+
end
|
580
|
+
|
581
|
+
hash
|
582
|
+
end
|
583
|
+
|
584
|
+
def download_gem(spec, uri, path)
|
585
|
+
require "resolv"
|
586
|
+
uri = Bundler.settings.mirror_for(uri)
|
587
|
+
proxy = configuration[:http_proxy]
|
588
|
+
dns = Resolv::DNS.new
|
589
|
+
fetcher = Gem::RemoteFetcher.new(proxy, dns)
|
590
|
+
fetcher.download(spec, uri, path)
|
591
|
+
end
|
592
|
+
|
593
|
+
def gem_from_path(path, policy = nil)
|
594
|
+
require "rubygems/package"
|
595
|
+
p = Gem::Package.new(path)
|
596
|
+
p.security_policy = policy if policy
|
597
|
+
p
|
598
|
+
end
|
599
|
+
|
600
|
+
def build(spec, skip_validation = false)
|
601
|
+
require "rubygems/package"
|
602
|
+
Gem::Package.build(spec, skip_validation)
|
603
|
+
end
|
604
|
+
|
605
|
+
def repository_subdirectories
|
606
|
+
Gem::REPOSITORY_SUBDIRECTORIES
|
607
|
+
end
|
608
|
+
end
|
609
|
+
|
610
|
+
# RubyGems 2.1.0
|
611
|
+
class MoreFuture < Future
|
612
|
+
def initialize
|
613
|
+
super
|
614
|
+
backport_ext_builder_monitor
|
615
|
+
end
|
616
|
+
|
617
|
+
def all_specs
|
618
|
+
require "bundler/remote_specification"
|
619
|
+
Gem::Specification.stubs.map do |stub|
|
620
|
+
StubSpecification.from_stub(stub)
|
621
|
+
end
|
622
|
+
end
|
623
|
+
|
624
|
+
def backport_ext_builder_monitor
|
625
|
+
require "rubygems/ext"
|
626
|
+
|
627
|
+
Gem::Ext::Builder.class_eval do
|
628
|
+
unless const_defined?(:CHDIR_MONITOR)
|
629
|
+
const_set(:CHDIR_MONITOR, EXT_LOCK)
|
630
|
+
end
|
631
|
+
|
632
|
+
if const_defined?(:CHDIR_MUTEX)
|
633
|
+
remove_const(:CHDIR_MUTEX)
|
634
|
+
end
|
635
|
+
const_set(:CHDIR_MUTEX, const_get(:CHDIR_MONITOR))
|
636
|
+
end
|
637
|
+
end
|
638
|
+
|
639
|
+
if Gem::Specification.respond_to?(:stubs_for)
|
640
|
+
def find_name(name)
|
641
|
+
Gem::Specification.stubs_for(name).map(&:to_spec)
|
642
|
+
end
|
643
|
+
else
|
644
|
+
def find_name(name)
|
645
|
+
Gem::Specification.stubs.find_all do |spec|
|
646
|
+
spec.name == name
|
647
|
+
end.map(&:to_spec)
|
648
|
+
end
|
649
|
+
end
|
650
|
+
end
|
651
|
+
end
|
652
|
+
|
653
|
+
if RubygemsIntegration.provides?(">= 2.1.0")
|
654
|
+
@rubygems = RubygemsIntegration::MoreFuture.new
|
655
|
+
elsif RubygemsIntegration.provides?(">= 1.99.99")
|
656
|
+
@rubygems = RubygemsIntegration::Future.new
|
657
|
+
elsif RubygemsIntegration.provides?(">= 1.8.20")
|
658
|
+
@rubygems = RubygemsIntegration::MoreModern.new
|
659
|
+
elsif RubygemsIntegration.provides?(">= 1.8.5")
|
660
|
+
@rubygems = RubygemsIntegration::Modern.new
|
661
|
+
elsif RubygemsIntegration.provides?(">= 1.8.0")
|
662
|
+
@rubygems = RubygemsIntegration::AlmostModern.new
|
663
|
+
elsif RubygemsIntegration.provides?(">= 1.7.0")
|
664
|
+
@rubygems = RubygemsIntegration::Transitional.new
|
665
|
+
elsif RubygemsIntegration.provides?(">= 1.4.0")
|
666
|
+
@rubygems = RubygemsIntegration::Legacy.new
|
667
|
+
else # Rubygems 1.3.6 and 1.3.7
|
668
|
+
@rubygems = RubygemsIntegration::Ancient.new
|
669
|
+
end
|
670
|
+
|
671
|
+
class << self
|
672
|
+
attr_reader :rubygems
|
673
|
+
end
|
674
|
+
end
|