rkh-bundler 1.2.0.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (176) hide show
  1. data/.gitignore +22 -0
  2. data/.travis.yml +42 -0
  3. data/CHANGELOG.md +1105 -0
  4. data/ISSUES.md +67 -0
  5. data/LICENSE +23 -0
  6. data/README.md +31 -0
  7. data/Rakefile +208 -0
  8. data/UPGRADING.md +103 -0
  9. data/bin/bundle +31 -0
  10. data/bundler.gemspec +31 -0
  11. data/lib/bundler.rb +353 -0
  12. data/lib/bundler/capistrano.rb +11 -0
  13. data/lib/bundler/cli.rb +693 -0
  14. data/lib/bundler/definition.rb +568 -0
  15. data/lib/bundler/dep_proxy.rb +43 -0
  16. data/lib/bundler/dependency.rb +134 -0
  17. data/lib/bundler/deployment.rb +58 -0
  18. data/lib/bundler/dsl.rb +256 -0
  19. data/lib/bundler/endpoint_specification.rb +78 -0
  20. data/lib/bundler/environment.rb +47 -0
  21. data/lib/bundler/fetcher.rb +225 -0
  22. data/lib/bundler/gem_helper.rb +162 -0
  23. data/lib/bundler/gem_helpers.rb +23 -0
  24. data/lib/bundler/gem_installer.rb +9 -0
  25. data/lib/bundler/gem_tasks.rb +2 -0
  26. data/lib/bundler/graph.rb +148 -0
  27. data/lib/bundler/index.rb +187 -0
  28. data/lib/bundler/installer.rb +190 -0
  29. data/lib/bundler/lazy_specification.rb +79 -0
  30. data/lib/bundler/lockfile_parser.rb +127 -0
  31. data/lib/bundler/match_platform.rb +13 -0
  32. data/lib/bundler/psyched_yaml.rb +15 -0
  33. data/lib/bundler/remote_specification.rb +57 -0
  34. data/lib/bundler/resolver.rb +486 -0
  35. data/lib/bundler/ruby_version.rb +94 -0
  36. data/lib/bundler/rubygems_ext.rb +153 -0
  37. data/lib/bundler/rubygems_integration.rb +394 -0
  38. data/lib/bundler/runtime.rb +233 -0
  39. data/lib/bundler/settings.rb +128 -0
  40. data/lib/bundler/setup.rb +23 -0
  41. data/lib/bundler/shared_helpers.rb +71 -0
  42. data/lib/bundler/source.rb +869 -0
  43. data/lib/bundler/spec_set.rb +137 -0
  44. data/lib/bundler/templates/Executable +16 -0
  45. data/lib/bundler/templates/Executable.standalone +12 -0
  46. data/lib/bundler/templates/Gemfile +4 -0
  47. data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
  48. data/lib/bundler/templates/newgem/LICENSE.tt +22 -0
  49. data/lib/bundler/templates/newgem/README.md.tt +29 -0
  50. data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
  51. data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
  52. data/lib/bundler/templates/newgem/gitignore.tt +17 -0
  53. data/lib/bundler/templates/newgem/lib/newgem.rb.tt +9 -0
  54. data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
  55. data/lib/bundler/templates/newgem/newgem.gemspec.tt +17 -0
  56. data/lib/bundler/ui.rb +88 -0
  57. data/lib/bundler/vendor/net/http/faster.rb +27 -0
  58. data/lib/bundler/vendor/net/http/persistent.rb +468 -0
  59. data/lib/bundler/vendor/thor.rb +358 -0
  60. data/lib/bundler/vendor/thor/actions.rb +314 -0
  61. data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
  62. data/lib/bundler/vendor/thor/actions/create_link.rb +57 -0
  63. data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
  64. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  65. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +270 -0
  66. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +109 -0
  67. data/lib/bundler/vendor/thor/base.rb +576 -0
  68. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  69. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  70. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  71. data/lib/bundler/vendor/thor/error.rb +30 -0
  72. data/lib/bundler/vendor/thor/group.rb +273 -0
  73. data/lib/bundler/vendor/thor/invocation.rb +168 -0
  74. data/lib/bundler/vendor/thor/parser.rb +4 -0
  75. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  76. data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
  77. data/lib/bundler/vendor/thor/parser/option.rb +120 -0
  78. data/lib/bundler/vendor/thor/parser/options.rb +172 -0
  79. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  80. data/lib/bundler/vendor/thor/runner.rb +309 -0
  81. data/lib/bundler/vendor/thor/shell.rb +88 -0
  82. data/lib/bundler/vendor/thor/shell/basic.rb +302 -0
  83. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  84. data/lib/bundler/vendor/thor/shell/html.rb +121 -0
  85. data/lib/bundler/vendor/thor/task.rb +113 -0
  86. data/lib/bundler/vendor/thor/util.rb +229 -0
  87. data/lib/bundler/vendor/thor/version.rb +3 -0
  88. data/lib/bundler/vendored_thor.rb +7 -0
  89. data/lib/bundler/version.rb +6 -0
  90. data/lib/bundler/vlad.rb +11 -0
  91. data/man/bundle-config.ronn +130 -0
  92. data/man/bundle-exec.ronn +111 -0
  93. data/man/bundle-install.ronn +335 -0
  94. data/man/bundle-package.ronn +59 -0
  95. data/man/bundle-update.ronn +176 -0
  96. data/man/bundle.ronn +83 -0
  97. data/man/gemfile.5.ronn +324 -0
  98. data/man/index.txt +6 -0
  99. data/spec/bundler/dsl_spec.rb +48 -0
  100. data/spec/bundler/gem_helper_spec.rb +174 -0
  101. data/spec/bundler/source_spec.rb +25 -0
  102. data/spec/cache/gems_spec.rb +239 -0
  103. data/spec/cache/git_spec.rb +124 -0
  104. data/spec/cache/path_spec.rb +103 -0
  105. data/spec/cache/platform_spec.rb +57 -0
  106. data/spec/install/deploy_spec.rb +211 -0
  107. data/spec/install/gems/c_ext_spec.rb +48 -0
  108. data/spec/install/gems/dependency_api_spec.rb +402 -0
  109. data/spec/install/gems/env_spec.rb +107 -0
  110. data/spec/install/gems/flex_spec.rb +313 -0
  111. data/spec/install/gems/groups_spec.rb +268 -0
  112. data/spec/install/gems/packed_spec.rb +84 -0
  113. data/spec/install/gems/platform_spec.rb +208 -0
  114. data/spec/install/gems/post_install_spec.rb +47 -0
  115. data/spec/install/gems/resolving_spec.rb +72 -0
  116. data/spec/install/gems/simple_case_spec.rb +814 -0
  117. data/spec/install/gems/standalone_spec.rb +260 -0
  118. data/spec/install/gems/sudo_spec.rb +74 -0
  119. data/spec/install/gems/win32_spec.rb +26 -0
  120. data/spec/install/gemspec_spec.rb +170 -0
  121. data/spec/install/git_spec.rb +796 -0
  122. data/spec/install/invalid_spec.rb +35 -0
  123. data/spec/install/path_spec.rb +405 -0
  124. data/spec/install/upgrade_spec.rb +26 -0
  125. data/spec/lock/git_spec.rb +35 -0
  126. data/spec/lock/lockfile_spec.rb +809 -0
  127. data/spec/other/check_spec.rb +265 -0
  128. data/spec/other/clean_spec.rb +492 -0
  129. data/spec/other/config_spec.rb +138 -0
  130. data/spec/other/console_spec.rb +54 -0
  131. data/spec/other/exec_spec.rb +229 -0
  132. data/spec/other/ext_spec.rb +37 -0
  133. data/spec/other/help_spec.rb +39 -0
  134. data/spec/other/init_spec.rb +40 -0
  135. data/spec/other/newgem_spec.rb +87 -0
  136. data/spec/other/open_spec.rb +35 -0
  137. data/spec/other/outdated_spec.rb +93 -0
  138. data/spec/other/platform_spec.rb +881 -0
  139. data/spec/other/show_spec.rb +88 -0
  140. data/spec/quality_spec.rb +62 -0
  141. data/spec/realworld/edgecases_spec.rb +177 -0
  142. data/spec/resolver/basic_spec.rb +20 -0
  143. data/spec/resolver/platform_spec.rb +82 -0
  144. data/spec/runtime/executable_spec.rb +120 -0
  145. data/spec/runtime/load_spec.rb +107 -0
  146. data/spec/runtime/platform_spec.rb +90 -0
  147. data/spec/runtime/require_spec.rb +261 -0
  148. data/spec/runtime/setup_spec.rb +755 -0
  149. data/spec/runtime/with_clean_env_spec.rb +80 -0
  150. data/spec/spec_helper.rb +98 -0
  151. data/spec/support/artifice/endopint_marshal_fail_basic_authentication.rb +13 -0
  152. data/spec/support/artifice/endpoint.rb +54 -0
  153. data/spec/support/artifice/endpoint_500.rb +37 -0
  154. data/spec/support/artifice/endpoint_api_missing.rb +16 -0
  155. data/spec/support/artifice/endpoint_basic_authentication.rb +13 -0
  156. data/spec/support/artifice/endpoint_extra.rb +27 -0
  157. data/spec/support/artifice/endpoint_extra_missing.rb +15 -0
  158. data/spec/support/artifice/endpoint_fallback.rb +18 -0
  159. data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
  160. data/spec/support/artifice/endpoint_redirect.rb +15 -0
  161. data/spec/support/builders.rb +604 -0
  162. data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
  163. data/spec/support/fakeweb/windows.rb +23 -0
  164. data/spec/support/helpers.rb +317 -0
  165. data/spec/support/indexes.rb +112 -0
  166. data/spec/support/matchers.rb +77 -0
  167. data/spec/support/path.rb +73 -0
  168. data/spec/support/platforms.rb +86 -0
  169. data/spec/support/ruby_ext.rb +20 -0
  170. data/spec/support/rubygems_ext.rb +37 -0
  171. data/spec/support/rubygems_hax/platform.rb +22 -0
  172. data/spec/support/sudo.rb +21 -0
  173. data/spec/update/gems_spec.rb +134 -0
  174. data/spec/update/git_spec.rb +196 -0
  175. data/spec/update/source_spec.rb +51 -0
  176. 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