honkster-bundler 1.1.pre
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +14 -0
- data/CHANGELOG.md +547 -0
- data/ISSUES.md +32 -0
- data/LICENSE +20 -0
- data/README.md +29 -0
- data/Rakefile +150 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +21 -0
- data/bundler.gemspec +30 -0
- data/lib/bundler.rb +268 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +515 -0
- data/lib/bundler/definition.rb +427 -0
- data/lib/bundler/dependency.rb +114 -0
- data/lib/bundler/deployment.rb +37 -0
- data/lib/bundler/dsl.rb +245 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/gem_helper.rb +145 -0
- data/lib/bundler/graph.rb +130 -0
- data/lib/bundler/index.rb +114 -0
- data/lib/bundler/installer.rb +84 -0
- data/lib/bundler/lazy_specification.rb +71 -0
- data/lib/bundler/lockfile_parser.rb +108 -0
- data/lib/bundler/remote_specification.rb +59 -0
- data/lib/bundler/resolver.rb +454 -0
- data/lib/bundler/rubygems_ext.rb +203 -0
- data/lib/bundler/runtime.rb +148 -0
- data/lib/bundler/settings.rb +117 -0
- data/lib/bundler/setup.rb +15 -0
- data/lib/bundler/shared_helpers.rb +151 -0
- data/lib/bundler/source.rb +662 -0
- data/lib/bundler/spec_set.rb +134 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -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 +3 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
- data/lib/bundler/ui.rb +60 -0
- data/lib/bundler/vendor/thor.rb +319 -0
- data/lib/bundler/vendor/thor/actions.rb +297 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -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 +229 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
- data/lib/bundler/vendor/thor/base.rb +556 -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/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 +174 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +275 -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 +114 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +9 -0
- data/man/bundle-config.ronn +90 -0
- data/man/bundle-exec.ronn +98 -0
- data/man/bundle-install.ronn +310 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +77 -0
- data/man/gemfile.5.ronn +273 -0
- data/man/index.txt +6 -0
- data/spec/cache/gems_spec.rb +205 -0
- data/spec/cache/git_spec.rb +9 -0
- data/spec/cache/path_spec.rb +27 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +197 -0
- data/spec/install/deprecated_spec.rb +43 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +272 -0
- data/spec/install/gems/groups_spec.rb +228 -0
- data/spec/install/gems/packed_spec.rb +72 -0
- data/spec/install/gems/platform_spec.rb +195 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +749 -0
- data/spec/install/gems/sudo_spec.rb +77 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +96 -0
- data/spec/install/git_spec.rb +553 -0
- data/spec/install/invalid_spec.rb +17 -0
- data/spec/install/path_spec.rb +329 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/flex_spec.rb +650 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/other/check_spec.rb +221 -0
- data/spec/other/config_spec.rb +40 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +241 -0
- data/spec/other/ext_spec.rb +16 -0
- data/spec/other/gem_helper_spec.rb +126 -0
- data/spec/other/help_spec.rb +36 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +24 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/show_spec.rb +82 -0
- data/spec/pack/gems_spec.rb +22 -0
- data/spec/quality_spec.rb +55 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +57 -0
- data/spec/runtime/environment_rb_spec.rb +162 -0
- data/spec/runtime/executable_spec.rb +110 -0
- data/spec/runtime/load_spec.rb +102 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +231 -0
- data/spec/runtime/setup_spec.rb +412 -0
- data/spec/runtime/with_clean_env_spec.rb +15 -0
- data/spec/spec_helper.rb +82 -0
- data/spec/support/builders.rb +566 -0
- data/spec/support/helpers.rb +243 -0
- data/spec/support/indexes.rb +113 -0
- data/spec/support/matchers.rb +89 -0
- data/spec/support/path.rb +71 -0
- data/spec/support/platforms.rb +49 -0
- data/spec/support/ruby_ext.rb +19 -0
- data/spec/support/rubygems_ext.rb +30 -0
- data/spec/support/rubygems_hax/rubygems_plugin.rb +9 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +112 -0
- data/spec/update/git_spec.rb +159 -0
- data/spec/update/source_spec.rb +50 -0
- metadata +251 -0
@@ -0,0 +1,203 @@
|
|
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
|
+
|
11
|
+
module Gem
|
12
|
+
@loaded_stacks = Hash.new { |h,k| h[k] = [] }
|
13
|
+
|
14
|
+
class Specification
|
15
|
+
attr_accessor :source, :location, :relative_loaded_from
|
16
|
+
|
17
|
+
alias_method :rg_full_gem_path, :full_gem_path
|
18
|
+
alias_method :rg_loaded_from, :loaded_from
|
19
|
+
|
20
|
+
def full_gem_path
|
21
|
+
source.respond_to?(:path) ?
|
22
|
+
Pathname.new(loaded_from).dirname.expand_path.to_s :
|
23
|
+
rg_full_gem_path
|
24
|
+
end
|
25
|
+
|
26
|
+
def loaded_from
|
27
|
+
relative_loaded_from ?
|
28
|
+
source.path.join(relative_loaded_from).to_s :
|
29
|
+
rg_loaded_from
|
30
|
+
end
|
31
|
+
|
32
|
+
def load_paths
|
33
|
+
require_paths.map do |require_path|
|
34
|
+
if require_path.include?(full_gem_path)
|
35
|
+
require_path
|
36
|
+
else
|
37
|
+
File.join(full_gem_path, require_path)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def groups
|
43
|
+
@groups ||= []
|
44
|
+
end
|
45
|
+
|
46
|
+
def git_version
|
47
|
+
if @loaded_from && File.exist?(File.join(full_gem_path, ".git"))
|
48
|
+
sha = Dir.chdir(full_gem_path){ `git rev-parse HEAD`.strip }
|
49
|
+
" #{sha[0..6]}"
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def to_gemfile(path = nil)
|
54
|
+
gemfile = "source :gemcutter\n"
|
55
|
+
gemfile << dependencies_to_gemfile(nondevelopment_dependencies)
|
56
|
+
unless development_dependencies.empty?
|
57
|
+
gemfile << "\n"
|
58
|
+
gemfile << dependencies_to_gemfile(development_dependencies, :development)
|
59
|
+
end
|
60
|
+
gemfile
|
61
|
+
end
|
62
|
+
|
63
|
+
def nondevelopment_dependencies
|
64
|
+
dependencies - development_dependencies
|
65
|
+
end
|
66
|
+
|
67
|
+
def add_bundler_dependencies(*groups)
|
68
|
+
Bundler.ui.warn "#add_bundler_dependencies is deprecated and will " \
|
69
|
+
"be removed in Bundler 1.0. Instead, please use the #gemspec method " \
|
70
|
+
"in your Gemfile, which will pull in any dependencies specified in " \
|
71
|
+
"your gemspec"
|
72
|
+
|
73
|
+
groups = [:default] if groups.empty?
|
74
|
+
Bundler.definition.dependencies.each do |dep|
|
75
|
+
if dep.groups.include?(:development)
|
76
|
+
self.add_development_dependency(dep.name, dep.requirement.to_s)
|
77
|
+
elsif (dep.groups & groups).any?
|
78
|
+
self.add_dependency(dep.name, dep.requirement.to_s)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def dependencies_to_gemfile(dependencies, group = nil)
|
86
|
+
gemfile = ''
|
87
|
+
if dependencies.any?
|
88
|
+
gemfile << "group :#{group} do\n" if group
|
89
|
+
dependencies.each do |dependency|
|
90
|
+
gemfile << ' ' if group
|
91
|
+
gemfile << %|gem "#{dependency.name}"|
|
92
|
+
req = dependency.requirements_list.first
|
93
|
+
gemfile << %|, "#{req}"| if req
|
94
|
+
gemfile << "\n"
|
95
|
+
end
|
96
|
+
gemfile << "end\n" if group
|
97
|
+
end
|
98
|
+
gemfile
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
102
|
+
|
103
|
+
class Dependency
|
104
|
+
attr_accessor :source, :groups
|
105
|
+
|
106
|
+
alias eql? ==
|
107
|
+
|
108
|
+
def to_yaml_properties
|
109
|
+
instance_variables.reject { |p| ["@source", "@groups"].include?(p.to_s) }
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_lock
|
113
|
+
out = " #{name}"
|
114
|
+
unless requirement == Gem::Requirement.default
|
115
|
+
out << " (#{requirement.to_s})"
|
116
|
+
end
|
117
|
+
out
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
class Platform
|
122
|
+
JAVA = Gem::Platform.new('java')
|
123
|
+
MSWIN = Gem::Platform.new('mswin32')
|
124
|
+
MING = Gem::Platform.new('x86-mingw32')
|
125
|
+
|
126
|
+
def hash
|
127
|
+
@cpu.hash ^ @os.hash ^ @version.hash
|
128
|
+
end
|
129
|
+
|
130
|
+
alias eql? ==
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
module Bundler
|
135
|
+
class DepProxy
|
136
|
+
|
137
|
+
attr_reader :required_by, :__platform, :dep
|
138
|
+
|
139
|
+
def initialize(dep, platform)
|
140
|
+
@dep, @__platform, @required_by = dep, platform, []
|
141
|
+
end
|
142
|
+
|
143
|
+
def hash
|
144
|
+
@hash ||= dep.hash
|
145
|
+
end
|
146
|
+
|
147
|
+
def ==(o)
|
148
|
+
dep == o.dep && __platform == o.__platform
|
149
|
+
end
|
150
|
+
|
151
|
+
alias eql? ==
|
152
|
+
|
153
|
+
def type
|
154
|
+
@dep.type
|
155
|
+
end
|
156
|
+
|
157
|
+
def to_s
|
158
|
+
@dep.to_s
|
159
|
+
end
|
160
|
+
|
161
|
+
private
|
162
|
+
|
163
|
+
def method_missing(*args)
|
164
|
+
@dep.send(*args)
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
module GemHelpers
|
170
|
+
|
171
|
+
GENERIC_CACHE = {}
|
172
|
+
GENERICS = [
|
173
|
+
Gem::Platform::JAVA,
|
174
|
+
Gem::Platform::MSWIN,
|
175
|
+
Gem::Platform::MING,
|
176
|
+
Gem::Platform::RUBY
|
177
|
+
]
|
178
|
+
|
179
|
+
def generic(p)
|
180
|
+
if p == Gem::Platform::RUBY
|
181
|
+
return p
|
182
|
+
end
|
183
|
+
|
184
|
+
GENERIC_CACHE[p] ||= GENERICS.find { |p2| p =~ p2 } || Gem::Platform::RUBY
|
185
|
+
end
|
186
|
+
end
|
187
|
+
|
188
|
+
module MatchPlatform
|
189
|
+
include GemHelpers
|
190
|
+
|
191
|
+
def match_platform(p)
|
192
|
+
Gem::Platform::RUBY == platform or
|
193
|
+
platform.nil? or p == platform or
|
194
|
+
generic(Gem::Platform.new(platform)) == p
|
195
|
+
end
|
196
|
+
end
|
197
|
+
end
|
198
|
+
|
199
|
+
module Gem
|
200
|
+
class Specification
|
201
|
+
include Bundler::MatchPlatform
|
202
|
+
end
|
203
|
+
end
|
@@ -0,0 +1,148 @@
|
|
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
|
+
cripple_rubygems(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 = Gem.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}. Consider using bundle exec."
|
25
|
+
e.name = spec.name
|
26
|
+
e.version_requirement = Gem::Requirement.new(spec.version.to_s)
|
27
|
+
raise e
|
28
|
+
end
|
29
|
+
|
30
|
+
Gem.loaded_specs[spec.name] = spec
|
31
|
+
load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
|
32
|
+
$LOAD_PATH.unshift(*load_paths)
|
33
|
+
end
|
34
|
+
|
35
|
+
lock
|
36
|
+
|
37
|
+
self
|
38
|
+
end
|
39
|
+
|
40
|
+
REGEXPS = [
|
41
|
+
/^no such file to load -- (.+)$/i,
|
42
|
+
/^Missing \w+ (?:file\s*)?([^\s]+.rb)$/i,
|
43
|
+
/^Missing API definition file in (.+)$/i,
|
44
|
+
/^cannot load such file -- (.+)$/i,
|
45
|
+
]
|
46
|
+
|
47
|
+
def require(*groups)
|
48
|
+
groups.map! { |g| g.to_sym }
|
49
|
+
groups = [:default] if groups.empty?
|
50
|
+
|
51
|
+
@definition.dependencies.each do |dep|
|
52
|
+
# Skip the dependency if it is not in any of the requested
|
53
|
+
# groups
|
54
|
+
next unless ((dep.groups & groups).any? && dep.current_platform?)
|
55
|
+
|
56
|
+
required_file = nil
|
57
|
+
|
58
|
+
begin
|
59
|
+
# Loop through all the specified autorequires for the
|
60
|
+
# dependency. If there are none, use the dependency's name
|
61
|
+
# as the autorequire.
|
62
|
+
Array(dep.autorequire || dep.name).each do |file|
|
63
|
+
required_file = file
|
64
|
+
Kernel.require file
|
65
|
+
end
|
66
|
+
rescue LoadError => e
|
67
|
+
REGEXPS.find { |r| r =~ e.message }
|
68
|
+
raise if dep.autorequire || $1 != required_file
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
def dependencies_for(*groups)
|
74
|
+
if groups.empty?
|
75
|
+
dependencies
|
76
|
+
else
|
77
|
+
dependencies.select { |d| (groups & d.groups).any? }
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
alias gems specs
|
82
|
+
|
83
|
+
def cache
|
84
|
+
FileUtils.mkdir_p(cache_path)
|
85
|
+
|
86
|
+
Bundler.ui.info "Updating .gem files in vendor/cache"
|
87
|
+
specs.each do |spec|
|
88
|
+
next if spec.name == 'bundler'
|
89
|
+
spec.source.cache(spec) if spec.source.respond_to?(:cache)
|
90
|
+
end
|
91
|
+
prune_cache unless Bundler.settings[:no_prune]
|
92
|
+
end
|
93
|
+
|
94
|
+
def prune_cache
|
95
|
+
FileUtils.mkdir_p(cache_path)
|
96
|
+
|
97
|
+
resolve = @definition.resolve
|
98
|
+
cached = Dir["#{cache_path}/*.gem"]
|
99
|
+
|
100
|
+
cached = cached.delete_if do |path|
|
101
|
+
spec = Gem::Format.from_file_by_path(path).spec
|
102
|
+
|
103
|
+
resolve.any? do |s|
|
104
|
+
s.name == spec.name && s.version == spec.version
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
if cached.any?
|
109
|
+
Bundler.ui.info "Removing outdated .gem files from vendor/cache"
|
110
|
+
|
111
|
+
cached.each do |path|
|
112
|
+
Bundler.ui.info " * #{File.basename(path)}"
|
113
|
+
File.delete(path)
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
private
|
119
|
+
|
120
|
+
def cache_path
|
121
|
+
root.join("vendor/cache")
|
122
|
+
end
|
123
|
+
|
124
|
+
def setup_environment
|
125
|
+
begin
|
126
|
+
ENV["BUNDLE_BIN_PATH"] = Gem.bin_path("bundler", "bundle", VERSION)
|
127
|
+
rescue Gem::GemNotFoundException
|
128
|
+
ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
|
129
|
+
end
|
130
|
+
|
131
|
+
# Set PATH
|
132
|
+
paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
|
133
|
+
paths.unshift "#{Bundler.bundle_path}/bin"
|
134
|
+
ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
|
135
|
+
|
136
|
+
# Set BUNDLE_GEMFILE
|
137
|
+
ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s
|
138
|
+
|
139
|
+
# Set RUBYOPT
|
140
|
+
rubyopt = [ENV["RUBYOPT"]].compact
|
141
|
+
if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
|
142
|
+
rubyopt.unshift "-rbundler/setup"
|
143
|
+
rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
|
144
|
+
ENV["RUBYOPT"] = rubyopt.join(' ')
|
145
|
+
end
|
146
|
+
end
|
147
|
+
end
|
148
|
+
end
|
@@ -0,0 +1,117 @@
|
|
1
|
+
module Bundler
|
2
|
+
class Settings
|
3
|
+
def initialize(root)
|
4
|
+
@root = root
|
5
|
+
@local_config = File.exist?(local_config_file) ? YAML.load_file(local_config_file) : {}
|
6
|
+
@global_config = File.exist?(global_config_file) ? YAML.load_file(global_config_file) : {}
|
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
|
+
def delete(key)
|
19
|
+
@local_config
|
20
|
+
end
|
21
|
+
|
22
|
+
def set_global(key, value)
|
23
|
+
set_key(key, value, @global_config, global_config_file)
|
24
|
+
end
|
25
|
+
|
26
|
+
def all
|
27
|
+
env_keys = ENV.keys.select { |k| k =~ /BUNDLE_.*/ }
|
28
|
+
keys = @global_config.keys | @local_config.keys | env_keys
|
29
|
+
|
30
|
+
keys.map do |key|
|
31
|
+
key.sub(/^BUNDLE_/, '').gsub(/__/, ".").downcase
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def locations(key)
|
36
|
+
locations = {}
|
37
|
+
|
38
|
+
locations[:local] = @local_config[key] if @local_config.key?(key)
|
39
|
+
locations[:env] = ENV[key] if ENV[key]
|
40
|
+
locations[:global] = @global_config[key] if @global_config.key?(key)
|
41
|
+
locations
|
42
|
+
end
|
43
|
+
|
44
|
+
def pretty_values_for(exposed_key)
|
45
|
+
key = key_for(exposed_key)
|
46
|
+
|
47
|
+
locations = []
|
48
|
+
if @local_config.key?(key)
|
49
|
+
locations << "Set for your local app (#{local_config_file}): #{@local_config[key].inspect}"
|
50
|
+
end
|
51
|
+
|
52
|
+
if value = ENV[key]
|
53
|
+
locations << "Set via #{key}: #{value.inspect}"
|
54
|
+
end
|
55
|
+
|
56
|
+
if @global_config.key?(key)
|
57
|
+
locations << "Set for the current user (#{global_config_file}): #{@global_config[key].inspect}"
|
58
|
+
end
|
59
|
+
|
60
|
+
return ["You have not configured a value for `#{exposed_key}`"] if locations.empty?
|
61
|
+
locations
|
62
|
+
end
|
63
|
+
|
64
|
+
def without=(array)
|
65
|
+
unless array.empty?
|
66
|
+
self[:without] = array.join(":")
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def without
|
71
|
+
self[:without] ? self[:without].split(":").map { |w| w.to_sym } : []
|
72
|
+
end
|
73
|
+
|
74
|
+
# @local_config["BUNDLE_PATH"] should be prioritized over ENV["BUNDLE_PATH"]
|
75
|
+
def path
|
76
|
+
path = ENV[key_for(:path)] || @global_config[key_for(:path)]
|
77
|
+
return path if path && !@local_config.key?(key_for(:path))
|
78
|
+
|
79
|
+
if path = self[:path]
|
80
|
+
"#{path}/#{Bundler.ruby_scope}"
|
81
|
+
else
|
82
|
+
Gem.dir
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
def allow_sudo?
|
87
|
+
!@local_config.key?(key_for(:path))
|
88
|
+
end
|
89
|
+
|
90
|
+
private
|
91
|
+
def key_for(key)
|
92
|
+
key = key.to_s.sub(".", "__").upcase
|
93
|
+
"BUNDLE_#{key}"
|
94
|
+
end
|
95
|
+
|
96
|
+
def set_key(key, value, hash, file)
|
97
|
+
key = key_for(key)
|
98
|
+
|
99
|
+
unless hash[key] == value
|
100
|
+
hash[key] = value
|
101
|
+
hash.delete(key) if value.nil?
|
102
|
+
FileUtils.mkdir_p(file.dirname)
|
103
|
+
File.open(file, "w") { |f| f.puts hash.to_yaml }
|
104
|
+
end
|
105
|
+
value
|
106
|
+
end
|
107
|
+
|
108
|
+
def global_config_file
|
109
|
+
file = ENV["BUNDLE_CONFIG"] || File.join(Gem.user_home, ".bundle/config")
|
110
|
+
Pathname.new(file)
|
111
|
+
end
|
112
|
+
|
113
|
+
def local_config_file
|
114
|
+
Pathname.new("#{@root}/config")
|
115
|
+
end
|
116
|
+
end
|
117
|
+
end
|