bundler 0.9.5 → 0.9.6

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.

@@ -1,11 +1,5 @@
1
1
  ## Bundler : A gem to bundle gems
2
2
 
3
- Github: http://github.com/wycats/bundler
4
- Mailing list: http://groups.google.com/group/ruby-bundler
5
- IRC: #carlhuda on freenode
6
-
7
- ## Intro
8
-
9
3
  Bundler is a tool that manages gem dependencies for your ruby application. It
10
4
  takes a gem manifest file and is able to fetch, download, and install the gems
11
5
  and all child dependencies specified in this manifest. It can manage any update
@@ -14,14 +8,18 @@ you run any ruby code in context of the bundle's gem environment.
14
8
 
15
9
  ## Installation
16
10
 
17
- Bundler has no dependencies besides Ruby and RubyGems. Just clone the git
18
- repository and install the gem with the following rake task:
11
+ If you are upgrading from Bundler 0.8, be sure to read the upgrade notes
12
+ located at the bottom of this file.
19
13
 
20
- rake install
14
+ Bundler has no dependencies besides Ruby and RubyGems. You can install the
15
+ latest release via RubyGems:
21
16
 
22
- You can also install the gem with
17
+ gem install bundler
23
18
 
24
- gem install bundler --prerelease
19
+ If you want to contribute, or need a change that hasn't been released yet,
20
+ just clone the git repository and install the gem with rake:
21
+
22
+ rake install
25
23
 
26
24
  ## Usage
27
25
 
@@ -78,7 +76,7 @@ Groups are involved in a number of scenarios:
78
76
 
79
77
  1. When installing gems using bundle install, you can choose to leave
80
78
  out any group by specifying `--without {group name}`. This can be
81
- helpful if, for instance, you have a gem that you can only compile
79
+ helpful if, for instance, you have a gem that you cannot compile
82
80
  in certain environments.
83
81
  2. When setting up load paths using Bundler.setup, Bundler will, by
84
82
  default, add the load paths for all groups. You can restrict the
@@ -92,14 +90,15 @@ Groups are involved in a number of scenarios:
92
90
 
93
91
  ### Installing gems
94
92
 
95
- Once the manifest file has been created, the next step is to install all
96
- the gems needed to satisfy the Gemfile's dependencies. The `bundle install`
97
- command will do this.
93
+ Once the Gemfile manifest file has been created, the next step is to install
94
+ all the gems needed to satisfy the manifest's dependencies. The command to
95
+ do this is `bundle install`.
98
96
 
99
97
  This command will load the Gemfile, resolve all the dependencies, download
100
- all gems that are missing, and install them to the system's RubyGems
101
- repository. Every time an update is made to the Gemfile, run `bundle install`
102
- again to get the new gems installed.
98
+ all gems that are missing, and install them to the bundler's gem repository.
99
+ Gems that are already installed into the system RubyGems repository will be
100
+ referenced, rather than installed again. Every time an update is made to the
101
+ Gemfile, run `bundle install` again to install any newly needed gems.
103
102
 
104
103
  ### Locking dependencies
105
104
 
@@ -108,20 +107,25 @@ Gemfile's dependencies. If you install a newer version of a gem and it
108
107
  satisfies the dependencies, it will be used instead of the older one.
109
108
 
110
109
  The command `bundle lock` will lock the bundle to the current set of
111
- resolved gems. This ensures that, until the lock file is removed, that
112
- bundle install and Bundle.setup will always activate the same gems.
110
+ resolved gems. This ensures that, until the lock file is removed,
111
+ `bundle install` and `Bundle.setup` will always activate the same gems.
112
+
113
+ When you are distributing your application, you should add the Gemfile.lock
114
+ file to your source control, so that the set of libraries your code will
115
+ run against are fixed. Simply run `bundle install` after checking out or
116
+ deploying your code to ensure your libraries are present.
113
117
 
114
118
  ### Running the application
115
119
 
116
120
  Bundler must be required and setup before anything else is required. This
117
- is because it will configure all the load paths and manage rubygems for your.
121
+ is because it will configure all the load paths and manage gems for you.
118
122
  To do this, include the following at the beginning of your code.
119
123
 
120
124
  begin
121
- # Require the preresolved locked set of gems.
125
+ # Try to require the preresolved locked set of gems.
122
126
  require File.expand_path('../.bundle/environment', __FILE__)
123
127
  rescue LoadError
124
- # Fallback on doing the resolve at runtime.
128
+ # Fall back on doing an unlocked resolve at runtime.
125
129
  require "rubygems"
126
130
  require "bundler"
127
131
  Bundler.setup
@@ -134,17 +138,17 @@ context of the bundle. For example:
134
138
 
135
139
  bundle exec ruby my_ruby_script.rb
136
140
 
137
- To enter a shell that will run all gem executables (such as rake, rails,
141
+ To enter a shell that will run all gem executables (such as `rake`, `rails`,
138
142
  etc... ) use `bundle exec bash` (replacing bash for whatever your favorite
139
143
  shell is).
140
144
 
141
145
  ### Packing the bundle's gems
142
146
 
143
- When sharing or deploying an application, it might be useful to include
147
+ When sharing or deploying an application, you may want to include
144
148
  everything necessary to install gem dependencies. `bundle pack` will
145
149
  copy .gem files for all of the bundle's dependencies into vendor/cache.
146
- This way, bundle install can always work no matter what the state of the
147
- remote sources.
150
+ After that, `bundle install` will always work, since it will install the
151
+ local .gem files, and will not contact any of the remote sources.
148
152
 
149
153
  ## Gem resolution
150
154
 
@@ -180,11 +184,18 @@ so it can detect that all gems *together* require activesupport "2.3.4".
180
184
 
181
185
  ## Upgrading from Bundler 0.8 to 0.9 and above
182
186
 
183
- Bundler 0.9 changes a number of APIs in the Gemfile.
187
+ Upgrading to Bundler 0.9 from Bundler 0.8 requires upgrading several
188
+ API calls in your Gemfile, and some workarounds if you are using Rails 2.3.
189
+
190
+ ### Rails 2.3
191
+
192
+ Using Bundler 0.9 with Rails 2.3 requires adding a preinitializer, and
193
+ making a few changes to boot.rb. The exact changes needed can be found at
194
+ [http://gist.github.com/302406](http://gist.github.com/302406).
184
195
 
185
196
  ### Gemfile Removals
186
197
 
187
- The following Bundler 0.8 APIs are no longer supported:
198
+ Bundler 0.9 removes the following Bundler 0.8 Gemfile APIs:
188
199
 
189
200
  1. `disable_system_gems`: This is now the default (and only) option
190
201
  for bundler. Bundler uses the system gems you have specified
@@ -208,6 +219,8 @@ The following Bundler 0.8 APIs are no longer supported:
208
219
 
209
220
  ### Gemfile Changes
210
221
 
222
+ Bundler 0.9 changes the following Bundler 0.8 Gemfile APIs:
223
+
211
224
  1. Bundler 0.8 supported :only and :except as APIs for describing
212
225
  groups of gems. Bundler 0.9 supports a single `group` method,
213
226
  which you can use to group gems together. See the above "Group"
@@ -237,13 +250,16 @@ The following Bundler 0.8 APIs are no longer supported:
237
250
 
238
251
  2. `require 'vendor/gems/environment'`: In unlocked
239
252
  mode, where using system gems, this becomes
240
- `Bundler.setup(:multiple, groups)`. If you don't
253
+ `Bundler.setup(:multiple, :groups)`. If you don't
241
254
  specify any groups, this puts all groups on the load
242
255
  path. In locked, mode, it becomes `require '.bundle/environment'`
243
256
 
244
- ## Reporting bugs
257
+ ## More information
245
258
 
246
- Please report all bugs on the github issue tracker for the project located
247
- at:
259
+ Explanations of common Bundler use cases can be found in [Using Bundler in Real Life](http://yehudakatz.com/2010/02/09/using-bundler-in-real-life/). The general philosophy behind Bundler 0.9 is explained at some length in [Bundler 0.9: Heading Toward 1.0](http://yehudakatz.com/2010/02/01/bundler-0-9-heading-toward-1-0/).
260
+
261
+ Any remaining questions may be directed via email to the [Bundler mailing list](http://groups.google.com/group/ruby-bundler) or via IRC to [#carlhuda](irc://irc.freenode.net/carlhuda) on Freenode.
262
+
263
+ ## Reporting bugs
248
264
 
249
- http://github.com/carlhuda/bundler/issues/
265
+ Please report all bugs on the github issue tracker for the project, located at [http://github.com/carlhuda/bundler/issues/](http://github.com/carlhuda/bundler/issues/).
data/bin/bundle CHANGED
@@ -2,7 +2,7 @@
2
2
  require 'bundler'
3
3
  $:.each do |path|
4
4
  if path =~ %r'/bundler-0.(\d+)' && $1.to_i < 9
5
- abort "Please remove older versions of bundler. This can by running `gem cleanup`."
5
+ abort "Please remove older versions of bundler. This can be done by running `gem cleanup bundler`."
6
6
  end
7
7
  end
8
8
  require 'bundler/cli'
@@ -4,7 +4,7 @@ require 'yaml'
4
4
  require 'bundler/rubygems-ext'
5
5
 
6
6
  module Bundler
7
- VERSION = "0.9.5"
7
+ VERSION = "0.9.6"
8
8
 
9
9
  autoload :Definition, 'bundler/definition'
10
10
  autoload :Dependency, 'bundler/dependency'
@@ -17,6 +17,9 @@ module Bundler
17
17
  def gem(name, *args)
18
18
  options = Hash === args.last ? args.pop : {}
19
19
  version = args.last || ">= 0"
20
+ if options[:group]
21
+ options[:group] = options[:group].to_sym
22
+ end
20
23
 
21
24
  _deprecated_options(options)
22
25
  _normalize_options(name, version, options)
@@ -48,7 +51,7 @@ module Bundler
48
51
  end
49
52
 
50
53
  def group(name, options = {}, &blk)
51
- old, @group = @group, name
54
+ old, @group = @group, name.to_sym
52
55
  yield
53
56
  ensure
54
57
  @group = old
@@ -77,11 +80,14 @@ module Bundler
77
80
  end
78
81
 
79
82
  def _normalize_hash(opts)
80
- opts.each do |k, v|
83
+ # Cannot modify a hash during an iteration in 1.9
84
+ opts.keys.each do |k|
81
85
  next if String === k
86
+ v = opts[k]
82
87
  opts.delete(k)
83
88
  opts[k.to_s] = v
84
89
  end
90
+ opts
85
91
  end
86
92
 
87
93
  def _normalize_options(name, version, opts)
@@ -12,6 +12,9 @@ module Bundler
12
12
  return
13
13
  end
14
14
 
15
+ # Ensure that BUNDLE_PATH exists
16
+ FileUtils.mkdir_p(Bundler.bundle_path)
17
+
15
18
  specs.sort_by { |s| s.name }.each do |spec|
16
19
  # unless spec.source.is_a?(Source::SystemGems)
17
20
  Bundler.ui.info "Installing #{spec.name} (#{spec.version}) from #{spec.source} "
@@ -135,6 +135,7 @@ module Bundler
135
135
  shared_helpers = File.read(File.expand_path("../shared_helpers.rb", __FILE__))
136
136
  template = File.read(File.expand_path("../templates/environment.erb", __FILE__))
137
137
  erb = ERB.new(template, nil, '-')
138
+ FileUtils.mkdir_p(rb_lock_file.dirname)
138
139
  File.open(rb_lock_file, 'w') do |f|
139
140
  f.puts erb.result(binding)
140
141
  end
@@ -159,9 +160,9 @@ module Bundler
159
160
  end
160
161
 
161
162
  details["dependencies"] = @definition.dependencies.inject({}) do |h,d|
162
- h.merge!({d.name => {"version" => d.version_requirements.to_s, "group" => d.groups} })
163
- h[d.name]['require'] = d.autorequire if d.autorequire
164
- h
163
+ info = {"version" => d.version_requirements.to_s, "group" => d.groups}
164
+ info.merge!("require" => d.autorequire) if d.autorequire
165
+ h.merge(d.name => info)
165
166
  end
166
167
  details
167
168
  end
@@ -185,7 +186,14 @@ module Bundler
185
186
  def autorequires_for_groups(*groups)
186
187
  groups.map! { |g| g.to_sym }
187
188
  autorequires = Hash.new { |h,k| h[k] = [] }
188
- @definition.dependencies.each do |dep|
189
+
190
+ ordered_deps = []
191
+ specs_for(*groups).each do |g|
192
+ dep = @definition.dependencies.find{|d| d.name == g.name }
193
+ ordered_deps << dep if dep && !ordered_deps.include?(dep)
194
+ end
195
+
196
+ ordered_deps.each do |dep|
189
197
  dep.groups.each do |group|
190
198
  # If there is no autorequire, then rescue from
191
199
  # autorequiring the gems name
@@ -247,7 +255,8 @@ module Bundler
247
255
  source_index_class = (class << Gem::SourceIndex ; self ; end)
248
256
  source_index_class.send(:define_method, :from_gems_in) do |*args|
249
257
  source_index = Gem::SourceIndex.new
250
- source_index.add_specs *specs
258
+ source_index.spec_dirs = *args
259
+ source_index.add_specs(*specs)
251
260
  source_index
252
261
  end
253
262
 
@@ -34,7 +34,7 @@ module Bundler
34
34
  until !File.directory?(current) || current == previous
35
35
  filename = File.join(current, 'Gemfile')
36
36
  return filename if File.file?(filename)
37
- current, previous = File.expand_path("#{current}/.."), current
37
+ current, previous = File.expand_path("..", current), current
38
38
  end
39
39
  end
40
40
 
@@ -236,7 +236,7 @@ module Bundler
236
236
  # Loop over the lines and extract the relative path and the
237
237
  # git hash
238
238
  lines.each do |line|
239
- next unless line =~ %r{^(\d+) (blob|tree) ([a-zf0-9]+)\t(.*)$}
239
+ next unless line =~ %r{^(\d+) (blob|tree) ([a-f0-9]+)\t(.*)$}
240
240
  hash, file = $3, $4
241
241
  # Read the gemspec
242
242
  if spec = eval(%x(git cat-file blob #{$3}))
@@ -31,6 +31,7 @@ module Bundler
31
31
 
32
32
  def self.setup(*groups)
33
33
  match_fingerprint
34
+ clean_load_path
34
35
  SPECS.each do |spec|
35
36
  spec[:load_paths].each { |path| $LOAD_PATH.unshift path }
36
37
  end
@@ -53,6 +54,11 @@ module Bundler
53
54
  end
54
55
 
55
56
  def self.patch_rubygems
57
+ Kernel.class_eval do
58
+ private
59
+ def gem(*) ; end
60
+ end
61
+ Gem.source_index # ensure RubyGems is fully loaded
56
62
  specs = SPECS
57
63
 
58
64
  ::Kernel.send(:define_method, :gem) do |dep, *reqs|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.5
4
+ version: 0.9.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Carl Lerche
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2010-02-12 00:00:00 -08:00
13
+ date: 2010-02-16 00:00:00 -08:00
14
14
  default_executable:
15
15
  dependencies: []
16
16