bundler 0.7.2 → 0.7.3.pre

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

@@ -66,6 +66,15 @@ information, please refer to Bundler::ManifestBuilder.
66
66
  # the gemspec is found in.
67
67
  gem "rspec", "1.1.6", :vendored_at => "vendor/rspec"
68
68
 
69
+ # You can also control what will happen when you run Bundler.require_env
70
+ # by using the :require_as option, as per the next two examples.
71
+
72
+ # Don't auto-require this gem.
73
+ gem "rspec-rails", "1.2.9", :require_as => nil
74
+
75
+ # Require something other than the default.
76
+ gem "yajl-ruby", "0.6.7", :require_as => "yajl/json_gem"
77
+
69
78
  # Works exactly like :vendored_at, but first downloads the repo from
70
79
  # git and handles stashing the files for you. As with :vendored_at,
71
80
  # Bundler will automatically use *.gemspec files in the root or anywhere
@@ -19,7 +19,7 @@ require "bundler/dependency"
19
19
  require "bundler/remote_specification"
20
20
 
21
21
  module Bundler
22
- VERSION = "0.7.2"
22
+ VERSION = "0.7.3.pre"
23
23
 
24
24
  class << self
25
25
  attr_writer :logger
@@ -7,10 +7,14 @@ module Bundler
7
7
  def initialize(path, bindir)
8
8
  FileUtils.mkdir_p(path)
9
9
 
10
- @path = Pathname.new(path)
10
+ @path = Pathname.new(path)
11
11
  @bindir = Pathname.new(bindir)
12
12
 
13
- @cache = GemDirectorySource.new(:location => @path.join("cache"))
13
+ @cache_path = @path.join('cache')
14
+ @cache = GemDirectorySource.new(:location => @cache_path)
15
+
16
+ @specs_path = @path.join('specifications')
17
+ @gems_path = @path.join('gems')
14
18
  end
15
19
 
16
20
  def install(dependencies, sources, options = {})
@@ -51,10 +55,10 @@ module Bundler
51
55
  end
52
56
 
53
57
  def cache(*gemfiles)
54
- FileUtils.mkdir_p(@path.join("cache"))
58
+ FileUtils.mkdir_p(@cache_path)
55
59
  gemfiles.each do |gemfile|
56
60
  Bundler.logger.info "Caching: #{File.basename(gemfile)}"
57
- FileUtils.cp(gemfile, @path.join("cache"))
61
+ FileUtils.cp(gemfile, @cache_path)
58
62
  end
59
63
  end
60
64
 
@@ -70,7 +74,7 @@ module Bundler
70
74
  specs.each do |spec|
71
75
  unless bundle.any? { |s| s.name == spec.name && s.version == spec.version }
72
76
  Bundler.logger.info "Pruning #{spec.name} (#{spec.version}) from the cache"
73
- FileUtils.rm @path.join("cache", "#{spec.full_name}.gem")
77
+ FileUtils.rm @cache_path.join("#{spec.full_name}.gem")
74
78
  end
75
79
  end
76
80
  end
@@ -85,8 +89,8 @@ module Bundler
85
89
  end
86
90
 
87
91
  def source_index
88
- index = Gem::SourceIndex.from_gems_in(@path.join("specifications"))
89
- index.each { |n, spec| spec.loaded_from = @path.join("specifications", "#{spec.full_name}.gemspec") }
92
+ index = Gem::SourceIndex.from_gems_in(@specs_path)
93
+ index.each { |n, spec| spec.loaded_from = @specs_path.join("#{spec.full_name}.gemspec") }
90
94
  index
91
95
  end
92
96
 
@@ -110,9 +114,9 @@ module Bundler
110
114
  def do_install(bundle, options)
111
115
  bundle.each do |spec|
112
116
  next if options[:no_bundle].include?(spec.name)
113
- spec.loaded_from = @path.join("specifications", "#{spec.full_name}.gemspec")
117
+ spec.loaded_from = @specs_path.join("#{spec.full_name}.gemspec")
114
118
  # Do nothing if the gem is already expanded
115
- next if @path.join("gems", spec.full_name).directory?
119
+ next if @gems_path.join(spec.full_name).directory?
116
120
 
117
121
  case spec.source
118
122
  when GemSource, GemDirectorySource, SystemGemSource
@@ -129,11 +133,12 @@ module Bundler
129
133
  # HAX -- Generate the bin
130
134
  bin_dir = @bindir
131
135
  path = @path
136
+ gems_path = @gems_path
132
137
  installer = Gem::Installer.allocate
133
138
  installer.instance_eval do
134
139
  @spec = spec
135
140
  @bin_dir = bin_dir
136
- @gem_dir = path.join("gems", "#{spec.full_name}")
141
+ @gem_dir = gems_path.join(spec.full_name)
137
142
  @gem_home = path
138
143
  @wrappers = true
139
144
  @format_executable = false
@@ -146,7 +151,7 @@ module Bundler
146
151
  def expand_gemfile(spec, options)
147
152
  Bundler.logger.info "Installing #{spec.name} (#{spec.version})"
148
153
 
149
- gemfile = @path.join("cache", "#{spec.full_name}.gem").to_s
154
+ gemfile = @cache_path.join("#{spec.full_name}.gem").to_s
150
155
 
151
156
  if build_args = options[:build_options] && options[:build_options][spec.name]
152
157
  Gem::Command.build_args = build_args.map {|k,v| "--with-#{k}=#{v}"}
@@ -169,12 +174,12 @@ module Bundler
169
174
 
170
175
  def expand_vendored_gem(spec, options)
171
176
  add_spec(spec)
172
- FileUtils.mkdir_p(@path.join("gems"))
173
- File.symlink(spec.location, @path.join("gems", spec.full_name))
177
+ FileUtils.mkdir_p(@gems_path)
178
+ File.symlink(spec.location, @gems_path.join(spec.full_name))
174
179
  end
175
180
 
176
181
  def add_spec(spec)
177
- destination = path.join('specifications')
182
+ destination = @specs_path
178
183
  destination.mkdir unless destination.exist?
179
184
 
180
185
  File.open(destination.join("#{spec.full_name}.gemspec"), 'w') do |f|
@@ -203,8 +208,8 @@ module Bundler
203
208
  end
204
209
 
205
210
  def cleanup_spec(spec)
206
- FileUtils.rm_rf(@path.join("specifications", "#{spec.full_name}.gemspec"))
207
- FileUtils.rm_rf(@path.join("gems", spec.full_name))
211
+ FileUtils.rm_rf(@specs_path.join("#{spec.full_name}.gemspec"))
212
+ FileUtils.rm_rf(@gems_path.join(spec.full_name))
208
213
  end
209
214
 
210
215
  def expand(options)
@@ -214,12 +219,16 @@ module Bundler
214
219
  end
215
220
 
216
221
  def configure(specs, options)
222
+ FileUtils.mkdir_p(path)
217
223
  generate_environment(specs, options)
224
+ generate_environment_picker
218
225
  end
219
226
 
220
- def generate_environment(specs, options)
221
- FileUtils.mkdir_p(path)
227
+ def generate_environment_picker
228
+ FileUtils.cp("#{File.dirname(__FILE__)}/templates/environment_picker.erb", path.join("../../environment.rb"))
229
+ end
222
230
 
231
+ def generate_environment(specs, options)
223
232
  load_paths = load_paths_for_specs(specs, options)
224
233
  bindir = @bindir.relative_path_from(path).to_s
225
234
  filename = options[:manifest].relative_path_from(path).to_s
@@ -236,7 +245,9 @@ module Bundler
236
245
  specs.each do |spec|
237
246
  next if options[:no_bundle].include?(spec.name)
238
247
  gem_path = Pathname.new(spec.full_gem_path)
239
- load_paths << load_path_for(gem_path, spec.bindir) if spec.bindir
248
+ if spec.bindir && gem_path.join(spec.bindir).exist?
249
+ load_paths << load_path_for(gem_path, spec.bindir)
250
+ end
240
251
  spec.require_paths.each do |path|
241
252
  load_paths << load_path_for(gem_path, path)
242
253
  end
@@ -107,7 +107,7 @@ module Bundler
107
107
  options = args.last.is_a?(Hash) ? args.pop : {}
108
108
  version = args.last
109
109
 
110
- keys = %w(vendored_at path only except git path bundle require_as tag branch ref).map(&:to_sym)
110
+ keys = :vendored_at, :path, :only, :except, :git, :path, :bundle, :require_as, :tag, :branch, :ref
111
111
  unless (invalid = options.keys - keys).empty?
112
112
  raise InvalidKey, "Only #{keys.join(", ")} are valid options to #gem. You used #{invalid.join(", ")}"
113
113
  end
@@ -171,7 +171,7 @@ module Bundler
171
171
 
172
172
  def _handle_git_option(name, version, options)
173
173
  git = options[:git].to_s
174
- ref = options[:commit] || options[:tag]
174
+ ref = options[:ref] || options[:tag]
175
175
  branch = options[:branch]
176
176
 
177
177
  if source = @git || @git_sources[git]
@@ -9,6 +9,10 @@ module Bundler
9
9
  attr_accessor :rubygems, :system_gems
10
10
  attr_writer :gem_path, :bindir
11
11
 
12
+ def self.default_gem_path(root)
13
+ Pathname.new("#{root}/vendor/gems/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}")
14
+ end
15
+
12
16
  def initialize(filename)
13
17
  @filename = filename
14
18
  @default_sources = default_sources
@@ -114,7 +118,7 @@ module Bundler
114
118
  end
115
119
 
116
120
  def gem_path
117
- @gem_path ||= root.join("vendor", "gems")
121
+ @gem_path ||= self.class.default_gem_path(root)
118
122
  end
119
123
 
120
124
  def bindir
@@ -235,7 +235,7 @@ module Bundler
235
235
  found.reject! { |spec| spec.version.prerelease? }
236
236
  end
237
237
 
238
- found.sort_by {|s| [s.version, s.platform == 'ruby' ? "\0" : s.platform] }
238
+ found.sort_by {|s| [s.version, s.platform.to_s == 'ruby' ? "\0" : s.platform.to_s] }
239
239
  end
240
240
  end
241
241
  end
@@ -69,17 +69,10 @@ module Bundler
69
69
 
70
70
  def fetch_specs
71
71
  Bundler.logger.info "Updating source: #{to_s}"
72
+ build_gem_index(fetch_main_specs + fetch_prerelease_specs)
73
+ end
72
74
 
73
- fetcher = Gem::RemoteFetcher.fetcher
74
- main_index = fetcher.fetch_path("#{uri}/specs.4.8.gz")
75
- begin
76
- prerelease_index = fetcher.fetch_path("#{uri}/prerelease_specs.4.8.gz")
77
- index = Marshal.load(main_index) + Marshal.load(prerelease_index)
78
- rescue Gem::RemoteFetcher::FetchError
79
- Bundler.logger.warn "Source '#{uri}' does not support prerelease gems"
80
- index = Marshal.load(main_index)
81
- end
82
-
75
+ def build_gem_index(index)
83
76
  gems = Hash.new { |h,k| h[k] = [] }
84
77
  index.each do |name, version, platform|
85
78
  spec = RemoteSpecification.new(name, version, platform, @uri)
@@ -87,9 +80,20 @@ module Bundler
87
80
  gems[spec.name] << spec if Gem::Platform.match(spec.platform)
88
81
  end
89
82
  gems
83
+ end
84
+
85
+ def fetch_main_specs
86
+ Marshal.load(Gem::RemoteFetcher.fetcher.fetch_path("#{uri}/specs.4.8.gz"))
90
87
  rescue Gem::RemoteFetcher::FetchError => e
91
88
  raise ArgumentError, "#{to_s} is not a valid source: #{e.message}"
92
89
  end
90
+
91
+ def fetch_prerelease_specs
92
+ Marshal.load(Gem::RemoteFetcher.fetcher.fetch_path("#{uri}/prerelease_specs.4.8.gz"))
93
+ rescue Gem::RemoteFetcher::FetchError
94
+ Bundler.logger.warn "Source '#{uri}' does not support prerelease gems"
95
+ []
96
+ end
93
97
  end
94
98
 
95
99
  class SystemGemSource < Source
@@ -288,8 +292,8 @@ module Bundler
288
292
  def initialize(options)
289
293
  super
290
294
  @uri = options[:uri]
291
- @ref = options[:ref]
292
- @branch = options[:branch]
295
+ @branch = options[:branch] || 'master'
296
+ @ref = options[:ref] || "origin/#{@branch}"
293
297
  end
294
298
 
295
299
  def location
@@ -298,24 +302,8 @@ module Bundler
298
302
  end
299
303
 
300
304
  def gems
301
- unless location.directory?
302
- # Raise an error if the source should run in local mode,
303
- # but it has not been cached yet.
304
- if local
305
- raise SourceNotCached, "Git repository '#{@uri}' has not been cloned yet"
306
- end
307
-
308
- FileUtils.mkdir_p(location.dirname)
309
-
310
- Bundler.logger.info "Cloning git repository at: #{@uri}"
311
- `git clone #{@uri} #{location} --no-hardlinks`
312
-
313
- if @ref
314
- Dir.chdir(location) { `git checkout --quiet #{@ref}` }
315
- elsif @branch && @branch != "master"
316
- Dir.chdir(location) { `git checkout --quiet origin/#{@branch}` }
317
- end
318
- end
305
+ update
306
+ checkout
319
307
  super
320
308
  end
321
309
 
@@ -326,5 +314,37 @@ module Bundler
326
314
  def to_s
327
315
  "git: #{uri}"
328
316
  end
317
+
318
+ private
319
+ def update
320
+ if location.directory?
321
+ fetch
322
+ else
323
+ clone
324
+ end
325
+ end
326
+
327
+ def fetch
328
+ unless local
329
+ Bundler.logger.info "Fetching git repository at: #{@uri}"
330
+ Dir.chdir(location) { `git fetch origin` }
331
+ end
332
+ end
333
+
334
+ def clone
335
+ # Raise an error if the source should run in local mode,
336
+ # but it has not been cached yet.
337
+ if local
338
+ raise SourceNotCached, "Git repository '#{@uri}' has not been cloned yet"
339
+ end
340
+
341
+ Bundler.logger.info "Cloning git repository at: #{@uri}"
342
+ FileUtils.mkdir_p(location.dirname)
343
+ `git clone #{@uri} #{location} --no-hardlinks`
344
+ end
345
+
346
+ def checkout
347
+ Dir.chdir(location) { `git checkout --quiet #{@ref}` }
348
+ end
329
349
  end
330
350
  end
@@ -26,7 +26,7 @@ module Bundler
26
26
  @gemfile = "#{dir}/<%= filename %>"
27
27
 
28
28
  <% if options[:rubygems] -%>
29
- require "rubygems"
29
+ require "rubygems" unless respond_to?(:gem) # 1.9 already has RubyGems loaded
30
30
 
31
31
  @bundled_specs = {}
32
32
  <% specs.each do |spec| -%>
@@ -0,0 +1,4 @@
1
+ require 'rbconfig'
2
+ engine = defined?(RUBY_ENGINE) ? RUBY_ENGINE : 'ruby'
3
+ version = Config::CONFIG['ruby_version']
4
+ require File.expand_path("../#{engine}/#{version}/environment", __FILE__)
metadata CHANGED
@@ -1,52 +1,53 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.2
4
+ version: 0.7.3.pre
5
5
  platform: ruby
6
6
  authors:
7
- - Yehuda Katz
8
- - Carl Lerche
7
+ - Yehuda Katz
8
+ - Carl Lerche
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2009-12-18 00:00:00 -08:00
13
+ date: 2010-01-03 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16
 
17
17
  description: An easy way to vendor gem dependencies
18
18
  email:
19
- - wycats@gmail.com
20
- - clerche@engineyard.com
19
+ - wycats@gmail.com
20
+ - clerche@engineyard.com
21
21
  executables: []
22
22
 
23
23
  extensions: []
24
24
 
25
25
  extra_rdoc_files:
26
- - README.markdown
27
- - LICENSE
26
+ - README.markdown
27
+ - LICENSE
28
28
  files:
29
- - LICENSE
30
- - README.markdown
31
- - Rakefile
32
- - lib/bundler.rb
33
- - lib/rubygems_plugin.rb
34
- - lib/bundler/bundle.rb
35
- - lib/bundler/cli.rb
36
- - lib/bundler/dependency.rb
37
- - lib/bundler/dsl.rb
38
- - lib/bundler/environment.rb
39
- - lib/bundler/finder.rb
40
- - lib/bundler/gem_bundle.rb
41
- - lib/bundler/gem_ext.rb
42
- - lib/bundler/remote_specification.rb
43
- - lib/bundler/resolver.rb
44
- - lib/bundler/runtime.rb
45
- - lib/bundler/source.rb
46
- - lib/bundler/commands/bundle_command.rb
47
- - lib/bundler/commands/exec_command.rb
48
- - lib/bundler/templates/app_script.erb
49
- - lib/bundler/templates/environment.erb
29
+ - LICENSE
30
+ - README.markdown
31
+ - Rakefile
32
+ - lib/bundler/bundle.rb
33
+ - lib/bundler/cli.rb
34
+ - lib/bundler/commands/bundle_command.rb
35
+ - lib/bundler/commands/exec_command.rb
36
+ - lib/bundler/dependency.rb
37
+ - lib/bundler/dsl.rb
38
+ - lib/bundler/environment.rb
39
+ - lib/bundler/finder.rb
40
+ - lib/bundler/gem_bundle.rb
41
+ - lib/bundler/gem_ext.rb
42
+ - lib/bundler/remote_specification.rb
43
+ - lib/bundler/resolver.rb
44
+ - lib/bundler/runtime.rb
45
+ - lib/bundler/source.rb
46
+ - lib/bundler/templates/app_script.erb
47
+ - lib/bundler/templates/environment.erb
48
+ - lib/bundler/templates/environment_picker.erb
49
+ - lib/bundler.rb
50
+ - lib/rubygems_plugin.rb
50
51
  has_rdoc: true
51
52
  homepage: http://github.com/wycats/bundler
52
53
  licenses: []
@@ -55,18 +56,18 @@ post_install_message:
55
56
  rdoc_options: []
56
57
 
57
58
  require_paths:
58
- - lib
59
+ - lib
59
60
  required_ruby_version: !ruby/object:Gem::Requirement
60
61
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: "0"
62
+ - - ">="
63
+ - !ruby/object:Gem::Version
64
+ version: "0"
64
65
  version:
65
66
  required_rubygems_version: !ruby/object:Gem::Requirement
66
67
  requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 1.3.5
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ version: 1.3.5
70
71
  version:
71
72
  requirements: []
72
73