bundler 0.7.1 → 0.7.2

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.

data/Rakefile CHANGED
@@ -47,6 +47,12 @@ else
47
47
  end
48
48
  end
49
49
 
50
+ desc "mount a ramdisk at ./tmp for faster specs"
51
+ task :ramdisk do
52
+ sh 'diskutil erasevolume HFS+ "tmpbundler" `hdiutil attach -nomount ram://116543`'
53
+ File.symlink "/Volumes/tmpbundler", File.expand_path('../tmp', __FILE__)
54
+ end
55
+
50
56
  desc "install the gem locally"
51
57
  task :install => [:package] do
52
58
  sh %{gem install pkg/#{spec.name}-#{spec.version}}
@@ -14,12 +14,12 @@ require "bundler/resolver"
14
14
  require "bundler/environment"
15
15
  require "bundler/dsl"
16
16
  require "bundler/cli"
17
- require "bundler/repository"
17
+ require "bundler/bundle"
18
18
  require "bundler/dependency"
19
19
  require "bundler/remote_specification"
20
20
 
21
21
  module Bundler
22
- VERSION = "0.7.1"
22
+ VERSION = "0.7.2"
23
23
 
24
24
  class << self
25
25
  attr_writer :logger
@@ -1,7 +1,7 @@
1
1
  module Bundler
2
2
  class InvalidRepository < StandardError ; end
3
3
 
4
- class Repository
4
+ class Bundle
5
5
  attr_reader :path
6
6
 
7
7
  def initialize(path, bindir)
@@ -160,6 +160,9 @@ module Bundler
160
160
  :bin_dir => @bindir
161
161
  ))
162
162
  installer.install
163
+ rescue Gem::InstallError
164
+ cleanup_spec(spec)
165
+ raise
163
166
  ensure
164
167
  Gem::Command.build_args = []
165
168
  end
@@ -189,8 +192,7 @@ module Bundler
189
192
 
190
193
  to_delete.each do |spec|
191
194
  Bundler.logger.info "Deleting gem: #{spec.name} (#{spec.version})"
192
- FileUtils.rm_rf(@path.join("specifications", "#{spec.full_name}.gemspec"))
193
- FileUtils.rm_rf(@path.join("gems", spec.full_name))
195
+ cleanup_spec(spec)
194
196
  # Cleanup the bin directory
195
197
  spec.executables.each do |bin|
196
198
  next if valid_executables.include?(bin)
@@ -200,6 +202,11 @@ module Bundler
200
202
  end
201
203
  end
202
204
 
205
+ 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))
208
+ end
209
+
203
210
  def expand(options)
204
211
  each_repo do |repo|
205
212
  repo.expand(options)
@@ -32,7 +32,7 @@ module Bundler
32
32
 
33
33
  def initialize(options)
34
34
  @options = options
35
- @environment = Bundler::Environment.load(@options[:manifest])
35
+ @environment = Dsl.load_gemfile(@options[:manifest])
36
36
  end
37
37
 
38
38
  def bundle
@@ -19,7 +19,7 @@ class Gem::Commands::BundleCommand < Gem::Command
19
19
  options[:cache] = gem
20
20
  end
21
21
 
22
- add_option('--prune-cache', "Removes all .gem files from the bundle's cache") do
22
+ add_option('--prune-cache', "Removes all .gem files that are not a part of the bundle from the cache") do
23
23
  options[:prune] = true
24
24
  end
25
25
 
@@ -1,10 +1,36 @@
1
1
  module Bundler
2
2
  class ManifestFileNotFound < StandardError; end
3
+ class InvalidKey < StandardError; end
4
+ class DefaultManifestNotFound < StandardError; end
3
5
 
4
6
  class Dsl
5
- def self.evaluate(environment, file)
7
+ def self.load_gemfile(file)
8
+ gemfile = Pathname.new(file || default_gemfile).expand_path
9
+
10
+ unless gemfile.file?
11
+ raise ManifestFileNotFound, "Manifest file not found: #{gemfile.to_s.inspect}"
12
+ end
13
+
14
+ evaluate(gemfile)
15
+ end
16
+
17
+ def self.default_gemfile
18
+ current = Pathname.new(Dir.pwd)
19
+
20
+ until current.root?
21
+ filename = current.join("Gemfile")
22
+ return filename if filename.exist?
23
+ current = current.parent
24
+ end
25
+
26
+ raise DefaultManifestNotFound
27
+ end
28
+
29
+ def self.evaluate(file)
30
+ environment = Environment.new(file)
6
31
  builder = new(environment)
7
32
  builder.instance_eval(File.read(file.to_s), file.to_s, 1)
33
+ environment
8
34
  end
9
35
 
10
36
  def initialize(environment)
@@ -81,6 +107,11 @@ module Bundler
81
107
  options = args.last.is_a?(Hash) ? args.pop : {}
82
108
  version = args.last
83
109
 
110
+ keys = %w(vendored_at path only except git path bundle require_as tag branch ref).map(&:to_sym)
111
+ unless (invalid = options.keys - keys).empty?
112
+ raise InvalidKey, "Only #{keys.join(", ")} are valid options to #gem. You used #{invalid.join(", ")}"
113
+ end
114
+
84
115
  if path = options.delete(:vendored_at)
85
116
  options[:path] = path
86
117
  warn "The :vendored_at option is deprecated. Use :path instead.\nFrom #{caller[0]}"
@@ -104,12 +135,16 @@ module Bundler
104
135
 
105
136
  private
106
137
 
138
+ def _version?(version)
139
+ version && Gem::Version.new(version) rescue false
140
+ end
141
+
107
142
  def _handle_vendored_option(name, version, options)
108
143
  dir, path = _find_directory_source(options[:path])
109
144
 
110
145
  if dir
111
146
  dir.required_specs << name
112
- dir.add_spec(path, name, version) if version
147
+ dir.add_spec(path, name, version) if _version?(version)
113
148
  dir
114
149
  else
115
150
  directory options[:path] do
@@ -147,7 +182,7 @@ module Bundler
147
182
  end
148
183
 
149
184
  source.required_specs << name
150
- source.add_spec(Pathname.new(options[:path] || '.'), name, version) if version
185
+ source.add_spec(Pathname.new(options[:path] || '.'), name, version) if _version?(version)
151
186
  source
152
187
  else
153
188
  git(git, :ref => ref, :branch => branch) do
@@ -1,7 +1,6 @@
1
1
  require "rubygems/source_index"
2
2
 
3
3
  module Bundler
4
- class DefaultManifestNotFound < StandardError; end
5
4
  class InvalidCacheArgument < StandardError; end
6
5
  class SourceNotCached < StandardError; end
7
6
 
@@ -10,28 +9,6 @@ module Bundler
10
9
  attr_accessor :rubygems, :system_gems
11
10
  attr_writer :gem_path, :bindir
12
11
 
13
- def self.load(file = nil)
14
- gemfile = Pathname.new(file || default_manifest_file).expand_path
15
-
16
- unless gemfile.file?
17
- raise ManifestFileNotFound, "Manifest file not found: #{gemfile.to_s.inspect}"
18
- end
19
-
20
- new(gemfile)
21
- end
22
-
23
- def self.default_manifest_file
24
- current = Pathname.new(Dir.pwd)
25
-
26
- until current.root?
27
- filename = current.join("Gemfile")
28
- return filename if filename.exist?
29
- current = current.parent
30
- end
31
-
32
- raise DefaultManifestNotFound
33
- end
34
-
35
12
  def initialize(filename)
36
13
  @filename = filename
37
14
  @default_sources = default_sources
@@ -40,9 +17,6 @@ module Bundler
40
17
  @dependencies = []
41
18
  @rubygems = true
42
19
  @system_gems = true
43
-
44
- # Evaluate the Gemfile
45
- Dsl.evaluate(self, filename)
46
20
  end
47
21
 
48
22
  def install(options = {})
@@ -171,7 +145,7 @@ module Bundler
171
145
  end
172
146
 
173
147
  def repository
174
- @repository ||= Repository.new(gem_path, bindir)
148
+ @repository ||= Bundle.new(gem_path, bindir)
175
149
  end
176
150
 
177
151
  def gem_dependencies
@@ -32,7 +32,10 @@ module Bundler
32
32
  private
33
33
 
34
34
  def _remote_uri
35
- "#{@source_uri}/quick/Marshal.4.8/#{@name}-#{@version}.gemspec.rz"
35
+ # "#{@source_uri}/quick/Marshal.4.8/#{@name}-#{@version}.gemspec.rz"
36
+ tuple = [@name, @version, @platform]
37
+ tuple = tuple - [nil, 'ruby', '']
38
+ "#{@source_uri}/quick/Marshal.4.8/#{tuple.join("-")}.gemspec.rz"
36
39
  end
37
40
 
38
41
  def _remote_specification
@@ -77,8 +77,9 @@ module Bundler
77
77
  sources.each do |source|
78
78
  source.gems.each do |name, specs|
79
79
  # Hack to work with a regular Gem::SourceIndex
80
- [specs].flatten.compact.each do |spec|
81
- next if @specs[spec.name].any? { |s| s.version == spec.version }
80
+ specs = [specs] unless specs.is_a?(Array)
81
+ specs.compact.each do |spec|
82
+ next if @specs[spec.name].any? { |s| s.version == spec.version && s.platform == spec.platform }
82
83
  @specs[spec.name] << spec
83
84
  end
84
85
  end
@@ -157,7 +158,8 @@ module Bundler
157
158
 
158
159
  if matching_versions.empty?
159
160
  if current.required_by.empty?
160
- raise GemNotFound, "Could not find gem '#{current}' in any of the sources"
161
+ location = @by_gem[current.name] ? @by_gem[current.name] : "any of the sources"
162
+ raise GemNotFound, "Could not find gem '#{current}' in #{location}"
161
163
  end
162
164
  Bundler.logger.warn "Could not find gem '#{current}' (required by '#{current.required_by.last}') in any of the sources"
163
165
  end
@@ -221,13 +223,19 @@ module Bundler
221
223
 
222
224
  def search(dependency)
223
225
  @cache[dependency.hash] ||= begin
224
- collection = @by_gem[dependency.name].gems if @by_gem[dependency.name]
225
- collection ||= @specs
226
- collection[dependency.name].select do |spec|
227
- match = dependency =~ spec
228
- match &= dependency.version_requirements.prerelease? if spec.version.prerelease?
229
- match
230
- end.sort_by {|s| s.version }
226
+ pinned = @by_gem[dependency.name].gems if @by_gem[dependency.name]
227
+ specs = (pinned || @specs)[dependency.name]
228
+
229
+ wants_prerelease = dependency.version_requirements.prerelease?
230
+ only_prerelease = specs.all? {|spec| spec.version.prerelease? }
231
+
232
+ found = specs.select { |spec| dependency =~ spec }
233
+
234
+ unless wants_prerelease || (pinned && only_prerelease)
235
+ found.reject! { |spec| spec.version.prerelease? }
236
+ end
237
+
238
+ found.sort_by {|s| [s.version, s.platform == 'ruby' ? "\0" : s.platform] }
231
239
  end
232
240
  end
233
241
  end
@@ -274,7 +274,7 @@ module Bundler
274
274
  end
275
275
 
276
276
  def to_s
277
- "#{@name} (#{@version}) Located at: '#{location}'"
277
+ "directory: '#{location}'"
278
278
  end
279
279
 
280
280
  def download(spec)
@@ -322,5 +322,9 @@ module Bundler
322
322
  def download(spec)
323
323
  # Nothing needed here
324
324
  end
325
+
326
+ def to_s
327
+ "git: #{uri}"
328
+ end
325
329
  end
326
330
  end
@@ -1,3 +1,3 @@
1
1
  <%= shebang bin_file_name %>
2
- require File.join(File.dirname(__FILE__), "<%= path.join("environment").relative_path_from(Pathname.new(bin_dir)) %>")
3
- load File.join(File.dirname(__FILE__), "<%= path.join("gems", @spec.full_name, @spec.bindir, bin_file_name).relative_path_from(Pathname.new(bin_dir)) %>")
2
+ require File.expand_path(File.join(File.dirname(__FILE__), "<%= path.join("environment").relative_path_from(Pathname.new(bin_dir)) %>"))
3
+ load File.expand_path(File.join(File.dirname(__FILE__), "<%= path.join("gems", @spec.full_name, @spec.bindir, bin_file_name).relative_path_from(Pathname.new(bin_dir)) %>"))
@@ -6,8 +6,17 @@ module Bundler
6
6
  <% unless options[:system_gems] -%>
7
7
  ENV["GEM_HOME"] = dir
8
8
  ENV["GEM_PATH"] = dir
9
+
10
+ # handle 1.9 where system gems are always on the load path
11
+ if defined?(::Gem)
12
+ $LOAD_PATH.reject! do |p|
13
+ p != File.dirname(__FILE__) &&
14
+ Gem.path.any? { |gp| p.include?(gp) }
15
+ end
16
+ end
17
+
9
18
  <% end -%>
10
- ENV["PATH"] = "#{dir}/<%= bindir %>:#{ENV["PATH"]}"
19
+ ENV["PATH"] = "#{dir}/<%= bindir %><%= File::PATH_SEPARATOR %>#{ENV["PATH"]}"
11
20
  ENV["RUBYOPT"] = "-r#{file} #{ENV["RUBYOPT"]}"
12
21
 
13
22
  <% load_paths.each do |load_path| -%>
@@ -121,6 +130,8 @@ end
121
130
  # Define all the Gem errors for gems that reference them.
122
131
  module Gem
123
132
  def self.ruby ; <%= Gem.ruby.inspect %> ; end
133
+ def self.dir ; @dir ||= File.dirname(File.expand_path(__FILE__)) ; end
134
+ class << self ; alias default_dir dir; alias path dir ; end
124
135
  class LoadError < ::LoadError; end
125
136
  class Exception < RuntimeError; end
126
137
  class CommandLineError < Exception; end
metadata CHANGED
@@ -1,52 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.2
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-07 00:00:00 -08:00
13
+ date: 2009-12-18 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/cli.rb
33
- - lib/bundler/commands/bundle_command.rb
34
- - lib/bundler/commands/exec_command.rb
35
- - lib/bundler/dependency.rb
36
- - lib/bundler/dsl.rb
37
- - lib/bundler/environment.rb
38
- - lib/bundler/finder.rb
39
- - lib/bundler/gem_bundle.rb
40
- - lib/bundler/gem_ext.rb
41
- - lib/bundler/remote_specification.rb
42
- - lib/bundler/repository.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.rb
49
- - lib/rubygems_plugin.rb
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
50
50
  has_rdoc: true
51
51
  homepage: http://github.com/wycats/bundler
52
52
  licenses: []
@@ -55,18 +55,18 @@ post_install_message:
55
55
  rdoc_options: []
56
56
 
57
57
  require_paths:
58
- - lib
58
+ - lib
59
59
  required_ruby_version: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: "0"
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: "0"
64
64
  version:
65
65
  required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - ">="
68
- - !ruby/object:Gem::Version
69
- version: 1.3.5
67
+ - - ">="
68
+ - !ruby/object:Gem::Version
69
+ version: 1.3.5
70
70
  version:
71
71
  requirements: []
72
72