bundler 0.8.1 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. data/README.markdown +76 -208
  2. data/bin/bundle +8 -0
  3. data/lib/bundler/cli.rb +72 -65
  4. data/lib/bundler/definition.rb +80 -0
  5. data/lib/bundler/dependency.rb +7 -57
  6. data/lib/bundler/dsl.rb +48 -143
  7. data/lib/bundler/environment.rb +124 -52
  8. data/lib/bundler/index.rb +92 -0
  9. data/lib/bundler/installer.rb +157 -0
  10. data/lib/bundler/remote_specification.rb +6 -2
  11. data/lib/bundler/resolver.rb +20 -50
  12. data/lib/bundler/rubygems.rb +22 -0
  13. data/lib/bundler/settings.rb +29 -0
  14. data/lib/bundler/setup.rb +3 -0
  15. data/lib/bundler/source.rb +222 -283
  16. data/lib/bundler/specification.rb +22 -0
  17. data/lib/bundler/templates/Gemfile +4 -0
  18. data/lib/bundler/templates/environment.erb +3 -153
  19. data/lib/bundler/ui.rb +55 -0
  20. data/lib/bundler/vendor/thor/base.rb +530 -0
  21. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  22. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  23. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  24. data/lib/bundler/vendor/thor/error.rb +27 -0
  25. data/lib/bundler/vendor/thor/invocation.rb +178 -0
  26. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  27. data/lib/bundler/vendor/thor/parser/arguments.rb +145 -0
  28. data/lib/bundler/vendor/thor/parser/option.rb +132 -0
  29. data/lib/bundler/vendor/thor/parser/options.rb +142 -0
  30. data/lib/bundler/vendor/thor/parser.rb +4 -0
  31. data/lib/bundler/vendor/thor/shell/basic.rb +239 -0
  32. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  33. data/lib/bundler/vendor/thor/shell.rb +78 -0
  34. data/lib/bundler/vendor/thor/task.rb +111 -0
  35. data/lib/bundler/vendor/thor/util.rb +233 -0
  36. data/lib/bundler/vendor/thor/version.rb +3 -0
  37. data/lib/bundler/vendor/thor.rb +240 -0
  38. data/lib/bundler.rb +113 -34
  39. metadata +41 -26
  40. data/Rakefile +0 -81
  41. data/lib/bundler/bundle.rb +0 -314
  42. data/lib/bundler/commands/bundle_command.rb +0 -72
  43. data/lib/bundler/commands/exec_command.rb +0 -36
  44. data/lib/bundler/finder.rb +0 -51
  45. data/lib/bundler/gem_bundle.rb +0 -11
  46. data/lib/bundler/gem_ext.rb +0 -34
  47. data/lib/bundler/runtime.rb +0 -2
  48. data/lib/bundler/templates/app_script.erb +0 -3
  49. data/lib/bundler/templates/environment_picker.erb +0 -4
  50. data/lib/rubygems_plugin.rb +0 -6
data/README.markdown CHANGED
@@ -9,108 +9,110 @@
9
9
  Bundler is a tool that manages gem dependencies for your ruby application. It
10
10
  takes a gem manifest file and is able to fetch, download, and install the gems
11
11
  and all child dependencies specified in this manifest. It can manage any update
12
- to the gem manifest file and update the bundled gems accordingly. It also lets
13
- you run any ruby code in context of the bundled gem environment.
12
+ to the gem manifest file and update the bundle's gems accordingly. It also lets
13
+ you run any ruby code in context of the bundle's gem environment.
14
14
 
15
15
  ## Installation
16
16
 
17
- Bundler has no dependencies. Just clone the git repository and install the gem
18
- with the following rake task:
17
+ Bundler has no dependencies besides Ruby and RubyGems. Just clone the git
18
+ repository and install the gem with the following rake task:
19
19
 
20
20
  rake install
21
21
 
22
22
  You can also install the gem with
23
23
 
24
- gem install bundler
25
-
24
+ gem install bundler --prerelease
25
+
26
26
  ## Usage
27
27
 
28
- Bundler requires a gem manifest file to be created. This should be a file named
29
- `Gemfile` located in the root directory of your application. After the manifest
30
- has been created, in your shell, cd into your application's directory and run
31
- `gem bundle`. This will start the bundling process.
28
+ The first thing to do is create a gem manifest file named `Gemfile` at the
29
+ root directory of your application. This can quickly be done by running
30
+ `bundle init` in the directory that you wish the Gemfile to be created in.
31
+
32
+ ### Gemfile
32
33
 
33
- ### Manifest file
34
+ This is where you specify all of your application's dependencies. The
35
+ following is an example. For more information, refer to
36
+ Bundler::Dsl.
34
37
 
35
- This is where you specify all of your application's dependencies. By default
36
- this should be in a file named `Gemfile` located in your application's root
37
- directory. The following is an example of a potential `Gemfile`. For more
38
- information, please refer to Bundler::ManifestBuilder.
38
+ # Add :gemcutter as a source that Bundler will use
39
+ # to find gems listed in the manifest. At least one source
40
+ # should be listed. URLs maybe also be used, such as
41
+ # http://gems.github.com.
42
+ #
43
+ source :gemcutter
39
44
 
40
- # Specify a dependency on rails. When the bundler downloads gems,
41
- # it will download rails as well as all of rails' dependencies (such as
42
- # activerecord, actionpack, etc...)
45
+ # Specify a dependency on rails. When bundler downloads gems,
46
+ # it will download rails as well as all of rails' dependencies
47
+ # (such as activerecord, actionpack, etc...)
43
48
  #
44
49
  # At least one dependency must be specified
50
+ #
45
51
  gem "rails"
46
52
 
47
- # Specify a dependency on rack v.1.0.0. The version is optional. If present,
48
- # it can be specified the same way as with rubygems' #gem method.
53
+ # Specify a dependency on rack v.1.0.0. The version is optional.
54
+ # If present, it can be specified the same way as with rubygems'
55
+ # #gem method.
56
+ #
49
57
  gem "rack", "1.0.0"
50
58
 
51
- # Specify a dependency rspec, but only require that gem in the "testing"
52
- # environment. :except is also a valid option to specify environment
53
- # restrictions.
54
- gem "rspec", :only => :testing
59
+ ### Installing gems
55
60
 
56
- # Specify a dependency, but specify that it is already present and expanded
57
- # at vendor/rspec. Bundler will treat rspec as though it was the rspec gem
58
- # for the purpose of gem resolution: if another gem depends on a version
59
- # of rspec satisfied by "1.1.6", it will be used.
60
- #
61
- # If a gemspec is found in the directory, it will be used to specify load
62
- # paths and supply additional dependencies.
63
- #
64
- # Bundler will also recursively search for *.gemspec, and assume that
65
- # gemspecs it finds represent gems that are rooted in the same directory
66
- # the gemspec is found in.
67
- gem "rspec", "1.1.6", :vendored_at => "vendor/rspec"
61
+ Once the manifest file has been created, the next step is to install all
62
+ the gems needed to satisfy the Gemfile's dependencies. The `bundle install`
63
+ command will do this.
68
64
 
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.
65
+ This command will load the Gemfile, resolve all the dependencies, download
66
+ all gems that are missing, and install them to the system's RubyGems
67
+ repository. Every time an update is made to the Gemfile, run `bundle install`
68
+ again to get the new gems installed.
71
69
 
72
- # Don't auto-require this gem.
73
- gem "rspec-rails", "1.2.9", :require_as => nil
70
+ ### Locking dependencies
74
71
 
75
- # Require something other than the default.
76
- gem "yajl-ruby", "0.6.7", :require_as => "yajl/json_gem"
72
+ By default, bundler will only ensure that the activated gems satisfy the
73
+ Gemfile's dependencies. If you install a newer version of a gem and it
74
+ satisfies the dependencies, it will be used instead of the older one.
77
75
 
78
- # Works exactly like :vendored_at, but first downloads the repo from
79
- # git and handles stashing the files for you. As with :vendored_at,
80
- # Bundler will automatically use *.gemspec files in the root or anywhere
81
- # in the repository.
82
- gem "rails", "3.0.pre", :git => "git://github.com/rails/rails.git"
76
+ The command `bundle lock` will lock the bundle to the current set of
77
+ resolved gems. This ensures that, until the lock file is removed, that
78
+ bundle install and Bundle.setup will always activate the same gems.
83
79
 
84
- # Add http://gems.github.com as a source that the bundler will use
85
- # to find gems listed in the manifest. By default,
86
- # http://gems.rubyforge.org is already added to the list.
87
- #
88
- # This is an optional setting.
89
- source "http://gems.github.com"
80
+ ### Running the application
90
81
 
91
- # Specify where the bundled gems should be stashed. This directory will
92
- # be a gem repository where all gems are downloaded to and installed to.
93
- #
94
- # This is an optional setting.
95
- # The default is: vendor/gems
96
- bundle_path "my/bundled/gems"
82
+ Bundler must be required and setup before anything else is required. This
83
+ is because it will configure all the load paths and manage rubygems for your.
84
+ To do this, include the following at the beginning of your code.
97
85
 
98
- # Specify where gem executables should be copied to.
99
- #
100
- # This is an optional setting.
101
- # The default is: bin
102
- bin_path "my/executables"
86
+ begin
87
+ # Require the preresolved locked set of gems.
88
+ require File.expand_path('../.bundle/environment', __FILE__)
89
+ rescue LoadError
90
+ # Fallback on doing the resolve at runtime.
91
+ require "rubygems"
92
+ require "bundler"
93
+ Bundler.setup
94
+ end
103
95
 
104
- # Specify that rubygems should be completely disabled. This means that it
105
- # will be impossible to require it and that available gems will be
106
- # limited exclusively to gems that have been bundled.
107
- #
108
- # The default is to automatically require rubygems. There is also a
109
- # `disable_system_gems` option that will limit available rubygems to
110
- # the ones that have been bundled.
111
- disable_rubygems
96
+ # Your application requires come here
97
+
98
+ The `bundle exec` command provides a way to run arbitrary ruby code in
99
+ context of the bundle. For example:
100
+
101
+ bundle exec ruby my_ruby_script.rb
102
+
103
+ To enter a shell that will run all gem executables (such as rake, rails,
104
+ etc... ) use `bundle exec bash` (replacing bash for whatever your favorite
105
+ shell is).
106
+
107
+ ### Packing the bundle's gems
112
108
 
113
- ### Gem Resolution
109
+ When sharing or deploying an application, it might be useful to include
110
+ everything necessary to install gem dependencies. `bundle pack` will
111
+ copy .gem files for all of the bundle's dependencies into vendor/cache.
112
+ This way, bundle install can always work no matter what the state of the
113
+ remote sources.
114
+
115
+ ## Gem resolution
114
116
 
115
117
  One of the most important things that the bundler does is do a
116
118
  dependency resolution on the full list of gems that you specify, all
@@ -142,143 +144,9 @@ a more narrow dependency.
142
144
  Bundler solves this problem by evaluating all dependencies at once,
143
145
  so it can detect that all gems *together* require activesupport "2.3.4".
144
146
 
145
- ### Running Bundler
146
-
147
- Once a manifest file has been created, the only thing that needs to be done
148
- is to run the `gem bundle` command anywhere in your application. The script
149
- will load the manifest file, resolve all the dependencies, download all
150
- needed gems, and install them into the specified directory.
151
-
152
- Every time an update is made to the manifest file, run `gem bundle` again to
153
- get the changes installed. This will only check the remote sources if your
154
- currently installed gems do not satisfy the `Gemfile`. If you want to force
155
- checking for updates on the remote sources, use the `--update` option.
156
-
157
- ### Remote deploys
158
-
159
- When you run `gem bundle`, the following steps occur:
160
-
161
- 1. Gemfile is read in
162
- 2. The gems specified in the Gemfile are resolved against the gems
163
- already in your bundle. If the dependencies resolve, skip to step 5.
164
- 3. If the dependencies in your Gemfile cannot be fully resolved
165
- against the gems already in the bundle, the metadata for each
166
- source is fetched.
167
- 4. The gems in the Gemfile are resolved against the full list of
168
- available gems in all sources, and the resulting gems are downloaded
169
- 5. Each gem that has been downloaded but not yet expanded is expanded
170
- into the local directory. This expansion process also installs
171
- native gems.
172
-
173
- As you can see, if you run gem bundle twice in a row, it will do nothing the
174
- second time, since the gems obviously resolve against the installed gems,
175
- and they are all expanded.
176
-
177
- This also means that if you run `gem bundle`, and .gitignore the expanded
178
- copies, leaving only the cached `.gem` files, you can run `gem bundle` again
179
- on the remote system, and it will only expand out the gems (but not
180
- resolve or download `.gem` files). This also means that native gems
181
- will be compiled for the target platform without requiring that the
182
- `.gem` file itself be downloaded from a remote gem server.
183
-
184
- Assuming a Rails app with Bundler's standard setup, add something like
185
- this to your top-level `.gitignore` to only keep the cache:
186
-
187
- bin/*
188
- vendor/gems/*
189
- !vendor/gems/cache/
190
-
191
- Make sure that you explicitly `git add vendor/gems/cache` before you commit.
192
-
193
- ### Gems with compile-time options
194
-
195
- Some gems require you to pass compile-time options to the gem install command.
196
- For instance, to install mysql, you might do:
197
-
198
- gem install mysql -- --with-mysql-config=/usr/local/lib/mysql
199
-
200
- You can pass these options to the bundler by creating a YAML file containing
201
- the options in question:
202
-
203
- mysql:
204
- mysql-config: /usr/local/lib/mysql
205
-
206
- You can then point the bundler at the file:
207
-
208
- gem bundle --build-options build_options.yml
209
-
210
- In general, you will want to keep the build options YAML out of version control,
211
- and provide the appropriate options for the system in question.
212
-
213
- ### Running your application
214
-
215
- The easiest way to run your application is to start it with an executable
216
- copied to the specified bin directory (by default, simply bin). For example,
217
- if the application in question is a rack app, start it with `bin/rackup`.
218
- This will automatically set the gem environment correctly.
219
-
220
- Another way to run arbitrary ruby code in context of the bundled gems is to
221
- run it with the `gem exec` command. For example:
222
-
223
- gem exec ruby my_ruby_script.rb
224
-
225
- You can use `gem exec bash` to enter a shell that will run all binaries in
226
- the current context.
227
-
228
- Yet another way is to manually require the environment file first. This is
229
- located in `[bundle_path]/gems/environment.rb`. For example:
230
-
231
- ruby -r vendor/gems/environment.rb my_ruby_script.rb
232
-
233
- ### Using Bundler with Rails today
234
-
235
- It should be possible to use Bundler with Rails today. Here are the steps
236
- to follow.
237
-
238
- * In your rails app, create a Gemfile and specify the gems that your
239
- application depends on. Make sure to specify rails as well:
240
-
241
- gem "rails", "2.1.2"
242
- gem "will_paginate"
243
-
244
- # Optionally, you can disable system gems all together and only
245
- # use bundled gems.
246
- disable_system_gems
247
-
248
- * Run `gem bundle`
249
-
250
- * You can now use rails if you prepend `gem exec` to every call to `script/*`
251
- but that isn't fun.
252
-
253
- * At the top of `config/preinitializer.rb`, add the following line:
254
-
255
- require "#{RAILS_ROOT}/vendor/gems/environment"
256
-
257
- In theory, this should be enough to get going.
258
-
259
- ## To require rubygems or not
260
-
261
- Ideally, no gem would assume the presence of rubygems at runtime. Rubygems provides
262
- enough features so that this isn't necessary. However, there are a number of gems
263
- that require specific rubygems features.
264
-
265
- If the `disable_rubygems` option is used, Bundler will stub out the most common
266
- of these features, but it is possible that things will not go as intended quite
267
- yet. So, if you are brave, try your code without rubygems at runtime.
268
-
269
- This is different from the `disable_system_gems` option, which uses the rubygems
270
- library, but prevents system gems from being loaded; only gems that are bundled
271
- will be available to your application. This option guarantees that dependencies
272
- of your application will be available to a remote system.
273
-
274
- ## Known Issues
275
-
276
- * When a gem points to a git repository, the git repository will be cloned
277
- every time Bundler does a gem dependency resolve.
278
-
279
147
  ## Reporting bugs
280
148
 
281
149
  Please report all bugs on the github issue tracker for the project located
282
150
  at:
283
151
 
284
- http://github.com/wycats/bundler/issues/
152
+ http://github.com/wycats/bundler/issues/
data/bin/bundle ADDED
@@ -0,0 +1,8 @@
1
+ require 'bundler/cli'
2
+
3
+ begin
4
+ Bundler::CLI.start
5
+ rescue Bundler::BundlerError => e
6
+ Bundler.ui.error e.message
7
+ exit e.status_code
8
+ end
data/lib/bundler/cli.rb CHANGED
@@ -1,88 +1,95 @@
1
- require "optparse"
1
+ $:.unshift File.expand_path('../vendor', __FILE__)
2
+ require 'thor'
3
+ require 'bundler'
4
+ require 'rubygems/config_file'
5
+
6
+ # Work around a RubyGems bug
7
+ Gem.configuration
2
8
 
3
9
  module Bundler
4
- class CLI
5
- def self.run(command, options = {})
6
- new(options).run(command)
7
- rescue DefaultManifestNotFound => e
8
- Bundler.logger.error "Could not find a Gemfile to use"
9
- exit 3
10
- rescue InvalidEnvironmentName => e
11
- Bundler.logger.error "Gemfile error: #{e.message}"
12
- exit 4
13
- rescue InvalidRepository => e
14
- Bundler.logger.error e.message
15
- exit 5
16
- rescue VersionConflict => e
17
- Bundler.logger.error e.message
18
- exit 6
19
- rescue GemNotFound => e
20
- Bundler.logger.error e.message
21
- exit 7
22
- rescue InvalidCacheArgument => e
23
- Bundler.logger.error e.message
24
- exit 8
25
- rescue SourceNotCached => e
26
- Bundler.logger.error e.message
27
- exit 9
28
- rescue ManifestFileNotFound => e
29
- Bundler.logger.error e.message
30
- exit 10
31
- end
10
+ class CLI < Thor
11
+ ARGV = ::ARGV.dup
32
12
 
33
- def initialize(options)
34
- Bundler.mode = options[:cached] ? :local : :readwrite
35
- @options = options
36
- @bundle = Bundle.load(@options[:manifest])
13
+ desc "init", "Generates a Gemfile into the current working directory"
14
+ def init
15
+ if File.exist?("Gemfile")
16
+ puts "Gemfile already exists at #{Dir.pwd}/Gemfile"
17
+ else
18
+ puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
19
+ FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile')
20
+ end
37
21
  end
38
22
 
39
- def bundle
40
- @bundle.install(@options)
23
+ def initialize(*)
24
+ super
25
+ Bundler.ui = UI::Shell.new(shell)
26
+ Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui)
41
27
  end
42
28
 
43
- def cache
44
- gemfile = @options[:cache]
45
-
46
- if File.extname(gemfile) == ".gem"
47
- if !File.exist?(gemfile)
48
- raise InvalidCacheArgument, "'#{gemfile}' does not exist."
49
- end
50
- @bundle.cache(gemfile)
51
- elsif File.directory?(gemfile) || gemfile.include?('/')
52
- if !File.directory?(gemfile)
53
- raise InvalidCacheArgument, "'#{gemfile}' does not exist."
29
+ desc "check", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
30
+ def check
31
+ env = Bundler.load
32
+ # Check top level dependencies
33
+ missing = env.dependencies.select { |d| env.index.search(d).empty? }
34
+ if missing.any?
35
+ puts "The following dependencies are missing"
36
+ missing.each do |d|
37
+ puts " * #{d}"
54
38
  end
55
- gemfiles = Dir["#{gemfile}/*.gem"]
56
- if gemfiles.empty?
57
- raise InvalidCacheArgument, "'#{gemfile}' contains no gemfiles"
58
- end
59
- @bundle.cache(*gemfiles)
60
39
  else
61
- raise InvalidCacheArgument, "w0t? '#{gemfile}' means nothing to me."
40
+ env.specs
41
+ puts "The Gemfile's dependencies are satisfied"
62
42
  end
63
43
  end
64
44
 
65
- def prune
66
- Bundler.mode = :local
67
- @bundle.prune(@options)
45
+ desc "install", "Install the current environment to the system"
46
+ method_option :without, :type => :array, :banner => "Exclude gems thar are part of the specified named group"
47
+ def install(path = nil)
48
+ opts = options.dup
49
+ opts[:without] ||= []
50
+ opts[:without].map! { |g| g.to_sym }
51
+
52
+ Bundler.settings[:path] = path if path
53
+
54
+ Installer.install(Bundler.root, Bundler.definition, opts)
55
+ end
56
+
57
+ desc "lock", "Locks the bundle to the current set of dependencies, including all child dependencies."
58
+ def lock
59
+ environment = Bundler.load
60
+ environment.lock
68
61
  end
69
62
 
70
- def list
71
- @bundle.list(@options)
63
+ desc "unlock", "Unlock the bundle. This allows gem versions to be changed"
64
+ def unlock
65
+ environment = Bundler.load
66
+ environment.unlock
72
67
  end
73
68
 
74
- def list_outdated
75
- @bundle.list_outdated(@options)
69
+ desc "show", "Shows all gems that are part of the bundle."
70
+ def show
71
+ environment = Bundler.load
72
+ Bundler.ui.info "Gems included by the bundle:"
73
+ environment.specs.sort_by { |s| s.name }.each do |s|
74
+ Bundler.ui.info " * #{s.name} (#{s.version})"
75
+ end
76
76
  end
77
77
 
78
- def exec
79
- @bundle.setup_environment
80
- # w0t?
81
- super(*$command)
78
+ desc "pack", "Packs all the gems to vendor/cache"
79
+ def pack
80
+ environment = Bundler.load
81
+ environment.pack
82
82
  end
83
83
 
84
- def run(command)
85
- send(command)
84
+ desc "exec", "Run the command in context of the bundle"
85
+ def exec(*)
86
+ ARGV.delete('exec')
87
+ ENV["RUBYOPT"] = %W(
88
+ -I#{File.expand_path('../..', __FILE__)}
89
+ -rbundler/setup
90
+ #{ENV["RUBYOPT"]}
91
+ ).compact.join(' ')
92
+ Kernel.exec *ARGV
86
93
  end
87
94
 
88
95
  end
@@ -0,0 +1,80 @@
1
+ module Bundler
2
+ class Definition
3
+ def self.from_gemfile(gemfile)
4
+ gemfile = Pathname.new(gemfile).expand_path
5
+
6
+ unless gemfile.file?
7
+ raise GemfileNotFound, "#{gemfile} not found"
8
+ end
9
+
10
+ Dsl.evaluate(gemfile)
11
+ end
12
+
13
+ def self.from_lock(lockfile)
14
+ # gemfile_definition = from_gemfile(nil)
15
+ locked_definition = Locked.new(YAML.load_file(lockfile))
16
+ # raise GemfileError unless gemfile_definition.equivalent?(locked_definition)
17
+ locked_definition
18
+ end
19
+
20
+ attr_reader :dependencies, :sources
21
+
22
+ alias actual_dependencies dependencies
23
+
24
+ def initialize(dependencies, sources)
25
+ @dependencies = dependencies
26
+ @sources = sources
27
+ end
28
+
29
+ def local_index
30
+ @local_index ||= begin
31
+ index = Index.new
32
+
33
+ sources.each do |source|
34
+ next unless source.respond_to?(:local_specs)
35
+ index = source.local_specs.merge(index)
36
+ end
37
+
38
+ Index.from_installed_gems.merge(index)
39
+ end
40
+ end
41
+
42
+ # def equivalent?(other)
43
+ # self.matches?(other) && other.matches?(self)
44
+ # # other.matches?(self)
45
+ # end
46
+
47
+ # def matches?(other)
48
+ # dependencies.all? do |dep|
49
+ # dep =~ other.specs.find {|spec| spec.name == dep.name }
50
+ # end
51
+ # end
52
+
53
+ class Locked < Definition
54
+ def initialize(details)
55
+ @details = details
56
+ end
57
+
58
+ def sources
59
+ @sources ||= @details["sources"].map do |args|
60
+ name, options = args.to_a.flatten
61
+ Bundler::Source.const_get(name).new(options)
62
+ end
63
+ end
64
+
65
+ def actual_dependencies
66
+ @actual_dependencies ||= @details["specs"].map do |args|
67
+ name, details = args.to_a.flatten
68
+ details["source"] = sources[details["source"]] if details.include?("source")
69
+ Bundler::Dependency.new(name, details.delete("version"), details)
70
+ end
71
+ end
72
+
73
+ def dependencies
74
+ @dependencies ||= @details["dependencies"].map do |args|
75
+ Bundler::Dependency.new(*args.to_a.flatten)
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,62 +1,12 @@
1
- module Bundler
2
- class InvalidEnvironmentName < StandardError; end
1
+ require 'rubygems/dependency'
3
2
 
3
+ module Bundler
4
4
  class Dependency < Gem::Dependency
5
- attr_reader :name, :version, :require_as, :only, :except
6
- attr_accessor :source
7
-
8
- def initialize(name, options = {}, &block)
9
- options.each do |k, v|
10
- options[k.to_s] = v
11
- end
12
-
13
- super(name, options["version"] || ">= 0")
14
-
15
- @require_as = options["require_as"]
16
- @only = options["only"]
17
- @except = options["except"]
18
- @source = options["source"]
19
- @block = block
20
-
21
- if (@only && @only.include?("rubygems")) || (@except && @except.include?("rubygems"))
22
- raise InvalidEnvironmentName, "'rubygems' is not a valid environment name"
23
- end
24
- end
25
-
26
- def in?(environment)
27
- environment = environment.to_s
28
-
29
- return false unless !@only || @only.include?(environment)
30
- return false if @except && @except.include?(environment)
31
- true
32
- end
33
-
34
- def require_env(environment)
35
- return unless in?(environment)
36
-
37
- if @require_as
38
- Array(@require_as).each { |file| require file }
39
- else
40
- begin
41
- require name
42
- rescue LoadError
43
- # Do nothing
44
- end
45
- end
46
-
47
- @block.call if @block
48
- end
5
+ def initialize(name, version, options = {}, &blk)
6
+ super(name, version)
49
7
 
50
- def no_bundle?
51
- source == SystemGemSource.instance
8
+ @group = options["group"] || :default
9
+ @source = options["source"]
52
10
  end
53
-
54
- def ==(o)
55
- [name, version, require_as, only, except] ==
56
- [o.name, o.version, o.require_as, o.only, o.except]
57
- end
58
-
59
- alias version version_requirements
60
-
61
11
  end
62
- end
12
+ end