rkh-bundler 1.2.0.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +22 -0
- data/.travis.yml +42 -0
- data/CHANGELOG.md +1105 -0
- data/ISSUES.md +67 -0
- data/LICENSE +23 -0
- data/README.md +31 -0
- data/Rakefile +208 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +31 -0
- data/bundler.gemspec +31 -0
- data/lib/bundler.rb +353 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +693 -0
- data/lib/bundler/definition.rb +568 -0
- data/lib/bundler/dep_proxy.rb +43 -0
- data/lib/bundler/dependency.rb +134 -0
- data/lib/bundler/deployment.rb +58 -0
- data/lib/bundler/dsl.rb +256 -0
- data/lib/bundler/endpoint_specification.rb +78 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/fetcher.rb +225 -0
- data/lib/bundler/gem_helper.rb +162 -0
- data/lib/bundler/gem_helpers.rb +23 -0
- data/lib/bundler/gem_installer.rb +9 -0
- data/lib/bundler/gem_tasks.rb +2 -0
- data/lib/bundler/graph.rb +148 -0
- data/lib/bundler/index.rb +187 -0
- data/lib/bundler/installer.rb +190 -0
- data/lib/bundler/lazy_specification.rb +79 -0
- data/lib/bundler/lockfile_parser.rb +127 -0
- data/lib/bundler/match_platform.rb +13 -0
- data/lib/bundler/psyched_yaml.rb +15 -0
- data/lib/bundler/remote_specification.rb +57 -0
- data/lib/bundler/resolver.rb +486 -0
- data/lib/bundler/ruby_version.rb +94 -0
- data/lib/bundler/rubygems_ext.rb +153 -0
- data/lib/bundler/rubygems_integration.rb +394 -0
- data/lib/bundler/runtime.rb +233 -0
- data/lib/bundler/settings.rb +128 -0
- data/lib/bundler/setup.rb +23 -0
- data/lib/bundler/shared_helpers.rb +71 -0
- data/lib/bundler/source.rb +869 -0
- data/lib/bundler/spec_set.rb +137 -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/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
- data/lib/bundler/templates/newgem/README.md.tt +29 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/gitignore.tt +17 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
- data/lib/bundler/ui.rb +88 -0
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +468 -0
- data/lib/bundler/vendor/thor.rb +358 -0
- data/lib/bundler/vendor/thor/actions.rb +314 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
- data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
- data/lib/bundler/vendor/thor/base.rb +576 -0
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/bundler/vendor/thor/error.rb +30 -0
- data/lib/bundler/vendor/thor/group.rb +273 -0
- data/lib/bundler/vendor/thor/invocation.rb +168 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
- data/lib/bundler/vendor/thor/parser/option.rb +120 -0
- data/lib/bundler/vendor/thor/parser/options.rb +172 -0
- data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
- data/lib/bundler/vendor/thor/runner.rb +309 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
- data/lib/bundler/vendor/thor/shell/color.rb +108 -0
- data/lib/bundler/vendor/thor/shell/html.rb +121 -0
- data/lib/bundler/vendor/thor/task.rb +113 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/vendored_thor.rb +7 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +11 -0
- data/man/bundle-config.ronn +130 -0
- data/man/bundle-exec.ronn +111 -0
- data/man/bundle-install.ronn +335 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +83 -0
- data/man/gemfile.5.ronn +324 -0
- data/man/index.txt +6 -0
- data/spec/bundler/dsl_spec.rb +48 -0
- data/spec/bundler/gem_helper_spec.rb +174 -0
- data/spec/bundler/source_spec.rb +25 -0
- data/spec/cache/gems_spec.rb +239 -0
- data/spec/cache/git_spec.rb +124 -0
- data/spec/cache/path_spec.rb +103 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +211 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/dependency_api_spec.rb +402 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +313 -0
- data/spec/install/gems/groups_spec.rb +268 -0
- data/spec/install/gems/packed_spec.rb +84 -0
- data/spec/install/gems/platform_spec.rb +208 -0
- data/spec/install/gems/post_install_spec.rb +47 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +814 -0
- data/spec/install/gems/standalone_spec.rb +260 -0
- data/spec/install/gems/sudo_spec.rb +74 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +170 -0
- data/spec/install/git_spec.rb +796 -0
- data/spec/install/invalid_spec.rb +35 -0
- data/spec/install/path_spec.rb +405 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/lock/lockfile_spec.rb +809 -0
- data/spec/other/check_spec.rb +265 -0
- data/spec/other/clean_spec.rb +492 -0
- data/spec/other/config_spec.rb +138 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +229 -0
- data/spec/other/ext_spec.rb +37 -0
- data/spec/other/help_spec.rb +39 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +87 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/outdated_spec.rb +93 -0
- data/spec/other/platform_spec.rb +881 -0
- data/spec/other/show_spec.rb +88 -0
- data/spec/quality_spec.rb +62 -0
- data/spec/realworld/edgecases_spec.rb +177 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +82 -0
- data/spec/runtime/executable_spec.rb +120 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +261 -0
- data/spec/runtime/setup_spec.rb +755 -0
- data/spec/runtime/with_clean_env_spec.rb +80 -0
- data/spec/spec_helper.rb +98 -0
- data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
- data/spec/support/artifice/endpoint.rb +54 -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_extra.rb +27 -0
- data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
- data/spec/support/artifice/endpoint_fallback.rb +18 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +15 -0
- data/spec/support/builders.rb +604 -0
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +317 -0
- data/spec/support/indexes.rb +112 -0
- data/spec/support/matchers.rb +77 -0
- data/spec/support/path.rb +73 -0
- data/spec/support/platforms.rb +86 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +37 -0
- data/spec/support/rubygems_hax/platform.rb +22 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +134 -0
- data/spec/update/git_spec.rb +196 -0
- data/spec/update/source_spec.rb +51 -0
- metadata +338 -0
@@ -0,0 +1,233 @@
|
|
1
|
+
require "digest/sha1"
|
2
|
+
|
3
|
+
module Bundler
|
4
|
+
class Runtime < Environment
|
5
|
+
include SharedHelpers
|
6
|
+
|
7
|
+
def setup(*groups)
|
8
|
+
# Has to happen first
|
9
|
+
clean_load_path
|
10
|
+
|
11
|
+
specs = groups.any? ? @definition.specs_for(groups) : requested_specs
|
12
|
+
|
13
|
+
setup_environment
|
14
|
+
Bundler.rubygems.replace_entrypoints(specs)
|
15
|
+
|
16
|
+
# Activate the specs
|
17
|
+
specs.each do |spec|
|
18
|
+
unless spec.loaded_from
|
19
|
+
raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
|
20
|
+
end
|
21
|
+
|
22
|
+
if activated_spec = Bundler.rubygems.loaded_specs(spec.name) and activated_spec.version != spec.version
|
23
|
+
e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, " \
|
24
|
+
"but your Gemfile requires #{spec.name} #{spec.version}. Using bundle exec may solve this."
|
25
|
+
e.name = spec.name
|
26
|
+
if e.respond_to?(:requirement=)
|
27
|
+
e.requirement = Gem::Requirement.new(spec.version.to_s)
|
28
|
+
else
|
29
|
+
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
|
30
|
+
end
|
31
|
+
raise e
|
32
|
+
end
|
33
|
+
|
34
|
+
Bundler.rubygems.mark_loaded(spec)
|
35
|
+
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
|
36
|
+
$LOAD_PATH.unshift(*load_paths)
|
37
|
+
end
|
38
|
+
|
39
|
+
lock
|
40
|
+
|
41
|
+
self
|
42
|
+
end
|
43
|
+
|
44
|
+
REGEXPS = [
|
45
|
+
/^no such file to load -- (.+)$/i,
|
46
|
+
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
|
47
|
+
/^Missing API definition file in (.+)$/i,
|
48
|
+
/^cannot load such file -- (.+)$/i,
|
49
|
+
]
|
50
|
+
|
51
|
+
def require(*groups)
|
52
|
+
groups.map! { |g| g.to_sym }
|
53
|
+
groups = [:default] if groups.empty?
|
54
|
+
|
55
|
+
@definition.dependencies.each do |dep|
|
56
|
+
# Skip the dependency if it is not in any of the requested
|
57
|
+
# groups
|
58
|
+
next unless ((dep.groups & groups).any? && dep.current_platform?)
|
59
|
+
|
60
|
+
required_file = nil
|
61
|
+
|
62
|
+
begin
|
63
|
+
# Loop through all the specified autorequires for the
|
64
|
+
# dependency. If there are none, use the dependency's name
|
65
|
+
# as the autorequire.
|
66
|
+
Array(dep.autorequire || dep.name).each do |file|
|
67
|
+
required_file = file
|
68
|
+
Kernel.require file
|
69
|
+
end
|
70
|
+
rescue LoadError => e
|
71
|
+
if dep.autorequire.nil? && dep.name.include?('-')
|
72
|
+
begin
|
73
|
+
namespaced_file = dep.name.gsub('-', '/')
|
74
|
+
Kernel.require namespaced_file
|
75
|
+
rescue LoadError
|
76
|
+
REGEXPS.find { |r| r =~ e.message }
|
77
|
+
raise if dep.autorequire || $1.gsub('-', '/') != namespaced_file
|
78
|
+
end
|
79
|
+
else
|
80
|
+
REGEXPS.find { |r| r =~ e.message }
|
81
|
+
raise if dep.autorequire || $1 != required_file
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def dependencies_for(*groups)
|
88
|
+
if groups.empty?
|
89
|
+
dependencies
|
90
|
+
else
|
91
|
+
dependencies.select { |d| (groups & d.groups).any? }
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
alias gems specs
|
96
|
+
|
97
|
+
def cache
|
98
|
+
FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path)
|
99
|
+
|
100
|
+
Bundler.ui.info "Updating files in vendor/cache"
|
101
|
+
specs.each do |spec|
|
102
|
+
next if spec.name == 'bundler'
|
103
|
+
spec.source.cache(spec) if spec.source.respond_to?(:cache)
|
104
|
+
end
|
105
|
+
prune_cache unless Bundler.settings[:no_prune]
|
106
|
+
end
|
107
|
+
|
108
|
+
def prune_cache
|
109
|
+
FileUtils.mkdir_p(cache_path) unless File.exists?(cache_path)
|
110
|
+
|
111
|
+
resolve = @definition.resolve
|
112
|
+
cached = Dir["#{cache_path}/*.gem"]
|
113
|
+
|
114
|
+
cached = cached.delete_if do |path|
|
115
|
+
spec = Bundler.rubygems.spec_from_gem path
|
116
|
+
|
117
|
+
resolve.any? do |s|
|
118
|
+
s.name == spec.name && s.version == spec.version && !s.source.is_a?(Bundler::Source::Git)
|
119
|
+
end
|
120
|
+
end
|
121
|
+
|
122
|
+
if cached.any?
|
123
|
+
Bundler.ui.info "Removing outdated .gem files from vendor/cache"
|
124
|
+
|
125
|
+
cached.each do |path|
|
126
|
+
Bundler.ui.info " * #{File.basename(path)}"
|
127
|
+
File.delete(path)
|
128
|
+
end
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
def clean
|
133
|
+
gem_bins = Dir["#{Gem.dir}/bin/*"]
|
134
|
+
git_dirs = Dir["#{Gem.dir}/bundler/gems/*"]
|
135
|
+
git_cache_dirs = Dir["#{Gem.dir}/cache/bundler/git/*"]
|
136
|
+
gem_dirs = Dir["#{Gem.dir}/gems/*"]
|
137
|
+
gem_files = Dir["#{Gem.dir}/cache/*.gem"]
|
138
|
+
gemspec_files = Dir["#{Gem.dir}/specifications/*.gemspec"]
|
139
|
+
spec_gem_paths = []
|
140
|
+
spec_git_paths = []
|
141
|
+
spec_git_cache_dirs = []
|
142
|
+
spec_gem_executables = []
|
143
|
+
spec_cache_paths = []
|
144
|
+
spec_gemspec_paths = []
|
145
|
+
specs.each do |spec|
|
146
|
+
spec_gem_paths << spec.full_gem_path
|
147
|
+
# need to check here in case gems are nested like for the rails git repo
|
148
|
+
md = %r{(.+bundler/gems/.+-[a-f0-9]{7,12})}.match(spec.full_gem_path)
|
149
|
+
spec_git_paths << md[1] if md
|
150
|
+
spec_gem_executables << spec.executables.collect do |executable|
|
151
|
+
"#{Bundler.rubygems.gem_bindir}/#{executable}"
|
152
|
+
end
|
153
|
+
spec_cache_paths << spec.cache_file
|
154
|
+
spec_gemspec_paths << spec.spec_file
|
155
|
+
spec_git_cache_dirs << spec.source.cache_path.to_s if spec.source.is_a?(Bundler::Source::Git)
|
156
|
+
end
|
157
|
+
spec_gem_paths.uniq!
|
158
|
+
spec_gem_executables.flatten!
|
159
|
+
|
160
|
+
stale_gem_bins = gem_bins - spec_gem_executables
|
161
|
+
stale_git_dirs = git_dirs - spec_git_paths
|
162
|
+
stale_git_cache_dirs = git_cache_dirs - spec_git_cache_dirs
|
163
|
+
stale_gem_dirs = gem_dirs - spec_gem_paths
|
164
|
+
stale_gem_files = gem_files - spec_cache_paths
|
165
|
+
stale_gemspec_files = gemspec_files - spec_gemspec_paths
|
166
|
+
|
167
|
+
stale_gem_bins.each {|bin| FileUtils.rm(bin) }
|
168
|
+
output = stale_gem_dirs.collect do |gem_dir|
|
169
|
+
full_name = Pathname.new(gem_dir).basename.to_s
|
170
|
+
|
171
|
+
FileUtils.rm_rf(gem_dir)
|
172
|
+
|
173
|
+
parts = full_name.split('-')
|
174
|
+
name = parts[0..-2].join('-')
|
175
|
+
version = parts.last
|
176
|
+
output = "#{name} (#{version})"
|
177
|
+
|
178
|
+
Bundler.ui.info "Removing #{output}"
|
179
|
+
|
180
|
+
output
|
181
|
+
end + stale_git_dirs.collect do |gem_dir|
|
182
|
+
full_name = Pathname.new(gem_dir).basename.to_s
|
183
|
+
|
184
|
+
FileUtils.rm_rf(gem_dir)
|
185
|
+
|
186
|
+
parts = full_name.split('-')
|
187
|
+
name = parts[0..-2].join('-')
|
188
|
+
revision = parts[-1]
|
189
|
+
output = "#{name} (#{revision})"
|
190
|
+
|
191
|
+
Bundler.ui.info "Removing #{output}"
|
192
|
+
|
193
|
+
output
|
194
|
+
end
|
195
|
+
|
196
|
+
stale_gem_files.each {|file| FileUtils.rm(file) if File.exists?(file) }
|
197
|
+
stale_gemspec_files.each {|file| FileUtils.rm(file) if File.exists?(file) }
|
198
|
+
stale_git_cache_dirs.each {|dir| FileUtils.rm_rf(dir) if File.exists?(dir) }
|
199
|
+
|
200
|
+
output
|
201
|
+
end
|
202
|
+
|
203
|
+
def setup_environment
|
204
|
+
begin
|
205
|
+
ENV["BUNDLE_BIN_PATH"] = Bundler.rubygems.bin_path("bundler", "bundle", VERSION)
|
206
|
+
rescue Gem::GemNotFoundException
|
207
|
+
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
|
208
|
+
end
|
209
|
+
|
210
|
+
# Set PATH
|
211
|
+
paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
|
212
|
+
paths.unshift "#{Bundler.bundle_path}/bin"
|
213
|
+
ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
|
214
|
+
|
215
|
+
# Set BUNDLE_GEMFILE
|
216
|
+
ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s
|
217
|
+
|
218
|
+
# Set RUBYOPT
|
219
|
+
rubyopt = [ENV["RUBYOPT"]].compact
|
220
|
+
if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
|
221
|
+
rubyopt.unshift "-rbundler/setup"
|
222
|
+
rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
|
223
|
+
ENV["RUBYOPT"] = rubyopt.join(' ')
|
224
|
+
end
|
225
|
+
end
|
226
|
+
|
227
|
+
private
|
228
|
+
|
229
|
+
def cache_path
|
230
|
+
root.join("vendor/cache")
|
231
|
+
end
|
232
|
+
end
|
233
|
+
end
|
@@ -0,0 +1,128 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Settings
|
3
|
+
def initialize(root)
|
4
|
+
@root = root
|
5
|
+
@local_config = (File.exist?(local_config_file) && yaml = YAML.load_file(local_config_file)) ? yaml : {}
|
6
|
+
@global_config = (File.exist?(global_config_file) && yaml = YAML.load_file(global_config_file)) ? yaml : {}
|
7
|
+
end
|
8
|
+
|
9
|
+
def [](key)
|
10
|
+
key = key_for(key)
|
11
|
+
@local_config[key] || ENV[key] || @global_config[key]
|
12
|
+
end
|
13
|
+
|
14
|
+
def []=(key, value)
|
15
|
+
set_key(key, value, @local_config, local_config_file)
|
16
|
+
end
|
17
|
+
|
18
|
+
alias :set_local :[]=
|
19
|
+
|
20
|
+
def delete(key)
|
21
|
+
@local_config.delete(key_for(key))
|
22
|
+
end
|
23
|
+
|
24
|
+
def set_global(key, value)
|
25
|
+
set_key(key, value, @global_config, global_config_file)
|
26
|
+
end
|
27
|
+
|
28
|
+
def all
|
29
|
+
env_keys = ENV.keys.select { |k| k =~ /BUNDLE_.*/ }
|
30
|
+
keys = @global_config.keys | @local_config.keys | env_keys
|
31
|
+
|
32
|
+
keys.map do |key|
|
33
|
+
key.sub(/^BUNDLE_/, '').gsub(/__/, ".").downcase
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def local_overrides
|
38
|
+
repos = {}
|
39
|
+
all.each do |k|
|
40
|
+
if k =~ /^local\./
|
41
|
+
repos[$'] = self[k]
|
42
|
+
end
|
43
|
+
end
|
44
|
+
repos
|
45
|
+
end
|
46
|
+
|
47
|
+
def locations(key)
|
48
|
+
key = key_for(key)
|
49
|
+
locations = {}
|
50
|
+
locations[:local] = @local_config[key] if @local_config.key?(key)
|
51
|
+
locations[:env] = ENV[key] if ENV[key]
|
52
|
+
locations[:global] = @global_config[key] if @global_config.key?(key)
|
53
|
+
locations
|
54
|
+
end
|
55
|
+
|
56
|
+
def pretty_values_for(exposed_key)
|
57
|
+
key = key_for(exposed_key)
|
58
|
+
|
59
|
+
locations = []
|
60
|
+
if @local_config.key?(key)
|
61
|
+
locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
|
62
|
+
end
|
63
|
+
|
64
|
+
if value = ENV[key]
|
65
|
+
locations << "Set via #{key}: #{value.inspect}"
|
66
|
+
end
|
67
|
+
|
68
|
+
if @global_config.key?(key)
|
69
|
+
locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
|
70
|
+
end
|
71
|
+
|
72
|
+
return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
|
73
|
+
locations
|
74
|
+
end
|
75
|
+
|
76
|
+
def without=(array)
|
77
|
+
self[:without] = (array.empty? ? nil : array.join(":")) if array
|
78
|
+
end
|
79
|
+
|
80
|
+
def without
|
81
|
+
self[:without] ? self[:without].split(":").map { |w| w.to_sym } : []
|
82
|
+
end
|
83
|
+
|
84
|
+
# @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
|
85
|
+
def path
|
86
|
+
key = key_for(:path)
|
87
|
+
path = ENV[key] || @global_config[key]
|
88
|
+
return path if path && !@local_config.key?(key)
|
89
|
+
|
90
|
+
if path = self[:path]
|
91
|
+
"#{path}/#{Bundler.ruby_scope}"
|
92
|
+
else
|
93
|
+
Bundler.rubygems.gem_dir
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def allow_sudo?
|
98
|
+
!@local_config.key?(key_for(:path))
|
99
|
+
end
|
100
|
+
|
101
|
+
private
|
102
|
+
def key_for(key)
|
103
|
+
key = key.to_s.sub(".", "__").upcase
|
104
|
+
"BUNDLE_#{key}"
|
105
|
+
end
|
106
|
+
|
107
|
+
def set_key(key, value, hash, file)
|
108
|
+
key = key_for(key)
|
109
|
+
|
110
|
+
unless hash[key] == value
|
111
|
+
hash[key] = value
|
112
|
+
hash.delete(key) if value.nil?
|
113
|
+
FileUtils.mkdir_p(file.dirname)
|
114
|
+
File.open(file, "w") { |f| f.puts hash.to_yaml }
|
115
|
+
end
|
116
|
+
value
|
117
|
+
end
|
118
|
+
|
119
|
+
def global_config_file
|
120
|
+
file = ENV["BUNDLE_CONFIG"] || File.join(Bundler.rubygems.user_home, ".bundle/config")
|
121
|
+
Pathname.new(file)
|
122
|
+
end
|
123
|
+
|
124
|
+
def local_config_file
|
125
|
+
Pathname.new("#{@root}/config")
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
require 'bundler/shared_helpers'
|
2
|
+
|
3
|
+
if Bundler::SharedHelpers.in_bundle?
|
4
|
+
require 'bundler'
|
5
|
+
if STDOUT.tty?
|
6
|
+
begin
|
7
|
+
Bundler.setup
|
8
|
+
rescue Bundler::BundlerError => e
|
9
|
+
puts "\e[31m#{e.message}\e[0m"
|
10
|
+
puts e.backtrace.join("\n") if ENV["DEBUG"]
|
11
|
+
if Bundler::GemNotFound === e
|
12
|
+
puts "\e[33mRun `bundle install` to install missing gems.\e[0m"
|
13
|
+
end
|
14
|
+
exit e.status_code
|
15
|
+
end
|
16
|
+
else
|
17
|
+
Bundler.setup
|
18
|
+
end
|
19
|
+
|
20
|
+
# Add bundler to the load path after disabling system gems
|
21
|
+
bundler_lib = File.expand_path("../..", __FILE__)
|
22
|
+
$LOAD_PATH.unshift(bundler_lib) unless $LOAD_PATH.include?(bundler_lib)
|
23
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
require 'pathname'
|
2
|
+
require 'rubygems'
|
3
|
+
|
4
|
+
require 'bundler/rubygems_integration'
|
5
|
+
|
6
|
+
module Gem
|
7
|
+
class Dependency
|
8
|
+
if !instance_methods.map { |m| m.to_s }.include?("requirement")
|
9
|
+
def requirement
|
10
|
+
version_requirements
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Bundler
|
17
|
+
module SharedHelpers
|
18
|
+
attr_accessor :gem_loaded
|
19
|
+
|
20
|
+
def default_gemfile
|
21
|
+
gemfile = find_gemfile
|
22
|
+
raise GemfileNotFound, "Could not locate Gemfile" unless gemfile
|
23
|
+
Pathname.new(gemfile)
|
24
|
+
end
|
25
|
+
|
26
|
+
def default_lockfile
|
27
|
+
Pathname.new("#{default_gemfile}.lock")
|
28
|
+
end
|
29
|
+
|
30
|
+
def in_bundle?
|
31
|
+
find_gemfile
|
32
|
+
end
|
33
|
+
|
34
|
+
private
|
35
|
+
|
36
|
+
def find_gemfile
|
37
|
+
given = ENV['BUNDLE_GEMFILE']
|
38
|
+
return given if given && !given.empty?
|
39
|
+
|
40
|
+
previous = nil
|
41
|
+
current = File.expand_path(Dir.pwd)
|
42
|
+
|
43
|
+
until !File.directory?(current) || current == previous
|
44
|
+
if ENV['BUNDLE_SPEC_RUN']
|
45
|
+
# avoid stepping above the tmp directory when testing
|
46
|
+
return nil if File.file?(File.join(current, 'bundler.gemspec'))
|
47
|
+
end
|
48
|
+
|
49
|
+
# otherwise return the Gemfile if it's there
|
50
|
+
filename = File.join(current, 'Gemfile')
|
51
|
+
return filename if File.file?(filename)
|
52
|
+
current, previous = File.expand_path("..", current), current
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def clean_load_path
|
57
|
+
# handle 1.9 where system gems are always on the load path
|
58
|
+
if defined?(::Gem)
|
59
|
+
me = File.expand_path("../../", __FILE__)
|
60
|
+
$LOAD_PATH.reject! do |p|
|
61
|
+
next if File.expand_path(p) =~ /^#{Regexp.escape(me)}/
|
62
|
+
p != File.dirname(__FILE__) &&
|
63
|
+
Bundler.rubygems.gem_path.any?{|gp| p =~ /^#{Regexp.escape(gp)}/ }
|
64
|
+
end
|
65
|
+
$LOAD_PATH.uniq!
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
extend self
|
70
|
+
end
|
71
|
+
end
|