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,42 @@
|
|
1
|
+
require "bundler/vendored_thor"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
def self.with_friendly_errors
|
5
|
+
yield
|
6
|
+
rescue Bundler::BundlerError => e
|
7
|
+
Bundler.ui.error e.message, :wrap => true
|
8
|
+
Bundler.ui.trace e
|
9
|
+
exit e.status_code
|
10
|
+
rescue Thor::AmbiguousTaskError => e
|
11
|
+
Bundler.ui.error e.message
|
12
|
+
exit 15
|
13
|
+
rescue Thor::UndefinedTaskError => e
|
14
|
+
Bundler.ui.error e.message
|
15
|
+
exit 15
|
16
|
+
rescue Thor::Error => e
|
17
|
+
Bundler.ui.error e.message
|
18
|
+
exit 1
|
19
|
+
rescue LoadError => e
|
20
|
+
raise e unless e.message =~ /cannot load such file -- openssl|openssl.so|libcrypto.so/
|
21
|
+
Bundler.ui.error "\nCould not load OpenSSL."
|
22
|
+
Bundler.ui.warn <<-WARN, :wrap => true
|
23
|
+
You must recompile Ruby with OpenSSL support or change the sources in your \
|
24
|
+
Gemfile from 'https' to 'http'. Instructions for compiling with OpenSSL \
|
25
|
+
using RVM are available at http://rvm.io/packages/openssl.
|
26
|
+
WARN
|
27
|
+
Bundler.ui.trace e
|
28
|
+
exit 1
|
29
|
+
rescue Interrupt => e
|
30
|
+
Bundler.ui.error "\nQuitting..."
|
31
|
+
Bundler.ui.trace e
|
32
|
+
exit 1
|
33
|
+
rescue SystemExit => e
|
34
|
+
exit e.status
|
35
|
+
rescue Exception => e
|
36
|
+
Bundler.ui.error <<-ERR, :wrap => true
|
37
|
+
Unfortunately, a fatal error has occurred. Please see the Bundler \
|
38
|
+
troubleshooting documentation at http://bit.ly/bundler-issues. Thanks!
|
39
|
+
ERR
|
40
|
+
raise e
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'bundler/vendored_thor' unless defined?(Thor)
|
2
|
+
require 'bundler'
|
3
|
+
|
4
|
+
module Bundler
|
5
|
+
class GemHelper
|
6
|
+
include Rake::DSL if defined? Rake::DSL
|
7
|
+
|
8
|
+
class << self
|
9
|
+
# set when install'd.
|
10
|
+
attr_accessor :instance
|
11
|
+
|
12
|
+
def install_tasks(opts = {})
|
13
|
+
new(opts[:dir], opts[:name]).install
|
14
|
+
end
|
15
|
+
|
16
|
+
def gemspec(&block)
|
17
|
+
gemspec = instance.gemspec
|
18
|
+
block.call(gemspec) if block
|
19
|
+
gemspec
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :spec_path, :base, :gemspec
|
24
|
+
|
25
|
+
def initialize(base = nil, name = nil)
|
26
|
+
Bundler.ui = UI::Shell.new
|
27
|
+
@base = (base ||= SharedHelpers.pwd)
|
28
|
+
gemspecs = name ? [File.join(base, "#{name}.gemspec")] : Dir[File.join(base, "{,*}.gemspec")]
|
29
|
+
raise "Unable to determine name from existing gemspec. Use :name => 'gemname' in #install_tasks to manually set it." unless gemspecs.size == 1
|
30
|
+
@spec_path = gemspecs.first
|
31
|
+
@gemspec = Bundler.load_gemspec(@spec_path)
|
32
|
+
end
|
33
|
+
|
34
|
+
def install
|
35
|
+
built_gem_path = nil
|
36
|
+
|
37
|
+
desc "Build #{name}-#{version}.gem into the pkg directory."
|
38
|
+
task 'build' do
|
39
|
+
built_gem_path = build_gem
|
40
|
+
end
|
41
|
+
|
42
|
+
desc "Build and install #{name}-#{version}.gem into system gems."
|
43
|
+
task 'install' => 'build' do
|
44
|
+
install_gem(built_gem_path)
|
45
|
+
end
|
46
|
+
|
47
|
+
desc "Create tag #{version_tag} and build and push #{name}-#{version}.gem to Rubygems"
|
48
|
+
task 'release' => 'build' do
|
49
|
+
release_gem(built_gem_path)
|
50
|
+
end
|
51
|
+
|
52
|
+
GemHelper.instance = self
|
53
|
+
end
|
54
|
+
|
55
|
+
def build_gem
|
56
|
+
file_name = nil
|
57
|
+
sh("gem build -V '#{spec_path}'") { |out, code|
|
58
|
+
file_name = File.basename(built_gem_path)
|
59
|
+
FileUtils.mkdir_p(File.join(base, 'pkg'))
|
60
|
+
FileUtils.mv(built_gem_path, 'pkg')
|
61
|
+
Bundler.ui.confirm "#{name} #{version} built to pkg/#{file_name}."
|
62
|
+
}
|
63
|
+
File.join(base, 'pkg', file_name)
|
64
|
+
end
|
65
|
+
|
66
|
+
def install_gem(built_gem_path=nil)
|
67
|
+
built_gem_path ||= build_gem
|
68
|
+
out, _ = sh_with_code("gem install '#{built_gem_path}' --local")
|
69
|
+
raise "Couldn't install gem, run `gem install #{built_gem_path}' for more detailed output" unless out[/Successfully installed/]
|
70
|
+
Bundler.ui.confirm "#{name} (#{version}) installed."
|
71
|
+
end
|
72
|
+
|
73
|
+
def release_gem(built_gem_path=nil)
|
74
|
+
guard_clean
|
75
|
+
built_gem_path ||= build_gem
|
76
|
+
tag_version { git_push } unless already_tagged?
|
77
|
+
rubygem_push(built_gem_path) if gem_push?
|
78
|
+
end
|
79
|
+
|
80
|
+
protected
|
81
|
+
def rubygem_push(path)
|
82
|
+
if Pathname.new("~/.gem/credentials").expand_path.exist?
|
83
|
+
sh("gem push '#{path}'")
|
84
|
+
Bundler.ui.confirm "Pushed #{name} #{version} to rubygems.org."
|
85
|
+
else
|
86
|
+
raise "Your rubygems.org credentials aren't set. Run `gem push` to set them."
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
def built_gem_path
|
91
|
+
Dir[File.join(base, "#{name}-*.gem")].sort_by{|f| File.mtime(f)}.last
|
92
|
+
end
|
93
|
+
|
94
|
+
def git_push
|
95
|
+
perform_git_push
|
96
|
+
perform_git_push ' --tags'
|
97
|
+
Bundler.ui.confirm "Pushed git commits and tags."
|
98
|
+
end
|
99
|
+
|
100
|
+
def perform_git_push(options = '')
|
101
|
+
cmd = "git push #{options}"
|
102
|
+
out, code = sh_with_code(cmd)
|
103
|
+
raise "Couldn't git push. `#{cmd}' failed with the following output:\n\n#{out}\n" unless code == 0
|
104
|
+
end
|
105
|
+
|
106
|
+
def already_tagged?
|
107
|
+
if sh('git tag').split(/\n/).include?(version_tag)
|
108
|
+
Bundler.ui.confirm "Tag #{version_tag} has already been created."
|
109
|
+
true
|
110
|
+
end
|
111
|
+
end
|
112
|
+
|
113
|
+
def guard_clean
|
114
|
+
clean? && committed? or raise("There are files that need to be committed first.")
|
115
|
+
end
|
116
|
+
|
117
|
+
def clean?
|
118
|
+
sh_with_code("git diff --exit-code")[1] == 0
|
119
|
+
end
|
120
|
+
|
121
|
+
def committed?
|
122
|
+
sh_with_code("git diff-index --quiet --cached HEAD")[1] == 0
|
123
|
+
end
|
124
|
+
|
125
|
+
def tag_version
|
126
|
+
sh "git tag -a -m \"Version #{version}\" #{version_tag}"
|
127
|
+
Bundler.ui.confirm "Tagged #{version_tag}."
|
128
|
+
yield if block_given?
|
129
|
+
rescue
|
130
|
+
Bundler.ui.error "Untagging #{version_tag} due to error."
|
131
|
+
sh_with_code "git tag -d #{version_tag}"
|
132
|
+
raise
|
133
|
+
end
|
134
|
+
|
135
|
+
def version
|
136
|
+
gemspec.version
|
137
|
+
end
|
138
|
+
|
139
|
+
def version_tag
|
140
|
+
"v#{version}"
|
141
|
+
end
|
142
|
+
|
143
|
+
def name
|
144
|
+
gemspec.name
|
145
|
+
end
|
146
|
+
|
147
|
+
def sh(cmd, &block)
|
148
|
+
out, code = sh_with_code(cmd, &block)
|
149
|
+
code == 0 ? out : raise(out.empty? ? "Running `#{cmd}' failed. Run this command directly for more detailed output." : out)
|
150
|
+
end
|
151
|
+
|
152
|
+
def sh_with_code(cmd, &block)
|
153
|
+
cmd << " 2>&1"
|
154
|
+
outbuf = ''
|
155
|
+
Bundler.ui.debug(cmd)
|
156
|
+
SharedHelpers.chdir(base) {
|
157
|
+
outbuf = `#{cmd}`
|
158
|
+
if $? == 0
|
159
|
+
block.call(outbuf) if block
|
160
|
+
end
|
161
|
+
}
|
162
|
+
[outbuf, $?]
|
163
|
+
end
|
164
|
+
|
165
|
+
def gem_push?
|
166
|
+
! %w{n no nil false off 0}.include?(ENV['gem_push'].to_s.downcase)
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
module Bundler
|
2
|
+
module GemHelpers
|
3
|
+
|
4
|
+
GENERIC_CACHE = {}
|
5
|
+
GENERICS = [
|
6
|
+
[Gem::Platform.new('java'), Gem::Platform.new('java')],
|
7
|
+
[Gem::Platform.new('mswin32'), Gem::Platform.new('mswin32')],
|
8
|
+
[Gem::Platform.new('mswin64'), Gem::Platform.new('mswin64')],
|
9
|
+
[Gem::Platform.new('x64-mingw32'), Gem::Platform.new('x64-mingw32')],
|
10
|
+
[Gem::Platform.new('x86_64-mingw32'), Gem::Platform.new('x64-mingw32')],
|
11
|
+
[Gem::Platform.new('mingw32'), Gem::Platform.new('x86-mingw32')]
|
12
|
+
]
|
13
|
+
|
14
|
+
def generic(p)
|
15
|
+
return p if p == Gem::Platform::RUBY
|
16
|
+
|
17
|
+
GENERIC_CACHE[p] ||= begin
|
18
|
+
_, found = GENERICS.find do |match, _generic|
|
19
|
+
p.os == match.os && (!match.cpu || p.cpu == match.cpu)
|
20
|
+
end
|
21
|
+
found || Gem::Platform::RUBY
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
module Bundler
|
2
|
+
def self.preserve_gem_path
|
3
|
+
original_gem_path = ENV["_ORIGINAL_GEM_PATH"]
|
4
|
+
gem_path = ENV["GEM_PATH"]
|
5
|
+
ENV["_ORIGINAL_GEM_PATH"] = gem_path if original_gem_path.nil? || original_gem_path == ""
|
6
|
+
ENV["GEM_PATH"] = original_gem_path if gem_path.nil? || gem_path == ""
|
7
|
+
end
|
8
|
+
end
|
@@ -0,0 +1,169 @@
|
|
1
|
+
require 'set'
|
2
|
+
module Bundler
|
3
|
+
class Graph
|
4
|
+
GRAPH_NAME = :Gemfile
|
5
|
+
|
6
|
+
def initialize(env, output_file, show_version = false, show_requirements = false, output_format = "png", without = [])
|
7
|
+
@env = env
|
8
|
+
@output_file = output_file
|
9
|
+
@show_version = show_version
|
10
|
+
@show_requirements = show_requirements
|
11
|
+
@output_format = output_format
|
12
|
+
@without_groups = without.map(&:to_sym)
|
13
|
+
|
14
|
+
@groups = []
|
15
|
+
@relations = Hash.new {|h, k| h[k] = Set.new}
|
16
|
+
@node_options = {}
|
17
|
+
@edge_options = {}
|
18
|
+
|
19
|
+
_patching_gem_dependency_class
|
20
|
+
_populate_relations
|
21
|
+
end
|
22
|
+
|
23
|
+
attr_reader :groups, :relations, :node_options, :edge_options, :output_file, :output_format
|
24
|
+
|
25
|
+
def viz
|
26
|
+
GraphVizClient.new(self).run
|
27
|
+
end
|
28
|
+
|
29
|
+
private
|
30
|
+
|
31
|
+
def _populate_relations
|
32
|
+
parent_dependencies = _groups.values.to_set.flatten
|
33
|
+
while true
|
34
|
+
if parent_dependencies.empty?
|
35
|
+
break
|
36
|
+
else
|
37
|
+
tmp = Set.new
|
38
|
+
parent_dependencies.each do |dependency|
|
39
|
+
child_dependencies = dependency.to_spec.runtime_dependencies.to_set
|
40
|
+
@relations[dependency.name] += child_dependencies.map(&:name).to_set
|
41
|
+
tmp += child_dependencies
|
42
|
+
|
43
|
+
@node_options[dependency.name] = _make_label(dependency, :node)
|
44
|
+
child_dependencies.each do |c_dependency|
|
45
|
+
@edge_options["#{dependency.name}_#{c_dependency.name}"] = _make_label(c_dependency, :edge)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
parent_dependencies = tmp
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def _groups
|
54
|
+
relations = Hash.new {|h, k| h[k] = Set.new}
|
55
|
+
@env.current_dependencies.each do |dependency|
|
56
|
+
dependency.groups.each do |group|
|
57
|
+
next if @without_groups.include?(group)
|
58
|
+
|
59
|
+
relations[group.to_s].add(dependency)
|
60
|
+
@relations[group.to_s].add(dependency.name)
|
61
|
+
|
62
|
+
@node_options[group.to_s] ||= _make_label(group, :node)
|
63
|
+
@edge_options["#{group}_#{dependency.name}"] = _make_label(dependency, :edge)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
@groups = relations.keys
|
67
|
+
relations
|
68
|
+
end
|
69
|
+
|
70
|
+
def _make_label(symbol_or_string_or_dependency, element_type)
|
71
|
+
case element_type.to_sym
|
72
|
+
when :node
|
73
|
+
if symbol_or_string_or_dependency.is_a?(Gem::Dependency)
|
74
|
+
label = symbol_or_string_or_dependency.name.dup
|
75
|
+
label << "\n#{symbol_or_string_or_dependency.to_spec.version.to_s}" if @show_version
|
76
|
+
else
|
77
|
+
label = symbol_or_string_or_dependency.to_s
|
78
|
+
end
|
79
|
+
when :edge
|
80
|
+
label = nil
|
81
|
+
if symbol_or_string_or_dependency.respond_to?(:requirements_list) && @show_requirements
|
82
|
+
tmp = symbol_or_string_or_dependency.requirements_list.join(", ")
|
83
|
+
label = tmp if tmp != ">= 0"
|
84
|
+
end
|
85
|
+
else
|
86
|
+
raise ArgumentError, "2nd argument is invalid"
|
87
|
+
end
|
88
|
+
label.nil? ? {} : { :label => label }
|
89
|
+
end
|
90
|
+
|
91
|
+
def _patching_gem_dependency_class
|
92
|
+
# method borrow from rubygems/dependency.rb
|
93
|
+
# redefinition of matching_specs will also redefine to_spec and to_specs
|
94
|
+
Gem::Dependency.class_eval do
|
95
|
+
def matching_specs platform_only = false
|
96
|
+
matches = Bundler.load.specs.select { |spec|
|
97
|
+
self.name == spec.name and
|
98
|
+
requirement.satisfied_by? spec.version
|
99
|
+
}
|
100
|
+
|
101
|
+
if platform_only
|
102
|
+
matches.reject! { |spec|
|
103
|
+
not Gem::Platform.match spec.platform
|
104
|
+
}
|
105
|
+
end
|
106
|
+
|
107
|
+
matches = matches.sort_by { |s| s.sort_obj } # HACK: shouldn't be needed
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
class GraphVizClient
|
113
|
+
def initialize(graph_instance)
|
114
|
+
@graph_name = graph_instance.class::GRAPH_NAME
|
115
|
+
@groups = graph_instance.groups
|
116
|
+
@relations = graph_instance.relations
|
117
|
+
@node_options = graph_instance.node_options
|
118
|
+
@edge_options = graph_instance.edge_options
|
119
|
+
@output_file = graph_instance.output_file
|
120
|
+
@output_format = graph_instance.output_format
|
121
|
+
end
|
122
|
+
|
123
|
+
def g
|
124
|
+
@g ||= ::GraphViz.digraph(@graph_name, {:concentrate => true, :normalize => true, :nodesep => 0.55}) do |g|
|
125
|
+
g.edge[:weight] = 2
|
126
|
+
g.edge[:fontname] = g.node[:fontname] = 'Arial, Helvetica, SansSerif'
|
127
|
+
g.edge[:fontsize] = 12
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def run
|
132
|
+
@groups.each do |group|
|
133
|
+
g.add_nodes(
|
134
|
+
group,
|
135
|
+
{:style => 'filled',
|
136
|
+
:fillcolor => '#B9B9D5',
|
137
|
+
:shape => "box3d",
|
138
|
+
:fontsize => 16}.merge(@node_options[group])
|
139
|
+
)
|
140
|
+
end
|
141
|
+
|
142
|
+
@relations.each do |parent, children|
|
143
|
+
children.each do |child|
|
144
|
+
if @groups.include?(parent)
|
145
|
+
g.add_nodes(child, {:style => 'filled', :fillcolor => '#B9B9D5'}.merge(@node_options[child]))
|
146
|
+
g.add_edges(parent, child, {:constraint => false}.merge(@edge_options["#{parent}_#{child}"]))
|
147
|
+
else
|
148
|
+
g.add_nodes(child, @node_options[child])
|
149
|
+
g.add_edges(parent, child, @edge_options["#{parent}_#{child}"])
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
if @output_format.to_s == "debug"
|
155
|
+
$stdout.puts g.output :none => String
|
156
|
+
Bundler.ui.info "debugging bundle viz..."
|
157
|
+
else
|
158
|
+
begin
|
159
|
+
g.output @output_format.to_sym => "#{@output_file}.#{@output_format}"
|
160
|
+
Bundler.ui.info "#{@output_file}.#{@output_format}"
|
161
|
+
rescue ArgumentError => e
|
162
|
+
$stderr.puts "Unsupported output format. See Ruby-Graphviz/lib/graphviz/constants.rb"
|
163
|
+
raise e
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
end
|
@@ -0,0 +1,184 @@
|
|
1
|
+
require "set"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Index
|
5
|
+
include Enumerable
|
6
|
+
|
7
|
+
def self.build
|
8
|
+
i = new
|
9
|
+
yield i
|
10
|
+
i
|
11
|
+
end
|
12
|
+
|
13
|
+
attr_reader :specs, :sources
|
14
|
+
protected :specs
|
15
|
+
|
16
|
+
def initialize
|
17
|
+
@sources = []
|
18
|
+
@cache = {}
|
19
|
+
@specs = Hash.new { |h,k| h[k] = Hash.new }
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize_copy(o)
|
23
|
+
super
|
24
|
+
@sources = @sources.dup
|
25
|
+
@cache = {}
|
26
|
+
@specs = Hash.new { |h,k| h[k] = Hash.new }
|
27
|
+
|
28
|
+
o.specs.each do |name, hash|
|
29
|
+
@specs[name] = hash.dup
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def inspect
|
34
|
+
"#<#{self.class}:0x#{object_id} sources=#{sources.map{|s| s.inspect}} specs.size=#{specs.size}>"
|
35
|
+
end
|
36
|
+
|
37
|
+
def empty?
|
38
|
+
each { return false }
|
39
|
+
true
|
40
|
+
end
|
41
|
+
|
42
|
+
# Search this index's specs, and any source indexes that this index knows
|
43
|
+
# about, returning all of the results.
|
44
|
+
def search(query, base = nil)
|
45
|
+
results = local_search(query, base)
|
46
|
+
seen = Set.new(results.map { |spec| [spec.name, spec.version, spec.platform] })
|
47
|
+
|
48
|
+
@sources.each do |source|
|
49
|
+
source.search(query, base).each do |spec|
|
50
|
+
lookup = [spec.name, spec.version, spec.platform]
|
51
|
+
unless seen.include?(lookup)
|
52
|
+
results << spec
|
53
|
+
seen << lookup
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
results
|
59
|
+
end
|
60
|
+
|
61
|
+
def local_search(query, base = nil)
|
62
|
+
case query
|
63
|
+
when Gem::Specification, RemoteSpecification, LazySpecification, EndpointSpecification then search_by_spec(query)
|
64
|
+
when String then specs_by_name(query)
|
65
|
+
when Gem::Dependency then search_by_dependency(query, base)
|
66
|
+
else
|
67
|
+
raise "You can't search for a #{query.inspect}."
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def source_types
|
72
|
+
sources.map{|s| s.class }.uniq
|
73
|
+
end
|
74
|
+
|
75
|
+
alias [] search
|
76
|
+
|
77
|
+
def <<(spec)
|
78
|
+
@specs[spec.name]["#{spec.version}-#{spec.platform}"] = spec
|
79
|
+
|
80
|
+
spec
|
81
|
+
end
|
82
|
+
|
83
|
+
def each(&blk)
|
84
|
+
specs.values.each do |spec_sets|
|
85
|
+
spec_sets.values.each(&blk)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
# returns a list of the dependencies
|
90
|
+
def unmet_dependency_names
|
91
|
+
dependency_names = specs.values.map do |hash_of_s|
|
92
|
+
hash_of_s.values.map do |s|
|
93
|
+
s.dependencies.map{|d| d.name }
|
94
|
+
end
|
95
|
+
end.flatten.uniq
|
96
|
+
dependency_names.select{|name| name != 'bundler' && specs_by_name(name).empty? }
|
97
|
+
end
|
98
|
+
|
99
|
+
def use(other, override_dupes = false)
|
100
|
+
return unless other
|
101
|
+
other.each do |s|
|
102
|
+
if (dupes = search_by_spec(s)) && dupes.any?
|
103
|
+
next unless override_dupes
|
104
|
+
self << s
|
105
|
+
end
|
106
|
+
self << s
|
107
|
+
end
|
108
|
+
self
|
109
|
+
end
|
110
|
+
|
111
|
+
def size
|
112
|
+
@sources.inject(@specs.size) do |size, source|
|
113
|
+
size += source.size
|
114
|
+
end
|
115
|
+
end
|
116
|
+
|
117
|
+
def ==(o)
|
118
|
+
all? do |spec|
|
119
|
+
other_spec = o[spec].first
|
120
|
+
(spec.dependencies & other_spec.dependencies).empty? && spec.source == other_spec.source
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
def add_source(index)
|
125
|
+
if index.is_a?(Index)
|
126
|
+
@sources << index
|
127
|
+
@sources.uniq! # need to use uniq! here instead of checking for the item before adding
|
128
|
+
else
|
129
|
+
raise ArgumentError, "Source must be an index, not #{index.class}"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
private
|
134
|
+
|
135
|
+
def specs_by_name(name)
|
136
|
+
@specs[name].values
|
137
|
+
end
|
138
|
+
|
139
|
+
def search_by_dependency(dependency, base = nil)
|
140
|
+
@cache[base || false] ||= {}
|
141
|
+
@cache[base || false][dependency] ||= begin
|
142
|
+
specs = specs_by_name(dependency.name) + (base || [])
|
143
|
+
found = specs.select do |spec|
|
144
|
+
if base # allow all platforms when searching from a lockfile
|
145
|
+
dependency.matches_spec?(spec)
|
146
|
+
else
|
147
|
+
dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform)
|
148
|
+
end
|
149
|
+
end
|
150
|
+
|
151
|
+
wants_prerelease = dependency.requirement.prerelease?
|
152
|
+
only_prerelease = specs.all? {|spec| spec.version.prerelease? }
|
153
|
+
|
154
|
+
unless wants_prerelease || only_prerelease
|
155
|
+
found.reject! { |spec| spec.version.prerelease? }
|
156
|
+
end
|
157
|
+
|
158
|
+
found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def search_by_spec(spec)
|
163
|
+
spec = @specs[spec.name]["#{spec.version}-#{spec.platform}"]
|
164
|
+
spec ? [spec] : []
|
165
|
+
end
|
166
|
+
|
167
|
+
if RUBY_VERSION < '1.9'
|
168
|
+
def same_version?(a, b)
|
169
|
+
regex = /^(.*?)(?:\.0)*$/
|
170
|
+
a.to_s[regex, 1] == b.to_s[regex, 1]
|
171
|
+
end
|
172
|
+
else
|
173
|
+
def same_version?(a, b)
|
174
|
+
a == b
|
175
|
+
end
|
176
|
+
end
|
177
|
+
|
178
|
+
def spec_satisfies_dependency?(spec, dep)
|
179
|
+
return false unless dep.name == spec.name
|
180
|
+
dep.requirement.satisfied_by?(spec.version)
|
181
|
+
end
|
182
|
+
|
183
|
+
end
|
184
|
+
end
|