bundler 0.8.1 → 0.9.0.pre1

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.

Files changed (58) hide show
  1. data/README +7 -0
  2. data/bin/bundle +3 -0
  3. data/lib/bundler.rb +72 -37
  4. data/lib/bundler/cli.rb +64 -68
  5. data/lib/bundler/definition.rb +78 -0
  6. data/lib/bundler/dependency.rb +7 -57
  7. data/lib/bundler/dsl.rb +42 -142
  8. data/lib/bundler/environment.rb +94 -54
  9. data/lib/bundler/index.rb +98 -0
  10. data/lib/bundler/installer.rb +137 -0
  11. data/lib/bundler/remote_specification.rb +1 -1
  12. data/lib/bundler/resolver.rb +20 -50
  13. data/lib/bundler/rubygems.rb +22 -0
  14. data/lib/bundler/source.rb +185 -295
  15. data/lib/bundler/specification.rb +22 -0
  16. data/lib/bundler/templates/Gemfile +4 -0
  17. data/lib/bundler/templates/environment.erb +3 -153
  18. data/lib/bundler/ui.rb +51 -0
  19. data/lib/bundler/vendor/thor.rb +241 -0
  20. data/lib/bundler/vendor/thor/actions.rb +274 -0
  21. data/lib/bundler/vendor/thor/actions/create_file.rb +103 -0
  22. data/lib/bundler/vendor/thor/actions/directory.rb +91 -0
  23. data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
  24. data/lib/bundler/vendor/thor/actions/file_manipulation.rb +223 -0
  25. data/lib/bundler/vendor/thor/actions/inject_into_file.rb +101 -0
  26. data/lib/bundler/vendor/thor/base.rb +515 -0
  27. data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
  28. data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
  29. data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
  30. data/lib/bundler/vendor/thor/error.rb +27 -0
  31. data/lib/bundler/vendor/thor/group.rb +267 -0
  32. data/lib/bundler/vendor/thor/invocation.rb +178 -0
  33. data/lib/bundler/vendor/thor/parser.rb +4 -0
  34. data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
  35. data/lib/bundler/vendor/thor/parser/arguments.rb +145 -0
  36. data/lib/bundler/vendor/thor/parser/option.rb +132 -0
  37. data/lib/bundler/vendor/thor/parser/options.rb +142 -0
  38. data/lib/bundler/vendor/thor/rake_compat.rb +66 -0
  39. data/lib/bundler/vendor/thor/runner.rb +303 -0
  40. data/lib/bundler/vendor/thor/shell.rb +78 -0
  41. data/lib/bundler/vendor/thor/shell/basic.rb +239 -0
  42. data/lib/bundler/vendor/thor/shell/color.rb +108 -0
  43. data/lib/bundler/vendor/thor/task.rb +111 -0
  44. data/lib/bundler/vendor/thor/util.rb +233 -0
  45. data/lib/bundler/vendor/thor/version.rb +3 -0
  46. metadata +48 -26
  47. data/README.markdown +0 -284
  48. data/Rakefile +0 -81
  49. data/lib/bundler/bundle.rb +0 -314
  50. data/lib/bundler/commands/bundle_command.rb +0 -72
  51. data/lib/bundler/commands/exec_command.rb +0 -36
  52. data/lib/bundler/finder.rb +0 -51
  53. data/lib/bundler/gem_bundle.rb +0 -11
  54. data/lib/bundler/gem_ext.rb +0 -34
  55. data/lib/bundler/runtime.rb +0 -2
  56. data/lib/bundler/templates/app_script.erb +0 -3
  57. data/lib/bundler/templates/environment_picker.erb +0 -4
  58. data/lib/rubygems_plugin.rb +0 -6
data/Rakefile DELETED
@@ -1,81 +0,0 @@
1
- $:.unshift File.join(File.dirname(__FILE__), 'lib')
2
- require 'rubygems' unless ENV['NO_RUBYGEMS']
3
- require 'rubygems/specification'
4
- require 'bundler'
5
- require 'date'
6
-
7
- spec = Gem::Specification.new do |s|
8
- s.name = "bundler"
9
- s.version = Bundler::VERSION
10
- s.authors = ["Yehuda Katz", "Carl Lerche"]
11
- s.email = ["wycats@gmail.com", "clerche@engineyard.com"]
12
- s.homepage = "http://github.com/wycats/bundler"
13
- s.description = s.summary = "An easy way to vendor gem dependencies"
14
-
15
- s.platform = Gem::Platform::RUBY
16
- s.has_rdoc = true
17
- s.extra_rdoc_files = ["README.markdown", "LICENSE"]
18
-
19
- s.required_rubygems_version = ">= 1.3.5"
20
-
21
- s.require_path = 'lib'
22
- s.files = %w(LICENSE README.markdown Rakefile) + Dir.glob("lib/**/*")
23
- end
24
-
25
- task :default => :spec
26
-
27
- begin
28
- require 'spec/rake/spectask'
29
- rescue LoadError
30
- task(:spec) { $stderr.puts '`gem install rspec` to run specs' }
31
- else
32
- desc "Run specs"
33
- Spec::Rake::SpecTask.new do |t|
34
- t.spec_files = FileList['spec/**/*_spec.rb'] - FileList['spec/fixtures/**/*_spec.rb']
35
- t.spec_opts = %w(-fs --color)
36
- t.warning = true
37
- end
38
- end
39
-
40
- namespace :spec do
41
- file "tmp/rg_deps" do
42
- repo = File.dirname(__FILE__) + '/tmp/rg_deps'
43
- FileUtils.mkdir_p(repo)
44
- p repo
45
- ENV['GEM_HOME'], ENV['GEM_PATH'] = repo, repo
46
- system "gem install builder --no-rdoc --no-ri"
47
- end
48
-
49
- desc "Do all setup needed to run the specs"
50
- task :setup => "tmp/rg_deps"
51
- end
52
-
53
- begin
54
- require 'rake/gempackagetask'
55
- rescue LoadError
56
- task(:gem) { $stderr.puts '`gem install rake` to package gems' }
57
- else
58
- Rake::GemPackageTask.new(spec) do |pkg|
59
- pkg.gem_spec = spec
60
- end
61
- end
62
-
63
- desc "mount a ramdisk at ./tmp for faster specs"
64
- task :ramdisk do
65
- sh 'diskutil erasevolume HFS+ "tmpbundler" `hdiutil attach -nomount ram://116543`'
66
- File.symlink "/Volumes/tmpbundler", File.expand_path('../tmp', __FILE__)
67
- end
68
-
69
- desc "install the gem locally"
70
- task :install => [:package] do
71
- sh %{gem install pkg/#{spec.name}-#{spec.version}}
72
- end
73
-
74
- desc "create a gemspec file"
75
- task :make_spec do
76
- File.open("#{spec.name}.gemspec", "w") do |file|
77
- file.puts spec.to_ruby
78
- end
79
- end
80
-
81
- task :gem => :make_spec
@@ -1,314 +0,0 @@
1
- module Bundler
2
- class InvalidRepository < StandardError ; end
3
-
4
- class Bundle
5
- attr_reader :gemfile, :environment
6
-
7
- def self.load(gemfile = nil)
8
- gemfile = Pathname.new(gemfile || default_gemfile).expand_path
9
-
10
- unless gemfile.file?
11
- raise ManifestFileNotFound, "Manifest file not found: #{gemfile.to_s.inspect}"
12
- end
13
-
14
- new(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
- # TODO: passing in the filename is not good
30
- def initialize(gemfile)
31
- @gemfile = gemfile
32
- @environment = Environment.new(self)
33
- Dsl.evaluate(gemfile, self, @environment)
34
-
35
- # path = env.gem_path
36
-
37
- FileUtils.mkdir_p(gem_path)
38
-
39
- @cache_path = gem_path.join('cache')
40
- @cache = GemDirectorySource.new(self, :location => @cache_path)
41
-
42
- @specs_path = gem_path.join('specifications')
43
- @gems_path = gem_path.join('gems')
44
- end
45
-
46
- def root
47
- gemfile.parent
48
- end
49
-
50
- def path
51
- @path ||= root.join("vendor/gems")
52
- end
53
-
54
- def path=(path)
55
- @path = (path.relative? ? root.join(path) : path).expand_path
56
- end
57
-
58
- def gem_path
59
- path.join("#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}")
60
- end
61
-
62
- def bindir
63
- @bindir ||= root.join("bin")
64
- end
65
-
66
- def bindir=(path)
67
- @bindir = (path.relative? ? root.join(path) : path).expand_path
68
- end
69
-
70
- def install(options = {})
71
- dependencies = @environment.dependencies
72
- sources = @environment.sources
73
-
74
- # ========== from env
75
- if only_envs = options[:only]
76
- dependencies.reject! { |d| !only_envs.any? {|env| d.in?(env) } }
77
- end
78
- # ==========
79
-
80
- # Check to see whether the existing cache meets all the requirements
81
- begin
82
- valid = nil
83
- # valid = Resolver.resolve(dependencies, [source_index], source_requirements)
84
- rescue Bundler::GemNotFound
85
- end
86
-
87
- sources = only_local(sources) if options[:cached]
88
-
89
- # Check the remote sources if the existing cache does not meet the requirements
90
- # or the user passed --update
91
- if options[:update] || !valid
92
- Bundler.logger.info "Calculating dependencies..."
93
- bundle = Resolver.resolve(dependencies, [@cache] + sources)
94
- download(bundle, options)
95
- do_install(bundle, options)
96
- valid = bundle
97
- end
98
-
99
- generate_bins(valid, options)
100
- cleanup(valid, options)
101
- configure(valid, options)
102
-
103
- Bundler.logger.info "Done."
104
- end
105
-
106
- def cache(*gemfiles)
107
- FileUtils.mkdir_p(@cache_path)
108
- gemfiles.each do |gemfile|
109
- Bundler.logger.info "Caching: #{File.basename(gemfile)}"
110
- FileUtils.cp(gemfile, @cache_path)
111
- end
112
- end
113
-
114
- def list_outdated(options={})
115
- outdated_gems = source_index.outdated.sort
116
-
117
- if outdated_gems.empty?
118
- Bundler.logger.info "All gems are up to date."
119
- else
120
- Bundler.logger.info "Outdated gems:"
121
- outdated_gems.each do |name|
122
- Bundler.logger.info " * #{name}"
123
- end
124
- end
125
- end
126
-
127
- def prune(options = {})
128
- dependencies, sources = @environment.dependencies, @environment.sources
129
-
130
- sources = only_local(sources)
131
- bundle = Resolver.resolve(dependencies, [@cache] + sources)
132
- @cache.gems.each do |name, specs|
133
- specs.each do |spec|
134
- unless bundle.any? { |s| s.name == spec.name && s.version == spec.version }
135
- Bundler.logger.info "Pruning #{spec.name} (#{spec.version}) from the cache"
136
- FileUtils.rm @cache_path.join("#{spec.full_name}.gem")
137
- end
138
- end
139
- end
140
- end
141
-
142
- def list(options = {})
143
- Bundler.logger.info "Currently bundled gems:"
144
- gems.each do |spec|
145
- Bundler.logger.info " * #{spec.name} (#{spec.version})"
146
- end
147
- end
148
-
149
- def gems
150
- source_index.gems.values
151
- end
152
-
153
- def source_index
154
- index = Gem::SourceIndex.from_gems_in(@specs_path)
155
- index.each { |n, spec| spec.loaded_from = @specs_path.join("#{spec.full_name}.gemspec") }
156
- index
157
- end
158
-
159
- def download_path_for(type)
160
- @repos[type].download_path_for
161
- end
162
-
163
- def setup_environment
164
- unless @environment.system_gems
165
- ENV["GEM_HOME"] = gem_path
166
- ENV["GEM_PATH"] = gem_path
167
- end
168
- ENV["PATH"] = "#{bindir}:#{ENV["PATH"]}"
169
- ENV["RUBYOPT"] = "-r#{gem_path}/environment #{ENV["RUBYOPT"]}"
170
- end
171
-
172
- private
173
-
174
- def only_local(sources)
175
- sources.select { |s| s.local? }
176
- end
177
-
178
- def download(bundle, options)
179
- bundle.sort_by {|s| s.full_name.downcase }.each do |spec|
180
- next if spec.no_bundle?
181
- spec.source.download(spec)
182
- end
183
- end
184
-
185
- def do_install(bundle, options)
186
- bundle.each do |spec|
187
- next if spec.no_bundle?
188
- spec.loaded_from = @specs_path.join("#{spec.full_name}.gemspec")
189
- # Do nothing if the gem is already expanded
190
- next if @gems_path.join(spec.full_name).directory?
191
-
192
- case spec.source
193
- when GemSource, GemDirectorySource, SystemGemSource
194
- expand_gemfile(spec, options)
195
- else
196
- expand_vendored_gem(spec, options)
197
- end
198
- end
199
- end
200
-
201
- def generate_bins(bundle, options)
202
- bundle.each do |spec|
203
- next if spec.no_bundle?
204
- # HAX -- Generate the bin
205
- bin_dir = bindir
206
- path = gem_path
207
- gems_path = @gems_path
208
- installer = Gem::Installer.allocate
209
- installer.instance_eval do
210
- @spec = spec
211
- @bin_dir = bin_dir
212
- @gem_dir = gems_path.join(spec.full_name)
213
- @gem_home = path
214
- @wrappers = true
215
- @format_executable = false
216
- @env_shebang = false
217
- end
218
- installer.generate_bin
219
- end
220
- end
221
-
222
- def expand_gemfile(spec, options)
223
- Bundler.logger.info "Installing #{spec.name} (#{spec.version})"
224
-
225
- gemfile = @cache_path.join("#{spec.full_name}.gem").to_s
226
-
227
- if build_args = options[:build_options] && options[:build_options][spec.name]
228
- Gem::Command.build_args = build_args.map {|k,v| "--with-#{k}=#{v}"}
229
- end
230
-
231
- installer = Gem::Installer.new(gemfile, options.merge(
232
- :install_dir => gem_path,
233
- :ignore_dependencies => true,
234
- :env_shebang => true,
235
- :wrappers => true,
236
- :bin_dir => bindir
237
- ))
238
- installer.install
239
- rescue Gem::InstallError
240
- cleanup_spec(spec)
241
- raise
242
- ensure
243
- Gem::Command.build_args = []
244
- end
245
-
246
- def expand_vendored_gem(spec, options)
247
- add_spec(spec)
248
- FileUtils.mkdir_p(@gems_path)
249
- File.symlink(spec.location, @gems_path.join(spec.full_name))
250
- end
251
-
252
- def add_spec(spec)
253
- destination = @specs_path
254
- destination.mkdir unless destination.exist?
255
-
256
- File.open(destination.join("#{spec.full_name}.gemspec"), 'w') do |f|
257
- f.puts spec.to_ruby
258
- end
259
- end
260
-
261
- def cleanup(valid, options)
262
- to_delete = gems
263
- to_delete.delete_if do |spec|
264
- valid.any? { |other| spec.name == other.name && spec.version == other.version }
265
- end
266
-
267
- valid_executables = valid.map { |s| s.executables }.flatten.compact
268
-
269
- to_delete.each do |spec|
270
- Bundler.logger.info "Deleting gem: #{spec.name} (#{spec.version})"
271
- cleanup_spec(spec)
272
- # Cleanup the bin directory
273
- spec.executables.each do |bin|
274
- next if valid_executables.include?(bin)
275
- Bundler.logger.info "Deleting bin file: #{bin}"
276
- FileUtils.rm_rf(bindir.join(bin))
277
- end
278
- end
279
- end
280
-
281
- def cleanup_spec(spec)
282
- FileUtils.rm_rf(@specs_path.join("#{spec.full_name}.gemspec"))
283
- FileUtils.rm_rf(@gems_path.join(spec.full_name))
284
- end
285
-
286
- def expand(options)
287
- each_repo do |repo|
288
- repo.expand(options)
289
- end
290
- end
291
-
292
- def configure(specs, options)
293
- FileUtils.mkdir_p(gem_path)
294
-
295
- File.open(gem_path.join("environment.rb"), "w") do |file|
296
- file.puts @environment.environment_rb(specs, options)
297
- end
298
-
299
- generate_environment_picker
300
- end
301
-
302
- def generate_environment_picker
303
- FileUtils.cp("#{File.dirname(__FILE__)}/templates/environment_picker.erb", path.join("environment.rb"))
304
- end
305
-
306
- def require_code(file, dep)
307
- constraint = case
308
- when dep.only then %{ if #{dep.only.inspect}.include?(env)}
309
- when dep.except then %{ unless #{dep.except.inspect}.include?(env)}
310
- end
311
- "require #{file.inspect}#{constraint}"
312
- end
313
- end
314
- end
@@ -1,72 +0,0 @@
1
- class Gem::Commands::BundleCommand < Gem::Command
2
-
3
- def initialize
4
- super('bundle', 'Create a gem bundle based on your Gemfile', {:manifest => nil, :update => false})
5
-
6
- add_option('-m', '--manifest MANIFEST', "Specify the path to the manifest file") do |manifest, options|
7
- options[:manifest] = manifest
8
- end
9
-
10
- add_option('-u', '--update', "Force a remote check for newer gems") do
11
- options[:update] = true
12
- end
13
-
14
- add_option('--cached', "Only use cached gems when expanding the bundle") do
15
- options[:cached] = true
16
- end
17
-
18
- add_option('--cache GEM', "Specify a path to a .gem file to add to the bundled gem cache") do |gem, options|
19
- options[:cache] = gem
20
- end
21
-
22
- add_option('--prune-cache', "Removes all .gem files that are not a part of the bundle from the cache") do
23
- options[:prune] = true
24
- end
25
-
26
- add_option('--list', "List all gems that are part of the active bundle") do
27
- options[:list] = true
28
- end
29
-
30
- add_option('--list-outdated', "List all outdated gems that are part of the active bundle") do
31
- options[:list_outdated] = true
32
- end
33
-
34
- add_option('-b', '--build-options OPTION_FILE', "Specify a path to a yml file with build options for binary gems") do |option_file, options|
35
- if File.exist?(option_file)
36
- options[:build_options] = YAML.load_file(option_file)
37
- end
38
- end
39
-
40
- add_option('--only ENV', "Only expand the given environment. To specify multiple environments, use --only multiple times.") do |env, options|
41
- options[:only] ||= []
42
- options[:only] << env
43
- end
44
- end
45
-
46
- def usage
47
- "#{program_name}"
48
- end
49
-
50
- def description # :nodoc:
51
- <<-EOF
52
- Bundle stuff
53
- EOF
54
- end
55
-
56
- def execute
57
- # Prevent the bundler from getting required unless it is actually being used
58
- require 'bundler'
59
- if options[:cache]
60
- Bundler::CLI.run(:cache, options)
61
- elsif options[:prune]
62
- Bundler::CLI.run(:prune, options)
63
- elsif options[:list]
64
- Bundler::CLI.run(:list, options)
65
- elsif options[:list_outdated]
66
- Bundler::CLI.run(:list_outdated, options)
67
- else
68
- Bundler::CLI.run(:bundle, options)
69
- end
70
- end
71
-
72
- end