bundler-prehistoric 1.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rspec +3 -0
- data/.travis.yml +100 -0
- data/CHANGELOG.md +1640 -0
- data/CONTRIBUTING.md +32 -0
- data/DEVELOPMENT.md +117 -0
- data/Gemfile +3 -0
- data/ISSUES.md +96 -0
- data/LICENSE.md +23 -0
- data/README.md +46 -0
- data/Rakefile +256 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +21 -0
- data/bin/bundle_ruby +56 -0
- data/bin/bundler +21 -0
- data/bundler.gemspec +33 -0
- data/lib/bundler.rb +442 -0
- data/lib/bundler/backports/time.rb +7 -0
- data/lib/bundler/capistrano.rb +16 -0
- data/lib/bundler/cli.rb +395 -0
- data/lib/bundler/cli/binstubs.rb +38 -0
- data/lib/bundler/cli/cache.rb +34 -0
- data/lib/bundler/cli/check.rb +35 -0
- data/lib/bundler/cli/clean.rb +19 -0
- data/lib/bundler/cli/common.rb +54 -0
- data/lib/bundler/cli/config.rb +84 -0
- data/lib/bundler/cli/console.rb +39 -0
- data/lib/bundler/cli/exec.rb +37 -0
- data/lib/bundler/cli/gem.rb +101 -0
- data/lib/bundler/cli/init.rb +33 -0
- data/lib/bundler/cli/inject.rb +33 -0
- data/lib/bundler/cli/install.rb +133 -0
- data/lib/bundler/cli/open.rb +23 -0
- data/lib/bundler/cli/outdated.rb +80 -0
- data/lib/bundler/cli/package.rb +36 -0
- data/lib/bundler/cli/platform.rb +43 -0
- data/lib/bundler/cli/show.rb +48 -0
- data/lib/bundler/cli/update.rb +73 -0
- data/lib/bundler/cli/viz.rb +27 -0
- data/lib/bundler/constants.rb +5 -0
- data/lib/bundler/current_ruby.rb +155 -0
- data/lib/bundler/definition.rb +604 -0
- data/lib/bundler/dep_proxy.rb +43 -0
- data/lib/bundler/dependency.rb +106 -0
- data/lib/bundler/deployment.rb +59 -0
- data/lib/bundler/deprecate.rb +15 -0
- data/lib/bundler/dsl.rb +305 -0
- data/lib/bundler/endpoint_specification.rb +76 -0
- data/lib/bundler/env.rb +56 -0
- data/lib/bundler/environment.rb +42 -0
- data/lib/bundler/fetcher.rb +396 -0
- data/lib/bundler/friendly_errors.rb +42 -0
- data/lib/bundler/gem_helper.rb +169 -0
- data/lib/bundler/gem_helpers.rb +25 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_path_manipulation.rb +8 -0
- data/lib/bundler/gem_tasks.rb +2 -0
- data/lib/bundler/graph.rb +169 -0
- data/lib/bundler/index.rb +184 -0
- data/lib/bundler/injector.rb +64 -0
- data/lib/bundler/installer.rb +332 -0
- data/lib/bundler/lazy_specification.rb +83 -0
- data/lib/bundler/lockfile_parser.rb +146 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/parallel_workers.rb +18 -0
- data/lib/bundler/parallel_workers/thread_worker.rb +30 -0
- data/lib/bundler/parallel_workers/unix_worker.rb +101 -0
- data/lib/bundler/parallel_workers/worker.rb +69 -0
- data/lib/bundler/psyched_yaml.rb +26 -0
- data/lib/bundler/remote_specification.rb +57 -0
- data/lib/bundler/resolver.rb +534 -0
- data/lib/bundler/retry.rb +60 -0
- data/lib/bundler/ruby_dsl.rb +11 -0
- data/lib/bundler/ruby_version.rb +117 -0
- data/lib/bundler/rubygems_ext.rb +171 -0
- data/lib/bundler/rubygems_integration.rb +578 -0
- data/lib/bundler/runtime.rb +310 -0
- data/lib/bundler/settings.rb +176 -0
- data/lib/bundler/setup.rb +23 -0
- data/lib/bundler/shared_helpers.rb +110 -0
- data/lib/bundler/similarity_detector.rb +63 -0
- data/lib/bundler/source.rb +29 -0
- data/lib/bundler/source/git.rb +289 -0
- data/lib/bundler/source/git/git_proxy.rb +158 -0
- data/lib/bundler/source/path.rb +225 -0
- data/lib/bundler/source/path/installer.rb +38 -0
- data/lib/bundler/source/rubygems.rb +334 -0
- data/lib/bundler/source/svn.rb +260 -0
- data/lib/bundler/source/svn/svn_proxy.rb +110 -0
- data/lib/bundler/spec_set.rb +154 -0
- data/lib/bundler/ssl_certs/.document +1 -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 +41 -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 +3 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.txt.tt +22 -0
- data/lib/bundler/templates/newgem/README.md.tt +31 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +26 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/consolerc.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 +38 -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/minitest_helper.rb.tt +4 -0
- data/lib/bundler/templates/newgem/test/test_newgem.rb.tt +11 -0
- data/lib/bundler/ui.rb +7 -0
- data/lib/bundler/ui/rg_proxy.rb +21 -0
- data/lib/bundler/ui/shell.rb +98 -0
- data/lib/bundler/ui/silent.rb +44 -0
- data/lib/bundler/vendor/.document +0 -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.rb +480 -0
- data/lib/bundler/vendor/thor/actions.rb +319 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +103 -0
- data/lib/bundler/vendor/thor/actions/create_link.rb +59 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +118 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +135 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +316 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +107 -0
- data/lib/bundler/vendor/thor/base.rb +656 -0
- data/lib/bundler/vendor/thor/command.rb +133 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +77 -0
- data/lib/bundler/vendor/thor/core_ext/io_binary_read.rb +10 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +98 -0
- data/lib/bundler/vendor/thor/error.rb +32 -0
- data/lib/bundler/vendor/thor/group.rb +281 -0
- data/lib/bundler/vendor/thor/invocation.rb +173 -0
- data/lib/bundler/vendor/thor/line_editor.rb +17 -0
- data/lib/bundler/vendor/thor/line_editor/basic.rb +35 -0
- data/lib/bundler/vendor/thor/line_editor/readline.rb +88 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +73 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +175 -0
- data/lib/bundler/vendor/thor/parser/option.rb +121 -0
- data/lib/bundler/vendor/thor/parser/options.rb +218 -0
- data/lib/bundler/vendor/thor/rake_compat.rb +71 -0
- data/lib/bundler/vendor/thor/runner.rb +322 -0
- data/lib/bundler/vendor/thor/shell.rb +81 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +420 -0
- data/lib/bundler/vendor/thor/shell/color.rb +149 -0
- data/lib/bundler/vendor/thor/shell/html.rb +126 -0
- data/lib/bundler/vendor/thor/util.rb +267 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/vendored_persistent.rb +3 -0
- data/lib/bundler/vendored_thor.rb +8 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/man/bundle-config.ronn +155 -0
- data/man/bundle-exec.ronn +136 -0
- data/man/bundle-install.ronn +372 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-platform.ronn +42 -0
- data/man/bundle-update.ronn +179 -0
- data/man/bundle.ronn +92 -0
- data/man/gemfile.5.ronn +369 -0
- data/man/index.txt +7 -0
- data/spec/bundler/bundler_spec.rb +74 -0
- data/spec/bundler/cli_spec.rb +16 -0
- data/spec/bundler/definition_spec.rb +21 -0
- data/spec/bundler/dsl_spec.rb +108 -0
- data/spec/bundler/friendly_errors_spec.rb +13 -0
- data/spec/bundler/gem_helper_spec.rb +225 -0
- data/spec/bundler/psyched_yaml_spec.rb +8 -0
- data/spec/bundler/retry_spec.rb +59 -0
- data/spec/bundler/settings_spec.rb +13 -0
- data/spec/bundler/source_spec.rb +25 -0
- data/spec/cache/gems_spec.rb +316 -0
- data/spec/cache/git_spec.rb +188 -0
- data/spec/cache/path_spec.rb +121 -0
- data/spec/cache/platform_spec.rb +53 -0
- data/spec/cache/svn_spec.rb +82 -0
- data/spec/commands/binstubs_spec.rb +246 -0
- data/spec/commands/check_spec.rb +278 -0
- data/spec/commands/clean_spec.rb +652 -0
- data/spec/commands/config_spec.rb +227 -0
- data/spec/commands/console_spec.rb +102 -0
- data/spec/commands/exec_spec.rb +367 -0
- data/spec/commands/help_spec.rb +39 -0
- data/spec/commands/init_spec.rb +39 -0
- data/spec/commands/inject_spec.rb +78 -0
- data/spec/commands/licenses_spec.rb +31 -0
- data/spec/commands/newgem_spec.rb +451 -0
- data/spec/commands/open_spec.rb +80 -0
- data/spec/commands/outdated_spec.rb +168 -0
- data/spec/commands/package_spec.rb +128 -0
- data/spec/commands/show_spec.rb +152 -0
- data/spec/install/binstubs_spec.rb +24 -0
- data/spec/install/bundler_spec.rb +146 -0
- data/spec/install/deploy_spec.rb +237 -0
- data/spec/install/gemfile/gemspec_spec.rb +170 -0
- data/spec/install/gemfile/git_spec.rb +967 -0
- data/spec/install/gemfile/path_spec.rb +480 -0
- data/spec/install/gemfile/svn_spec.rb +582 -0
- data/spec/install/gemfile_spec.rb +44 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/dependency_api_spec.rb +580 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +314 -0
- data/spec/install/gems/groups_spec.rb +308 -0
- data/spec/install/gems/mirror_spec.rb +39 -0
- data/spec/install/gems/platform_spec.rb +221 -0
- data/spec/install/gems/post_install_spec.rb +121 -0
- data/spec/install/gems/resolving_spec.rb +124 -0
- data/spec/install/gems/simple_case_spec.rb +386 -0
- data/spec/install/gems/standalone_spec.rb +260 -0
- data/spec/install/gems/sudo_spec.rb +136 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspecs_spec.rb +50 -0
- data/spec/install/path_spec.rb +150 -0
- data/spec/install/post_bundle_message_spec.rb +142 -0
- data/spec/install/prereleases_spec.rb +43 -0
- data/spec/install/security_policy_spec.rb +77 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/git_spec.rb +34 -0
- data/spec/lock/lockfile_spec.rb +912 -0
- data/spec/lock/svn_spec.rb +35 -0
- data/spec/other/bundle_ruby_spec.rb +142 -0
- data/spec/other/cli_dispatch_spec.rb +21 -0
- data/spec/other/ext_spec.rb +60 -0
- data/spec/other/platform_spec.rb +1285 -0
- data/spec/other/ssl_cert_spec.rb +10 -0
- data/spec/quality_spec.rb +88 -0
- data/spec/realworld/dependency_api_spec.rb +60 -0
- data/spec/realworld/edgecases_spec.rb +177 -0
- data/spec/realworld/parallel_spec.rb +69 -0
- data/spec/resolver/basic_spec.rb +66 -0
- data/spec/resolver/platform_spec.rb +88 -0
- data/spec/runtime/executable_spec.rb +149 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +332 -0
- data/spec/runtime/setup_spec.rb +856 -0
- data/spec/runtime/with_clean_env_spec.rb +91 -0
- data/spec/spec_helper.rb +114 -0
- data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint.rb +71 -0
- data/spec/support/artifice/endpoint_500.rb +37 -0
- data/spec/support/artifice/endpoint_api_missing.rb +16 -0
- data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint_creds_diff_host.rb +38 -0
- data/spec/support/artifice/endpoint_extra.rb +31 -0
- data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
- data/spec/support/artifice/endpoint_fallback.rb +17 -0
- data/spec/support/artifice/endpoint_host_redirect.rb +15 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +15 -0
- data/spec/support/artifice/endpoint_strict_basic_authentication.rb +18 -0
- data/spec/support/artifice/endpoint_timeout.rb +13 -0
- data/spec/support/builders.rb +748 -0
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/hax.rb +22 -0
- data/spec/support/helpers.rb +348 -0
- data/spec/support/indexes.rb +280 -0
- data/spec/support/less_than_proc.rb +14 -0
- data/spec/support/matchers.rb +77 -0
- data/spec/support/path.rb +81 -0
- data/spec/support/permissions.rb +10 -0
- data/spec/support/platforms.rb +94 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +39 -0
- data/spec/support/streams.rb +13 -0
- data/spec/support/sudo.rb +16 -0
- data/spec/update/gems_spec.rb +201 -0
- data/spec/update/git_spec.rb +236 -0
- data/spec/update/source_spec.rb +63 -0
- data/spec/update/svn_spec.rb +100 -0
- metadata +486 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
module Bundler
|
2
|
+
# General purpose class for retrying code that may fail
|
3
|
+
class Retry
|
4
|
+
DEFAULT_ATTEMPTS = 2
|
5
|
+
attr_accessor :name, :total_runs, :current_run
|
6
|
+
|
7
|
+
class << self
|
8
|
+
attr_accessor :attempts
|
9
|
+
end
|
10
|
+
|
11
|
+
def initialize(name, exceptions = nil, attempts = nil)
|
12
|
+
@name = name
|
13
|
+
attempts ||= default_attempts
|
14
|
+
@exceptions = Array(exceptions) || []
|
15
|
+
@total_runs = attempts.next # will run once, then upto attempts.times
|
16
|
+
end
|
17
|
+
|
18
|
+
def default_attempts
|
19
|
+
return Integer(self.class.attempts) if self.class.attempts
|
20
|
+
DEFAULT_ATTEMPTS
|
21
|
+
end
|
22
|
+
|
23
|
+
def attempt(&block)
|
24
|
+
@current_run = 0
|
25
|
+
@failed = false
|
26
|
+
@error = nil
|
27
|
+
while keep_trying? do
|
28
|
+
run(&block)
|
29
|
+
end
|
30
|
+
@result
|
31
|
+
end
|
32
|
+
alias :attempts :attempt
|
33
|
+
|
34
|
+
private
|
35
|
+
def run(&block)
|
36
|
+
@failed = false
|
37
|
+
@current_run += 1
|
38
|
+
@result = block.call
|
39
|
+
rescue => e
|
40
|
+
fail(e)
|
41
|
+
end
|
42
|
+
|
43
|
+
def fail(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 GemfileError, "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,117 @@
|
|
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
|
+
nil
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def patchlevel
|
114
|
+
RUBY_PATCHLEVEL.to_s
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|
@@ -0,0 +1,171 @@
|
|
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 :source_uri, :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
|
+
source.respond_to?(:path) ?
|
26
|
+
Pathname.new(loaded_from).dirname.expand_path(Bundler.root).to_s :
|
27
|
+
rg_full_gem_path
|
28
|
+
end
|
29
|
+
|
30
|
+
def loaded_from
|
31
|
+
relative_loaded_from ?
|
32
|
+
source.path.join(relative_loaded_from).to_s :
|
33
|
+
rg_loaded_from
|
34
|
+
end
|
35
|
+
|
36
|
+
def load_paths
|
37
|
+
return full_require_paths if respond_to?(:full_require_paths)
|
38
|
+
|
39
|
+
require_paths.map do |require_path|
|
40
|
+
if require_path.include?(full_gem_path)
|
41
|
+
require_path
|
42
|
+
else
|
43
|
+
File.join(full_gem_path, require_path)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
if method_defined?(:extension_dir)
|
49
|
+
alias_method :rg_extension_dir, :extension_dir
|
50
|
+
def extension_dir
|
51
|
+
@extension_dir ||= source.respond_to?(:extension_dir_name) ?
|
52
|
+
File.expand_path(File.join(extensions_dir, source.extension_dir_name)) :
|
53
|
+
rg_extension_dir
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
# RubyGems 1.8+ used only.
|
58
|
+
remove_method :gem_dir if instance_methods(false).include?(:gem_dir)
|
59
|
+
def gem_dir
|
60
|
+
full_gem_path
|
61
|
+
end
|
62
|
+
|
63
|
+
def groups
|
64
|
+
@groups ||= []
|
65
|
+
end
|
66
|
+
|
67
|
+
def scm_version
|
68
|
+
return unless loaded_from
|
69
|
+
case source
|
70
|
+
when Bundler::Source::Git then " #{source.revision[0..6]}"
|
71
|
+
when Bundler::Source::SVN then " #{source.revision}"
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
def to_gemfile(path = nil)
|
76
|
+
gemfile = "source :gemcutter\n"
|
77
|
+
gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
|
78
|
+
unless development_dependencies.empty?
|
79
|
+
gemfile << "\n"
|
80
|
+
gemfile << dependencies_to_gemfile(development_dependencies, :development)
|
81
|
+
end
|
82
|
+
gemfile
|
83
|
+
end
|
84
|
+
|
85
|
+
def nondevelopment_dependencies
|
86
|
+
dependencies - development_dependencies
|
87
|
+
end
|
88
|
+
|
89
|
+
private
|
90
|
+
|
91
|
+
def dependencies_to_gemfile(dependencies, group = nil)
|
92
|
+
gemfile = ''
|
93
|
+
if dependencies.any?
|
94
|
+
gemfile << "group :#{group} do\n" if group
|
95
|
+
dependencies.each do |dependency|
|
96
|
+
gemfile << ' ' if group
|
97
|
+
gemfile << %|gem "#{dependency.name}"|
|
98
|
+
req = dependency.requirements_list.first
|
99
|
+
gemfile << %|, "#{req}"| if req
|
100
|
+
gemfile << "\n"
|
101
|
+
end
|
102
|
+
gemfile << "end\n" if group
|
103
|
+
end
|
104
|
+
gemfile
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
108
|
+
|
109
|
+
class Dependency
|
110
|
+
attr_accessor :source, :groups
|
111
|
+
|
112
|
+
alias eql? ==
|
113
|
+
|
114
|
+
def encode_with(coder)
|
115
|
+
to_yaml_properties.each do |ivar|
|
116
|
+
coder[ivar.to_s.sub(/^@/, '')] = instance_variable_get(ivar)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
def to_yaml_properties
|
121
|
+
instance_variables.reject { |p| ["@source", "@groups"].include?(p.to_s) }
|
122
|
+
end
|
123
|
+
|
124
|
+
def to_lock
|
125
|
+
out = " #{name}"
|
126
|
+
unless requirement == Gem::Requirement.default
|
127
|
+
reqs = requirement.requirements.map{|o,v| "#{o} #{v}" }.sort.reverse
|
128
|
+
out << " (#{reqs.join(', ')})"
|
129
|
+
end
|
130
|
+
out
|
131
|
+
end
|
132
|
+
|
133
|
+
# Backport of performance enhancement added to Rubygems 1.4
|
134
|
+
def matches_spec?(spec)
|
135
|
+
# name can be a Regexp, so use ===
|
136
|
+
return false unless name === spec.name
|
137
|
+
return true if requirement.none?
|
138
|
+
|
139
|
+
requirement.satisfied_by?(spec.version)
|
140
|
+
end unless allocate.respond_to?(:matches_spec?)
|
141
|
+
end
|
142
|
+
|
143
|
+
class Requirement
|
144
|
+
# Backport of performance enhancement added to Rubygems 1.4
|
145
|
+
def none?
|
146
|
+
@none ||= (to_s == ">= 0")
|
147
|
+
end unless allocate.respond_to?(:none?)
|
148
|
+
end
|
149
|
+
|
150
|
+
class Platform
|
151
|
+
JAVA = Gem::Platform.new('java') unless defined?(JAVA)
|
152
|
+
MSWIN = Gem::Platform.new('mswin32') unless defined?(MSWIN)
|
153
|
+
MSWIN64 = Gem::Platform.new('mswin64') unless defined?(MSWIN64)
|
154
|
+
MINGW = Gem::Platform.new('x86-mingw32') unless defined?(MINGW)
|
155
|
+
X64_MINGW = Gem::Platform.new('x64-mingw32') unless defined?(X64_MINGW)
|
156
|
+
|
157
|
+
undef_method :hash if method_defined? :hash
|
158
|
+
def hash
|
159
|
+
@cpu.hash ^ @os.hash ^ @version.hash
|
160
|
+
end
|
161
|
+
|
162
|
+
undef_method :eql? if method_defined? :eql?
|
163
|
+
alias eql? ==
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
module Gem
|
168
|
+
class Specification
|
169
|
+
include ::Bundler::MatchPlatform
|
170
|
+
end
|
171
|
+
end
|
@@ -0,0 +1,578 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rubygems/config_file'
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
class RubygemsIntegration
|
6
|
+
|
7
|
+
def self.version
|
8
|
+
@version ||= Gem::Version.new(Gem::VERSION)
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.provides?(req_str)
|
12
|
+
Gem::Requirement.new(req_str).satisfied_by?(version)
|
13
|
+
end
|
14
|
+
|
15
|
+
def version
|
16
|
+
self.class.version
|
17
|
+
end
|
18
|
+
|
19
|
+
def provides?(req_str)
|
20
|
+
self.class.provides?(req_str)
|
21
|
+
end
|
22
|
+
|
23
|
+
def build_args
|
24
|
+
Gem::Command.build_args
|
25
|
+
end
|
26
|
+
|
27
|
+
def build_args=(args)
|
28
|
+
Gem::Command.build_args = args
|
29
|
+
end
|
30
|
+
|
31
|
+
def loaded_specs(name)
|
32
|
+
Gem.loaded_specs[name]
|
33
|
+
end
|
34
|
+
|
35
|
+
def mark_loaded(spec)
|
36
|
+
Gem.loaded_specs[spec.name] = spec
|
37
|
+
end
|
38
|
+
|
39
|
+
def path(obj)
|
40
|
+
obj.to_s
|
41
|
+
end
|
42
|
+
|
43
|
+
def platforms
|
44
|
+
Gem.platforms
|
45
|
+
end
|
46
|
+
|
47
|
+
def configuration
|
48
|
+
Gem.configuration
|
49
|
+
rescue Gem::SystemExitException => e
|
50
|
+
Bundler.ui.error "#{e.class}: #{e.message}"
|
51
|
+
Bundler.ui.trace e
|
52
|
+
raise Gem::SystemExitException
|
53
|
+
end
|
54
|
+
|
55
|
+
def ruby_engine
|
56
|
+
Gem.ruby_engine
|
57
|
+
end
|
58
|
+
|
59
|
+
def read_binary(path)
|
60
|
+
Gem.read_binary(path)
|
61
|
+
end
|
62
|
+
|
63
|
+
def inflate(obj)
|
64
|
+
Gem.inflate(obj)
|
65
|
+
end
|
66
|
+
|
67
|
+
def sources=(val)
|
68
|
+
# Gem.configuration creates a new Gem::ConfigFile, which by default will read ~/.gemrc
|
69
|
+
# If that file exists, its settings (including sources) will overwrite the values we
|
70
|
+
# are about to set here. In order to avoid that, we force memoizing the config file now.
|
71
|
+
configuration
|
72
|
+
|
73
|
+
Gem.sources = val
|
74
|
+
end
|
75
|
+
|
76
|
+
def sources
|
77
|
+
Gem.sources
|
78
|
+
end
|
79
|
+
|
80
|
+
def gem_dir
|
81
|
+
Gem.dir
|
82
|
+
end
|
83
|
+
|
84
|
+
def gem_bindir
|
85
|
+
Gem.bindir
|
86
|
+
end
|
87
|
+
|
88
|
+
def user_home
|
89
|
+
Gem.user_home
|
90
|
+
end
|
91
|
+
|
92
|
+
def gem_path
|
93
|
+
Gem.path
|
94
|
+
end
|
95
|
+
|
96
|
+
def gem_cache
|
97
|
+
gem_path.map{|p| File.expand_path("cache", p) }
|
98
|
+
end
|
99
|
+
|
100
|
+
def spec_cache_dirs
|
101
|
+
@spec_cache_dirs ||= begin
|
102
|
+
dirs = gem_path.map {|dir| File.join(dir, 'specifications')}
|
103
|
+
dirs << Gem.spec_cache_dir if Gem.respond_to?(:spec_cache_dir) # Not in Rubygems 2.0.3 or earlier
|
104
|
+
dirs.uniq.select {|dir| File.directory? dir}
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def marshal_spec_dir
|
109
|
+
Gem::MARSHAL_SPEC_DIR
|
110
|
+
end
|
111
|
+
|
112
|
+
def config_map
|
113
|
+
Gem::ConfigMap
|
114
|
+
end
|
115
|
+
|
116
|
+
def repository_subdirectories
|
117
|
+
%w[cache doc gems specifications]
|
118
|
+
end
|
119
|
+
|
120
|
+
def clear_paths
|
121
|
+
Gem.clear_paths
|
122
|
+
end
|
123
|
+
|
124
|
+
def bin_path(gem, bin, ver)
|
125
|
+
Gem.bin_path(gem, bin, ver)
|
126
|
+
end
|
127
|
+
|
128
|
+
def preserve_paths
|
129
|
+
# this is a no-op outside of Rubygems 1.8
|
130
|
+
yield
|
131
|
+
end
|
132
|
+
|
133
|
+
def ui=(obj)
|
134
|
+
Gem::DefaultUserInteraction.ui = obj
|
135
|
+
end
|
136
|
+
|
137
|
+
def fetch_specs(all, pre, &blk)
|
138
|
+
specs = Gem::SpecFetcher.new.list(all, pre)
|
139
|
+
specs.each { yield } if block_given?
|
140
|
+
specs
|
141
|
+
end
|
142
|
+
|
143
|
+
def fetch_prerelease_specs
|
144
|
+
fetch_specs(false, true)
|
145
|
+
rescue Gem::RemoteFetcher::FetchError
|
146
|
+
[] # if we can't download them, there aren't any
|
147
|
+
end
|
148
|
+
|
149
|
+
def fetch_all_remote_specs
|
150
|
+
# Fetch all specs, minus prerelease specs
|
151
|
+
spec_list = fetch_specs(true, false)
|
152
|
+
# Then fetch the prerelease specs
|
153
|
+
fetch_prerelease_specs.each {|k, v| spec_list[k] += v }
|
154
|
+
|
155
|
+
return spec_list
|
156
|
+
end
|
157
|
+
|
158
|
+
def with_build_args(args)
|
159
|
+
old_args = self.build_args
|
160
|
+
begin
|
161
|
+
self.build_args = args
|
162
|
+
yield
|
163
|
+
ensure
|
164
|
+
self.build_args = old_args
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
def gem_from_path(path, policy = nil)
|
169
|
+
require 'rubygems/format'
|
170
|
+
Gem::Format.from_file_by_path(path, policy)
|
171
|
+
end
|
172
|
+
|
173
|
+
def spec_from_gem(path, policy = nil)
|
174
|
+
require 'rubygems/security'
|
175
|
+
gem_from_path(path, security_policies[policy]).spec
|
176
|
+
rescue Gem::Package::FormatError
|
177
|
+
raise GemspecError, "Could not read gem at #{path}. It may be corrupted."
|
178
|
+
rescue Exception, Gem::Exception, Gem::Security::Exception => e
|
179
|
+
if e.is_a?(Gem::Security::Exception) ||
|
180
|
+
e.message =~ /unknown trust policy|unsigned gem/i ||
|
181
|
+
e.message =~ /couldn't verify (meta)?data signature/i
|
182
|
+
raise SecurityError,
|
183
|
+
"The gem #{File.basename(path, '.gem')} can't be installed because " \
|
184
|
+
"the security policy didn't allow it, with the message: #{e.message}"
|
185
|
+
else
|
186
|
+
raise e
|
187
|
+
end
|
188
|
+
end
|
189
|
+
|
190
|
+
def build(spec, skip_validation = false)
|
191
|
+
require 'rubygems/builder'
|
192
|
+
Gem::Builder.new(spec).build
|
193
|
+
end
|
194
|
+
|
195
|
+
def build_gem(gem_dir, spec)
|
196
|
+
SharedHelpers.chdir(gem_dir) { build(spec) }
|
197
|
+
end
|
198
|
+
|
199
|
+
def download_gem(spec, uri, path)
|
200
|
+
uri = Bundler::Source.mirror_for(uri)
|
201
|
+
fetcher = Gem::RemoteFetcher.new(configuration[:http_proxy])
|
202
|
+
fetcher.download(spec, uri, path)
|
203
|
+
end
|
204
|
+
|
205
|
+
def security_policy_keys
|
206
|
+
%w{High Medium Low AlmostNo No}.map { |level| "#{level}Security" }
|
207
|
+
end
|
208
|
+
|
209
|
+
def security_policies
|
210
|
+
@security_policies ||= begin
|
211
|
+
require 'rubygems/security'
|
212
|
+
Gem::Security::Policies
|
213
|
+
rescue LoadError, NameError
|
214
|
+
{}
|
215
|
+
end
|
216
|
+
end
|
217
|
+
|
218
|
+
def reverse_rubygems_kernel_mixin
|
219
|
+
# Disable rubygems' gem activation system
|
220
|
+
::Kernel.class_eval do
|
221
|
+
if private_method_defined?(:gem_original_require)
|
222
|
+
alias rubygems_require require
|
223
|
+
alias require gem_original_require
|
224
|
+
end
|
225
|
+
|
226
|
+
undef gem
|
227
|
+
end
|
228
|
+
end
|
229
|
+
|
230
|
+
def replace_gem(specs)
|
231
|
+
reverse_rubygems_kernel_mixin
|
232
|
+
|
233
|
+
executables = specs.map { |s| s.executables }.flatten
|
234
|
+
|
235
|
+
::Kernel.send(:define_method, :gem) do |dep, *reqs|
|
236
|
+
if executables.include? File.basename(caller.first.split(':').first)
|
237
|
+
return
|
238
|
+
end
|
239
|
+
reqs.pop if reqs.last.is_a?(Hash)
|
240
|
+
|
241
|
+
unless dep.respond_to?(:name) && dep.respond_to?(:requirement)
|
242
|
+
dep = Gem::Dependency.new(dep, reqs)
|
243
|
+
end
|
244
|
+
|
245
|
+
spec = specs.find { |s| s.name == dep.name }
|
246
|
+
|
247
|
+
if spec.nil?
|
248
|
+
|
249
|
+
e = Gem::LoadError.new "#{dep.name} is not part of the bundle. Add it to Gemfile."
|
250
|
+
e.name = dep.name
|
251
|
+
if e.respond_to?(:requirement=)
|
252
|
+
e.requirement = dep.requirement
|
253
|
+
else
|
254
|
+
e.version_requirement = dep.requirement
|
255
|
+
end
|
256
|
+
raise e
|
257
|
+
elsif dep !~ spec
|
258
|
+
e = Gem::LoadError.new "can't activate #{dep}, already activated #{spec.full_name}. " \
|
259
|
+
"Make sure all dependencies are added to Gemfile."
|
260
|
+
e.name = dep.name
|
261
|
+
if e.respond_to?(:requirement=)
|
262
|
+
e.requirement = dep.requirement
|
263
|
+
else
|
264
|
+
e.version_requirement = dep.requirement
|
265
|
+
end
|
266
|
+
raise e
|
267
|
+
end
|
268
|
+
|
269
|
+
true
|
270
|
+
end
|
271
|
+
end
|
272
|
+
|
273
|
+
def stub_source_index(specs)
|
274
|
+
Gem::SourceIndex.send(:alias_method, :old_initialize, :initialize)
|
275
|
+
redefine_method(Gem::SourceIndex, :initialize) do |*args|
|
276
|
+
@gems = {}
|
277
|
+
# You're looking at this thinking: Oh! This is how I make those
|
278
|
+
# rubygems deprecations go away!
|
279
|
+
#
|
280
|
+
# You'd be correct BUT using of this method in production code
|
281
|
+
# must be approved by the rubygems team itself!
|
282
|
+
#
|
283
|
+
# This is your warning. If you use this and don't have approval
|
284
|
+
# we can't protect you.
|
285
|
+
#
|
286
|
+
Deprecate.skip_during do
|
287
|
+
self.spec_dirs = *args
|
288
|
+
add_specs(*specs)
|
289
|
+
end
|
290
|
+
end
|
291
|
+
end
|
292
|
+
|
293
|
+
# Used to make bin stubs that are not created by bundler work
|
294
|
+
# under bundler. The new Gem.bin_path only considers gems in
|
295
|
+
# +specs+
|
296
|
+
def replace_bin_path(specs)
|
297
|
+
gem_class = (class << Gem ; self ; end)
|
298
|
+
redefine_method(gem_class, :bin_path) do |name, *args|
|
299
|
+
exec_name = args.first
|
300
|
+
|
301
|
+
if exec_name == 'bundle'
|
302
|
+
return ENV['BUNDLE_BIN_PATH']
|
303
|
+
end
|
304
|
+
|
305
|
+
spec = nil
|
306
|
+
|
307
|
+
if exec_name
|
308
|
+
spec = specs.find { |s| s.executables.include?(exec_name) }
|
309
|
+
unless spec.name == name
|
310
|
+
warn "Bundler is using a binstub that was created for a different gem.\n" \
|
311
|
+
"This is deprecated, in future versions you may need to `bundle binstub #{name}` " \
|
312
|
+
"to work around a system/bundle conflict."
|
313
|
+
end
|
314
|
+
spec or raise Gem::Exception, "can't find executable #{exec_name}"
|
315
|
+
else
|
316
|
+
spec = specs.find { |s| s.name == name }
|
317
|
+
exec_name = spec.default_executable or raise Gem::Exception, "no default executable for #{spec.full_name}"
|
318
|
+
end
|
319
|
+
|
320
|
+
gem_bin = File.join(spec.full_gem_path, spec.bindir, exec_name)
|
321
|
+
gem_from_path_bin = File.join(File.dirname(spec.loaded_from), spec.bindir, exec_name)
|
322
|
+
File.exist?(gem_bin) ? gem_bin : gem_from_path_bin
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
# Because Bundler has a static view of what specs are available,
|
327
|
+
# we don't #refresh, so stub it out.
|
328
|
+
def replace_refresh
|
329
|
+
gem_class = (class << Gem ; self ; end)
|
330
|
+
redefine_method(gem_class, :refresh) { }
|
331
|
+
end
|
332
|
+
|
333
|
+
# Replace or hook into Rubygems to provide a bundlerized view
|
334
|
+
# of the world.
|
335
|
+
def replace_entrypoints(specs)
|
336
|
+
replace_gem(specs)
|
337
|
+
|
338
|
+
stub_rubygems(specs)
|
339
|
+
|
340
|
+
replace_bin_path(specs)
|
341
|
+
replace_refresh
|
342
|
+
|
343
|
+
Gem.clear_paths
|
344
|
+
end
|
345
|
+
|
346
|
+
# This backports the correct segment generation code from Rubygems 1.4+
|
347
|
+
# by monkeypatching it into the method in Rubygems 1.3.6 and 1.3.7.
|
348
|
+
def backport_segment_generation
|
349
|
+
redefine_method(Gem::Version, :segments) do
|
350
|
+
@segments ||= @version.scan(/[0-9]+|[a-z]+/i).map do |s|
|
351
|
+
/^\d+$/ =~ s ? s.to_i : s
|
352
|
+
end
|
353
|
+
end
|
354
|
+
end
|
355
|
+
|
356
|
+
# This backport fixes the marshaling of @segments.
|
357
|
+
def backport_yaml_initialize
|
358
|
+
redefine_method(Gem::Version, :yaml_initialize) do |tag, map|
|
359
|
+
@version = map['version']
|
360
|
+
@segments = nil
|
361
|
+
@hash = nil
|
362
|
+
end
|
363
|
+
end
|
364
|
+
|
365
|
+
# This backports base_dir which replaces installation path
|
366
|
+
# Rubygems 1.8+
|
367
|
+
def backport_base_dir
|
368
|
+
redefine_method(Gem::Specification, :base_dir) do
|
369
|
+
return Gem.dir unless loaded_from
|
370
|
+
File.dirname File.dirname loaded_from
|
371
|
+
end
|
372
|
+
end
|
373
|
+
|
374
|
+
def backport_cache_file
|
375
|
+
redefine_method(Gem::Specification, :cache_dir) do
|
376
|
+
@cache_dir ||= File.join base_dir, "cache"
|
377
|
+
end
|
378
|
+
|
379
|
+
redefine_method(Gem::Specification, :cache_file) do
|
380
|
+
@cache_file ||= File.join cache_dir, "#{full_name}.gem"
|
381
|
+
end
|
382
|
+
end
|
383
|
+
|
384
|
+
def backport_spec_file
|
385
|
+
redefine_method(Gem::Specification, :spec_dir) do
|
386
|
+
@spec_dir ||= File.join base_dir, "specifications"
|
387
|
+
end
|
388
|
+
|
389
|
+
redefine_method(Gem::Specification, :spec_file) do
|
390
|
+
@spec_file ||= File.join spec_dir, "#{full_name}.gemspec"
|
391
|
+
end
|
392
|
+
end
|
393
|
+
|
394
|
+
def redefine_method(klass, method, &block)
|
395
|
+
if klass.instance_methods(false).include?(method)
|
396
|
+
klass.send(:remove_method, method)
|
397
|
+
end
|
398
|
+
klass.send(:define_method, method, &block)
|
399
|
+
end
|
400
|
+
|
401
|
+
# Rubygems 1.4 through 1.6
|
402
|
+
class Legacy < RubygemsIntegration
|
403
|
+
def initialize
|
404
|
+
super
|
405
|
+
backport_base_dir
|
406
|
+
backport_cache_file
|
407
|
+
backport_spec_file
|
408
|
+
backport_yaml_initialize
|
409
|
+
end
|
410
|
+
|
411
|
+
def stub_rubygems(specs)
|
412
|
+
# Rubygems versions lower than 1.7 use SourceIndex#from_gems_in
|
413
|
+
source_index_class = (class << Gem::SourceIndex ; self ; end)
|
414
|
+
source_index_class.send(:define_method, :from_gems_in) do |*args|
|
415
|
+
source_index = Gem::SourceIndex.new
|
416
|
+
source_index.spec_dirs = *args
|
417
|
+
source_index.add_specs(*specs)
|
418
|
+
source_index
|
419
|
+
end
|
420
|
+
end
|
421
|
+
|
422
|
+
def all_specs
|
423
|
+
Gem.source_index.gems.values
|
424
|
+
end
|
425
|
+
|
426
|
+
def find_name(name)
|
427
|
+
Gem.source_index.find_name(name)
|
428
|
+
end
|
429
|
+
end
|
430
|
+
|
431
|
+
# Rubygems versions 1.3.6 and 1.3.7
|
432
|
+
class Ancient < Legacy
|
433
|
+
def initialize
|
434
|
+
super
|
435
|
+
backport_segment_generation
|
436
|
+
end
|
437
|
+
end
|
438
|
+
|
439
|
+
# Rubygems 1.7
|
440
|
+
class Transitional < Legacy
|
441
|
+
def stub_rubygems(specs)
|
442
|
+
stub_source_index(specs)
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
# Rubygems 1.8.5-1.8.19
|
447
|
+
class Modern < RubygemsIntegration
|
448
|
+
def stub_rubygems(specs)
|
449
|
+
Gem::Specification.all = specs
|
450
|
+
|
451
|
+
Gem.post_reset {
|
452
|
+
Gem::Specification.all = specs
|
453
|
+
}
|
454
|
+
|
455
|
+
stub_source_index(specs)
|
456
|
+
end
|
457
|
+
|
458
|
+
def all_specs
|
459
|
+
Gem::Specification.to_a
|
460
|
+
end
|
461
|
+
|
462
|
+
def find_name(name)
|
463
|
+
Gem::Specification.find_all_by_name name
|
464
|
+
end
|
465
|
+
end
|
466
|
+
|
467
|
+
# Rubygems 1.8.0 to 1.8.4
|
468
|
+
class AlmostModern < Modern
|
469
|
+
# Rubygems [>= 1.8.0, < 1.8.5] has a bug that changes Gem.dir whenever
|
470
|
+
# you call Gem::Installer#install with an :install_dir set. We have to
|
471
|
+
# change it back for our sudo mode to work.
|
472
|
+
def preserve_paths
|
473
|
+
old_dir, old_path = gem_dir, gem_path
|
474
|
+
yield
|
475
|
+
Gem.use_paths(old_dir, old_path)
|
476
|
+
end
|
477
|
+
end
|
478
|
+
|
479
|
+
# Rubygems 1.8.20+
|
480
|
+
class MoreModern < Modern
|
481
|
+
# Rubygems 1.8.20 and adds the skip_validation parameter, so that's
|
482
|
+
# when we start passing it through.
|
483
|
+
def build(spec, skip_validation = false)
|
484
|
+
require 'rubygems/builder'
|
485
|
+
Gem::Builder.new(spec).build(skip_validation)
|
486
|
+
end
|
487
|
+
end
|
488
|
+
|
489
|
+
# Rubygems 2.0
|
490
|
+
class Future < RubygemsIntegration
|
491
|
+
def stub_rubygems(specs)
|
492
|
+
Gem::Specification.all = specs
|
493
|
+
|
494
|
+
Gem.post_reset do
|
495
|
+
Gem::Specification.all = specs
|
496
|
+
end
|
497
|
+
end
|
498
|
+
|
499
|
+
def all_specs
|
500
|
+
Gem::Specification.to_a
|
501
|
+
end
|
502
|
+
|
503
|
+
def find_name(name)
|
504
|
+
Gem::Specification.find_all_by_name name
|
505
|
+
end
|
506
|
+
|
507
|
+
def fetch_specs(source, name)
|
508
|
+
path = source + "#{name}.#{Gem.marshal_version}.gz"
|
509
|
+
string = Gem::RemoteFetcher.fetcher.fetch_path(path)
|
510
|
+
Bundler.load_marshal(string)
|
511
|
+
rescue Gem::RemoteFetcher::FetchError => e
|
512
|
+
# it's okay for prerelease to fail
|
513
|
+
raise e unless name == "prerelease_specs"
|
514
|
+
end
|
515
|
+
|
516
|
+
def fetch_all_remote_specs
|
517
|
+
# Since SpecFetcher now returns NameTuples, we just fetch directly
|
518
|
+
# and unmarshal the array ourselves.
|
519
|
+
hash = {}
|
520
|
+
|
521
|
+
Gem.sources.each do |source|
|
522
|
+
source = URI.parse(source.to_s) unless source.is_a?(URI)
|
523
|
+
hash[source] = fetch_specs(source, "specs")
|
524
|
+
|
525
|
+
pres = fetch_specs(source, "prerelease_specs")
|
526
|
+
hash[source].push(*pres) if pres && !pres.empty?
|
527
|
+
end
|
528
|
+
|
529
|
+
hash
|
530
|
+
end
|
531
|
+
|
532
|
+
def download_gem(spec, uri, path)
|
533
|
+
require 'resolv'
|
534
|
+
uri = Bundler::Source.mirror_for(uri)
|
535
|
+
proxy, dns = configuration[:http_proxy], Resolv::DNS.new
|
536
|
+
fetcher = Gem::RemoteFetcher.new(proxy, dns)
|
537
|
+
fetcher.download(spec, uri, path)
|
538
|
+
end
|
539
|
+
|
540
|
+
def gem_from_path(path, policy = nil)
|
541
|
+
require 'rubygems/package'
|
542
|
+
p = Gem::Package.new(path)
|
543
|
+
p.security_policy = policy if policy
|
544
|
+
return p
|
545
|
+
end
|
546
|
+
|
547
|
+
def build(spec, skip_validation = false)
|
548
|
+
require 'rubygems/package'
|
549
|
+
Gem::Package.build(spec, skip_validation)
|
550
|
+
end
|
551
|
+
|
552
|
+
def repository_subdirectories
|
553
|
+
Gem::REPOSITORY_SUBDIRECTORIES
|
554
|
+
end
|
555
|
+
end
|
556
|
+
|
557
|
+
end
|
558
|
+
|
559
|
+
if RubygemsIntegration.provides?(">= 1.99.99")
|
560
|
+
@rubygems = RubygemsIntegration::Future.new
|
561
|
+
elsif RubygemsIntegration.provides?('>= 1.8.20')
|
562
|
+
@rubygems = RubygemsIntegration::MoreModern.new
|
563
|
+
elsif RubygemsIntegration.provides?('>= 1.8.5')
|
564
|
+
@rubygems = RubygemsIntegration::Modern.new
|
565
|
+
elsif RubygemsIntegration.provides?('>= 1.8.0')
|
566
|
+
@rubygems = RubygemsIntegration::AlmostModern.new
|
567
|
+
elsif RubygemsIntegration.provides?('>= 1.7.0')
|
568
|
+
@rubygems = RubygemsIntegration::Transitional.new
|
569
|
+
elsif RubygemsIntegration.provides?('>= 1.4.0')
|
570
|
+
@rubygems = RubygemsIntegration::Legacy.new
|
571
|
+
else # Rubygems 1.3.6 and 1.3.7
|
572
|
+
@rubygems = RubygemsIntegration::Ancient.new
|
573
|
+
end
|
574
|
+
|
575
|
+
class << self
|
576
|
+
attr_reader :rubygems
|
577
|
+
end
|
578
|
+
end
|