bundler_package_git 1.1.pre.1
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.
- data/.gitignore +22 -0
- data/.rvmrc +1 -0
- data/CHANGELOG.md +659 -0
- data/ISSUES.md +47 -0
- data/LICENSE +23 -0
- data/README.md +29 -0
- data/Rakefile +167 -0
- data/UPGRADING.md +103 -0
- data/bin/bundle +22 -0
- data/bundler.gemspec +30 -0
- data/lib/bundler.rb +283 -0
- data/lib/bundler/capistrano.rb +11 -0
- data/lib/bundler/cli.rb +490 -0
- data/lib/bundler/definition.rb +429 -0
- data/lib/bundler/dependency.rb +130 -0
- data/lib/bundler/deployment.rb +53 -0
- data/lib/bundler/dsl.rb +243 -0
- data/lib/bundler/environment.rb +47 -0
- data/lib/bundler/fetcher.rb +101 -0
- data/lib/bundler/gem_helper.rb +146 -0
- data/lib/bundler/graph.rb +130 -0
- data/lib/bundler/index.rb +131 -0
- data/lib/bundler/installer.rb +117 -0
- data/lib/bundler/lazy_specification.rb +71 -0
- data/lib/bundler/lockfile_parser.rb +108 -0
- data/lib/bundler/remote_specification.rb +57 -0
- data/lib/bundler/resolver.rb +470 -0
- data/lib/bundler/rubygems_ext.rb +226 -0
- data/lib/bundler/runtime.rb +201 -0
- data/lib/bundler/settings.rb +117 -0
- data/lib/bundler/setup.rb +16 -0
- data/lib/bundler/shared_helpers.rb +167 -0
- data/lib/bundler/source.rb +675 -0
- data/lib/bundler/spec_set.rb +134 -0
- data/lib/bundler/templates/Executable +16 -0
- data/lib/bundler/templates/Gemfile +4 -0
- data/lib/bundler/templates/newgem/Gemfile.tt +4 -0
- data/lib/bundler/templates/newgem/Rakefile.tt +2 -0
- data/lib/bundler/templates/newgem/bin/newgem.tt +3 -0
- data/lib/bundler/templates/newgem/gitignore.tt +4 -0
- data/lib/bundler/templates/newgem/lib/newgem.rb.tt +7 -0
- data/lib/bundler/templates/newgem/lib/newgem/version.rb.tt +7 -0
- data/lib/bundler/templates/newgem/newgem.gemspec.tt +21 -0
- data/lib/bundler/ui.rb +73 -0
- data/lib/bundler/vendor/net/http/faster.rb +27 -0
- data/lib/bundler/vendor/net/http/persistent.rb +464 -0
- data/lib/bundler/vendor/thor.rb +319 -0
- data/lib/bundler/vendor/thor/actions.rb +297 -0
- data/lib/bundler/vendor/thor/actions/create_file.rb +105 -0
- data/lib/bundler/vendor/thor/actions/directory.rb +93 -0
- data/lib/bundler/vendor/thor/actions/empty_directory.rb +134 -0
- data/lib/bundler/vendor/thor/actions/file_manipulation.rb +229 -0
- data/lib/bundler/vendor/thor/actions/inject_into_file.rb +104 -0
- data/lib/bundler/vendor/thor/base.rb +556 -0
- data/lib/bundler/vendor/thor/core_ext/file_binary_read.rb +9 -0
- data/lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb +75 -0
- data/lib/bundler/vendor/thor/core_ext/ordered_hash.rb +100 -0
- data/lib/bundler/vendor/thor/error.rb +30 -0
- data/lib/bundler/vendor/thor/invocation.rb +168 -0
- data/lib/bundler/vendor/thor/parser.rb +4 -0
- data/lib/bundler/vendor/thor/parser/argument.rb +67 -0
- data/lib/bundler/vendor/thor/parser/arguments.rb +161 -0
- data/lib/bundler/vendor/thor/parser/option.rb +120 -0
- data/lib/bundler/vendor/thor/parser/options.rb +174 -0
- data/lib/bundler/vendor/thor/shell.rb +88 -0
- data/lib/bundler/vendor/thor/shell/basic.rb +275 -0
- data/lib/bundler/vendor/thor/shell/color.rb +108 -0
- data/lib/bundler/vendor/thor/shell/html.rb +121 -0
- data/lib/bundler/vendor/thor/task.rb +114 -0
- data/lib/bundler/vendor/thor/util.rb +229 -0
- data/lib/bundler/vendor/thor/version.rb +3 -0
- data/lib/bundler/version.rb +6 -0
- data/lib/bundler/vlad.rb +9 -0
- data/man/bundle-config.ronn +90 -0
- data/man/bundle-exec.ronn +111 -0
- data/man/bundle-install.ronn +314 -0
- data/man/bundle-package.ronn +59 -0
- data/man/bundle-update.ronn +176 -0
- data/man/bundle.ronn +80 -0
- data/man/gemfile.5.ronn +279 -0
- data/man/index.txt +6 -0
- data/spec/cache/gems_spec.rb +219 -0
- data/spec/cache/git_spec.rb +9 -0
- data/spec/cache/path_spec.rb +27 -0
- data/spec/cache/platform_spec.rb +57 -0
- data/spec/install/deploy_spec.rb +197 -0
- data/spec/install/deprecated_spec.rb +37 -0
- data/spec/install/gems/c_ext_spec.rb +48 -0
- data/spec/install/gems/dependency_api_spec.rb +85 -0
- data/spec/install/gems/env_spec.rb +107 -0
- data/spec/install/gems/flex_spec.rb +313 -0
- data/spec/install/gems/groups_spec.rb +245 -0
- data/spec/install/gems/packed_spec.rb +84 -0
- data/spec/install/gems/platform_spec.rb +208 -0
- data/spec/install/gems/resolving_spec.rb +72 -0
- data/spec/install/gems/simple_case_spec.rb +715 -0
- data/spec/install/gems/standalone_spec.rb +162 -0
- data/spec/install/gems/sudo_spec.rb +73 -0
- data/spec/install/gems/win32_spec.rb +26 -0
- data/spec/install/gemspec_spec.rb +108 -0
- data/spec/install/git_spec.rb +571 -0
- data/spec/install/invalid_spec.rb +17 -0
- data/spec/install/path_spec.rb +353 -0
- data/spec/install/upgrade_spec.rb +26 -0
- data/spec/lock/git_spec.rb +35 -0
- data/spec/lock/lockfile_spec.rb +683 -0
- data/spec/other/check_spec.rb +221 -0
- data/spec/other/clean_spec.rb +202 -0
- data/spec/other/config_spec.rb +40 -0
- data/spec/other/console_spec.rb +54 -0
- data/spec/other/exec_spec.rb +241 -0
- data/spec/other/ext_spec.rb +16 -0
- data/spec/other/gem_helper_spec.rb +128 -0
- data/spec/other/help_spec.rb +38 -0
- data/spec/other/init_spec.rb +40 -0
- data/spec/other/newgem_spec.rb +24 -0
- data/spec/other/open_spec.rb +35 -0
- data/spec/other/show_spec.rb +82 -0
- data/spec/pack/gems_spec.rb +54 -0
- data/spec/quality_spec.rb +58 -0
- data/spec/resolver/basic_spec.rb +20 -0
- data/spec/resolver/platform_spec.rb +82 -0
- data/spec/runtime/executable_spec.rb +110 -0
- data/spec/runtime/load_spec.rb +107 -0
- data/spec/runtime/platform_spec.rb +90 -0
- data/spec/runtime/require_spec.rb +231 -0
- data/spec/runtime/setup_spec.rb +688 -0
- data/spec/runtime/with_clean_env_spec.rb +15 -0
- data/spec/spec_helper.rb +85 -0
- data/spec/support/artifice/endpoint.rb +50 -0
- data/spec/support/artifice/endpoint_fallback.rb +22 -0
- data/spec/support/artifice/endpoint_marshal_fail.rb +11 -0
- data/spec/support/artifice/endpoint_redirect.rb +11 -0
- data/spec/support/builders.rb +574 -0
- data/spec/support/fakeweb/rack-1.0.0.marshal +2 -0
- data/spec/support/fakeweb/windows.rb +23 -0
- data/spec/support/helpers.rb +246 -0
- data/spec/support/indexes.rb +112 -0
- data/spec/support/matchers.rb +89 -0
- data/spec/support/path.rb +73 -0
- data/spec/support/platforms.rb +53 -0
- data/spec/support/ruby_ext.rb +20 -0
- data/spec/support/rubygems_ext.rb +35 -0
- data/spec/support/rubygems_hax/platform.rb +11 -0
- data/spec/support/sudo.rb +21 -0
- data/spec/update/gems_spec.rb +121 -0
- data/spec/update/git_spec.rb +196 -0
- data/spec/update/source_spec.rb +51 -0
- metadata +294 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Capistrano task for Bundler.
|
|
2
|
+
#
|
|
3
|
+
# Just add "require 'bundler/capistrano'" in your Capistrano deploy.rb, and
|
|
4
|
+
# Bundler will be activated after each new deployment.
|
|
5
|
+
require 'bundler/deployment'
|
|
6
|
+
|
|
7
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
|
8
|
+
after "deploy:update_code", "bundle:install"
|
|
9
|
+
Bundler::Deployment.define_task(self, :task, :except => { :no_release => true })
|
|
10
|
+
set :rake, 'bundle exec rake'
|
|
11
|
+
end
|
data/lib/bundler/cli.rb
ADDED
|
@@ -0,0 +1,490 @@
|
|
|
1
|
+
$:.unshift File.expand_path('../vendor', __FILE__)
|
|
2
|
+
require 'thor'
|
|
3
|
+
require 'thor/actions'
|
|
4
|
+
require 'rubygems/user_interaction'
|
|
5
|
+
require 'rubygems/config_file'
|
|
6
|
+
|
|
7
|
+
# Work around a RubyGems bug
|
|
8
|
+
Gem.configuration
|
|
9
|
+
|
|
10
|
+
module Bundler
|
|
11
|
+
class CLI < Thor
|
|
12
|
+
include Thor::Actions
|
|
13
|
+
|
|
14
|
+
def initialize(*)
|
|
15
|
+
super
|
|
16
|
+
the_shell = (options["no-color"] ? Thor::Shell::Basic.new : shell)
|
|
17
|
+
Bundler.ui = UI::Shell.new(the_shell)
|
|
18
|
+
Bundler.ui.debug! if options["verbose"]
|
|
19
|
+
Gem::DefaultUserInteraction.ui = UI::RGProxy.new(Bundler.ui)
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
check_unknown_options! unless ARGV.include?("exec") || ARGV.include?("config")
|
|
23
|
+
|
|
24
|
+
default_task :install
|
|
25
|
+
class_option "no-color", :type => :boolean, :banner => "Disable colorization in output"
|
|
26
|
+
class_option "verbose", :type => :boolean, :banner => "Enable verbose output mode", :aliases => "-V"
|
|
27
|
+
|
|
28
|
+
def help(cli = nil)
|
|
29
|
+
case cli
|
|
30
|
+
when "gemfile" then command = "gemfile.5"
|
|
31
|
+
when nil then command = "bundle"
|
|
32
|
+
else command = "bundle-#{cli}"
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
manpages = %w(
|
|
36
|
+
bundle
|
|
37
|
+
bundle-config
|
|
38
|
+
bundle-exec
|
|
39
|
+
bundle-install
|
|
40
|
+
bundle-package
|
|
41
|
+
bundle-update
|
|
42
|
+
gemfile.5)
|
|
43
|
+
|
|
44
|
+
if manpages.include?(command)
|
|
45
|
+
root = File.expand_path("../man", __FILE__)
|
|
46
|
+
|
|
47
|
+
if have_groff? && root !~ %r{^file:/.+!/META-INF/jruby.home/.+}
|
|
48
|
+
groff = "groff -Wall -mtty-char -mandoc -Tascii"
|
|
49
|
+
pager = ENV['MANPAGER'] || ENV['PAGER'] || 'less'
|
|
50
|
+
|
|
51
|
+
Kernel.exec "#{groff} #{root}/#{command} | #{pager}"
|
|
52
|
+
else
|
|
53
|
+
puts File.read("#{root}/#{command}.txt")
|
|
54
|
+
end
|
|
55
|
+
else
|
|
56
|
+
super
|
|
57
|
+
end
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
desc "init", "Generates a Gemfile into the current working directory"
|
|
61
|
+
long_desc <<-D
|
|
62
|
+
Init generates a default Gemfile in the current working directory. When adding a
|
|
63
|
+
Gemfile to a gem with a gemspec, the --gemspec option will automatically add each
|
|
64
|
+
dependency listed in the gemspec file to the newly created Gemfile.
|
|
65
|
+
D
|
|
66
|
+
method_option "gemspec", :type => :string, :banner => "Use the specified .gemspec to create the Gemfile"
|
|
67
|
+
def init
|
|
68
|
+
opts = options.dup
|
|
69
|
+
if File.exist?("Gemfile")
|
|
70
|
+
Bundler.ui.error "Gemfile already exists at #{Dir.pwd}/Gemfile"
|
|
71
|
+
exit 1
|
|
72
|
+
end
|
|
73
|
+
|
|
74
|
+
if opts[:gemspec]
|
|
75
|
+
gemspec = File.expand_path(opts[:gemspec])
|
|
76
|
+
unless File.exist?(gemspec)
|
|
77
|
+
Bundler.ui.error "Gem specification #{gemspec} doesn't exist"
|
|
78
|
+
exit 1
|
|
79
|
+
end
|
|
80
|
+
spec = Gem::Specification.load(gemspec)
|
|
81
|
+
puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
|
|
82
|
+
File.open('Gemfile', 'wb') do |file|
|
|
83
|
+
file << "# Generated from #{gemspec}\n"
|
|
84
|
+
file << spec.to_gemfile
|
|
85
|
+
end
|
|
86
|
+
else
|
|
87
|
+
puts "Writing new Gemfile to #{Dir.pwd}/Gemfile"
|
|
88
|
+
FileUtils.cp(File.expand_path('../templates/Gemfile', __FILE__), 'Gemfile')
|
|
89
|
+
end
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
desc "check", "Checks if the dependencies listed in Gemfile are satisfied by currently installed gems"
|
|
93
|
+
long_desc <<-D
|
|
94
|
+
Check searches the local machine for each of the gems requested in the Gemfile. If
|
|
95
|
+
all gems are found, Bundler prints a success message and exits with a status of 0.
|
|
96
|
+
If not, the first missing gem is listed and Bundler exits status 1.
|
|
97
|
+
D
|
|
98
|
+
method_option "gemfile", :type => :string, :banner =>
|
|
99
|
+
"Use the specified gemfile instead of Gemfile"
|
|
100
|
+
def check
|
|
101
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path(options[:gemfile]) if options[:gemfile]
|
|
102
|
+
begin
|
|
103
|
+
not_installed = Bundler.definition.missing_specs
|
|
104
|
+
rescue GemNotFound, VersionConflict
|
|
105
|
+
Bundler.ui.error "Your Gemfile's dependencies could not be satisfied"
|
|
106
|
+
Bundler.ui.warn "Install missing gems with `bundle install`"
|
|
107
|
+
exit 1
|
|
108
|
+
end
|
|
109
|
+
|
|
110
|
+
if not_installed.any?
|
|
111
|
+
Bundler.ui.error "The following gems are missing"
|
|
112
|
+
not_installed.each { |s| Bundler.ui.error " * #{s.name} (#{s.version})" }
|
|
113
|
+
Bundler.ui.warn "Install missing gems with `bundle install`"
|
|
114
|
+
exit 1
|
|
115
|
+
else
|
|
116
|
+
Bundler.load.lock
|
|
117
|
+
Bundler.ui.info "The Gemfile's dependencies are satisfied"
|
|
118
|
+
end
|
|
119
|
+
end
|
|
120
|
+
|
|
121
|
+
desc "install", "Install the current environment to the system"
|
|
122
|
+
long_desc <<-D
|
|
123
|
+
Install will install all of the gems in the current bundle, making them available
|
|
124
|
+
for use. In a freshly checked out repository, this command will give you the same
|
|
125
|
+
gem versions as the last person who updated the Gemfile and ran `bundle update`.
|
|
126
|
+
|
|
127
|
+
Passing [DIR] to install (e.g. vendor) will cause the unpacked gems to be installed
|
|
128
|
+
into the [DIR] directory rather than into system gems.
|
|
129
|
+
|
|
130
|
+
If the bundle has already been installed, bundler will tell you so and then exit.
|
|
131
|
+
D
|
|
132
|
+
method_option "without", :type => :array, :banner =>
|
|
133
|
+
"Exclude gems that are part of the specified named group."
|
|
134
|
+
method_option "gemfile", :type => :string, :banner =>
|
|
135
|
+
"Use the specified gemfile instead of Gemfile"
|
|
136
|
+
method_option "no-prune", :type => :boolean, :banner =>
|
|
137
|
+
"Don't remove stale gems from the cache."
|
|
138
|
+
method_option "no-cache", :type => :boolean, :banner =>
|
|
139
|
+
"Don't update the existing gem cache."
|
|
140
|
+
method_option "quiet", :type => :boolean, :banner =>
|
|
141
|
+
"Only output warnings and errors."
|
|
142
|
+
method_option "local", :type => :boolean, :banner =>
|
|
143
|
+
"Do not attempt to fetch gems remotely and use the gem cache instead"
|
|
144
|
+
method_option "binstubs", :type => :string, :lazy_default => "bin", :banner =>
|
|
145
|
+
"Generate bin stubs for bundled gems to ./bin"
|
|
146
|
+
method_option "path", :type => :string, :banner =>
|
|
147
|
+
"Specify a different path than the system default ($BUNDLE_PATH or $GEM_HOME). Bundler will remember this value for future installs on this machine"
|
|
148
|
+
method_option "system", :type => :boolean, :banner =>
|
|
149
|
+
"Install to the system location ($BUNDLE_PATH or $GEM_HOME) even if the bundle was previously installed somewhere else for this application"
|
|
150
|
+
method_option "frozen", :type => :boolean, :banner =>
|
|
151
|
+
"Do not allow the Gemfile.lock to be updated after this install"
|
|
152
|
+
method_option "deployment", :type => :boolean, :banner =>
|
|
153
|
+
"Install using defaults tuned for deployment environments"
|
|
154
|
+
method_option "standalone", :type => :array, :lazy_default => [], :banner =>
|
|
155
|
+
"Make a bundle that can work without the Bundler runtime"
|
|
156
|
+
def install
|
|
157
|
+
opts = options.dup
|
|
158
|
+
opts[:without] ||= []
|
|
159
|
+
if opts[:without].size == 1
|
|
160
|
+
opts[:without].map!{|g| g.split(" ") }
|
|
161
|
+
opts[:without].flatten!
|
|
162
|
+
end
|
|
163
|
+
opts[:without].map!{|g| g.to_sym }
|
|
164
|
+
|
|
165
|
+
ENV['BUNDLE_GEMFILE'] = File.expand_path(opts[:gemfile]) if opts[:gemfile]
|
|
166
|
+
ENV['RB_USER_INSTALL'] = '1' if Bundler::FREEBSD
|
|
167
|
+
|
|
168
|
+
# Just disable color in deployment mode
|
|
169
|
+
Bundler.ui.shell = Thor::Shell::Basic.new if opts[:deployment]
|
|
170
|
+
|
|
171
|
+
if (opts[:path] || opts[:deployment]) && opts[:system]
|
|
172
|
+
Bundler.ui.error "You have specified both a path to install your gems to, \n" \
|
|
173
|
+
"as well as --system. Please choose."
|
|
174
|
+
exit 1
|
|
175
|
+
end
|
|
176
|
+
|
|
177
|
+
if opts[:deployment] || opts[:frozen]
|
|
178
|
+
unless Bundler.default_lockfile.exist?
|
|
179
|
+
flag = opts[:deployment] ? '--deployment' : '--frozen'
|
|
180
|
+
raise ProductionError, "The #{flag} flag requires a Gemfile.lock. Please make " \
|
|
181
|
+
"sure you have checked your Gemfile.lock into version control " \
|
|
182
|
+
"before deploying."
|
|
183
|
+
end
|
|
184
|
+
|
|
185
|
+
if Bundler.root.join("vendor/cache").exist?
|
|
186
|
+
opts[:local] = true
|
|
187
|
+
end
|
|
188
|
+
|
|
189
|
+
Bundler.settings[:frozen] = '1'
|
|
190
|
+
end
|
|
191
|
+
|
|
192
|
+
# Can't use Bundler.settings for this because settings needs gemfile.dirname
|
|
193
|
+
Bundler.settings[:path] = nil if opts[:system]
|
|
194
|
+
Bundler.settings[:path] = "vendor/bundle" if opts[:deployment]
|
|
195
|
+
Bundler.settings[:path] = opts[:path] if opts[:path]
|
|
196
|
+
Bundler.settings[:path] ||= "bundle" if opts[:standalone]
|
|
197
|
+
Bundler.settings[:bin] = opts["binstubs"] if opts[:binstubs]
|
|
198
|
+
Bundler.settings[:disable_shared_gems] = '1' if Bundler.settings[:path]
|
|
199
|
+
Bundler.settings.without = opts[:without] unless opts[:without].empty?
|
|
200
|
+
Bundler.ui.be_quiet! if opts[:quiet]
|
|
201
|
+
|
|
202
|
+
Installer.install(Bundler.root, Bundler.definition, opts)
|
|
203
|
+
Bundler.load.cache if Bundler.root.join("vendor/cache").exist? && !options["no-cache"]
|
|
204
|
+
|
|
205
|
+
if Bundler.settings[:path]
|
|
206
|
+
relative_path = Bundler.settings[:path]
|
|
207
|
+
relative_path = "./" + relative_path unless relative_path[0] == ?/
|
|
208
|
+
Bundler.ui.confirm "Your bundle is complete! " +
|
|
209
|
+
"It was installed into #{relative_path}"
|
|
210
|
+
else
|
|
211
|
+
Bundler.ui.confirm "Your bundle is complete! " +
|
|
212
|
+
"Use `bundle show [gemname]` to see where a bundled gem is installed."
|
|
213
|
+
end
|
|
214
|
+
rescue GemNotFound => e
|
|
215
|
+
if opts[:local]
|
|
216
|
+
Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
|
|
217
|
+
end
|
|
218
|
+
|
|
219
|
+
if Bundler.definition.no_sources?
|
|
220
|
+
Bundler.ui.warn "Your Gemfile doesn't have any sources. You can add one with a line like 'source :rubygems'"
|
|
221
|
+
end
|
|
222
|
+
raise e
|
|
223
|
+
end
|
|
224
|
+
|
|
225
|
+
desc "update", "update the current environment"
|
|
226
|
+
long_desc <<-D
|
|
227
|
+
Update will install the newest versions of the gems listed in the Gemfile. Use
|
|
228
|
+
update when you have changed the Gemfile, or if you want to get the newest
|
|
229
|
+
possible versions of the gems in the bundle.
|
|
230
|
+
D
|
|
231
|
+
method_option "source", :type => :array, :banner => "Update a specific source (and all gems associated with it)"
|
|
232
|
+
method_option "local", :type => :boolean, :banner =>
|
|
233
|
+
"Do not attempt to fetch gems remotely and use the gem cache instead"
|
|
234
|
+
def update(*gems)
|
|
235
|
+
sources = Array(options[:source])
|
|
236
|
+
|
|
237
|
+
if gems.empty? && sources.empty?
|
|
238
|
+
# We're doing a full update
|
|
239
|
+
Bundler.definition(true)
|
|
240
|
+
else
|
|
241
|
+
Bundler.definition(:gems => gems, :sources => sources)
|
|
242
|
+
end
|
|
243
|
+
|
|
244
|
+
opts = {"update" => true, "local" => options[:local]}
|
|
245
|
+
Installer.install Bundler.root, Bundler.definition, opts
|
|
246
|
+
Bundler.load.cache if Bundler.root.join("vendor/cache").exist?
|
|
247
|
+
Bundler.ui.confirm "Your bundle is updated! " +
|
|
248
|
+
"Use `bundle show [gemname]` to see where a bundled gem is installed."
|
|
249
|
+
end
|
|
250
|
+
|
|
251
|
+
desc "show [GEM]", "Shows all gems that are part of the bundle, or the path to a given gem"
|
|
252
|
+
long_desc <<-D
|
|
253
|
+
Show lists the names and versions of all gems that are required by your Gemfile.
|
|
254
|
+
Calling show with [GEM] will list the exact location of that gem on your machine.
|
|
255
|
+
D
|
|
256
|
+
def show(gem_name = nil)
|
|
257
|
+
Bundler.load.lock
|
|
258
|
+
|
|
259
|
+
if gem_name
|
|
260
|
+
Bundler.ui.info locate_gem(gem_name)
|
|
261
|
+
else
|
|
262
|
+
Bundler.ui.info "Gems included by the bundle:"
|
|
263
|
+
Bundler.load.specs.sort_by { |s| s.name }.each do |s|
|
|
264
|
+
Bundler.ui.info " * #{s.name} (#{s.version}#{s.git_version})"
|
|
265
|
+
end
|
|
266
|
+
end
|
|
267
|
+
end
|
|
268
|
+
map %w(list) => "show"
|
|
269
|
+
|
|
270
|
+
desc "cache", "Cache all the gems to vendor/cache", :hide => true
|
|
271
|
+
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
|
|
272
|
+
def cache
|
|
273
|
+
Bundler.definition.resolve_with_cache!
|
|
274
|
+
Bundler.load.cache
|
|
275
|
+
Bundler.settings[:no_prune] = true if options[:no_prune]
|
|
276
|
+
Bundler.load.lock
|
|
277
|
+
rescue GemNotFound => e
|
|
278
|
+
Bundler.ui.error(e.message)
|
|
279
|
+
Bundler.ui.warn "Run `bundle install` to install missing gems."
|
|
280
|
+
exit 128
|
|
281
|
+
end
|
|
282
|
+
|
|
283
|
+
desc "package", "Locks and then caches all of the gems into vendor/cache"
|
|
284
|
+
method_option "no-prune", :type => :boolean, :banner => "Don't remove stale gems from the cache."
|
|
285
|
+
long_desc <<-D
|
|
286
|
+
The package command will copy the .gem files for every gem in the bundle into the
|
|
287
|
+
directory ./vendor/cache. If you then check that directory into your source
|
|
288
|
+
control repository, others who check out your source will be able to install the
|
|
289
|
+
bundle without having to download any additional gems.
|
|
290
|
+
D
|
|
291
|
+
def package
|
|
292
|
+
install
|
|
293
|
+
# TODO: move cache contents here now that all bundles are locked
|
|
294
|
+
Bundler.load.cache
|
|
295
|
+
end
|
|
296
|
+
map %w(pack) => :package
|
|
297
|
+
|
|
298
|
+
desc "exec", "Run the command in context of the bundle"
|
|
299
|
+
long_desc <<-D
|
|
300
|
+
Exec runs a command, providing it access to the gems in the bundle. While using
|
|
301
|
+
bundle exec you can require and call the bundled gems as if they were installed
|
|
302
|
+
into the systemwide Rubygems repository.
|
|
303
|
+
D
|
|
304
|
+
def exec(*)
|
|
305
|
+
ARGV.delete("exec")
|
|
306
|
+
|
|
307
|
+
Bundler.setup
|
|
308
|
+
|
|
309
|
+
begin
|
|
310
|
+
# Run
|
|
311
|
+
Kernel.exec(*ARGV)
|
|
312
|
+
rescue Errno::EACCES
|
|
313
|
+
Bundler.ui.error "bundler: not executable: #{ARGV.first}"
|
|
314
|
+
exit 126
|
|
315
|
+
rescue Errno::ENOENT
|
|
316
|
+
Bundler.ui.error "bundler: command not found: #{ARGV.first}"
|
|
317
|
+
Bundler.ui.warn "Install missing gem binaries with `bundle install`"
|
|
318
|
+
exit 127
|
|
319
|
+
end
|
|
320
|
+
end
|
|
321
|
+
|
|
322
|
+
desc "config NAME [VALUE]", "retrieve or set a configuration value"
|
|
323
|
+
long_desc <<-D
|
|
324
|
+
Retrieves or sets a configuration value. If only parameter is provided, retrieve the value. If two parameters are provided, replace the
|
|
325
|
+
existing value with the newly provided one.
|
|
326
|
+
|
|
327
|
+
By default, setting a configuration value sets it for all projects
|
|
328
|
+
on the machine.
|
|
329
|
+
|
|
330
|
+
If a global setting is superceded by local configuration, this command
|
|
331
|
+
will show the current value, as well as any superceded values and
|
|
332
|
+
where they were specified.
|
|
333
|
+
D
|
|
334
|
+
def config(name = nil, *args)
|
|
335
|
+
values = ARGV.dup
|
|
336
|
+
values.shift # remove config
|
|
337
|
+
values.shift # remove the name
|
|
338
|
+
|
|
339
|
+
unless name
|
|
340
|
+
Bundler.ui.confirm "Settings are listed in order of priority. The top value will be used.\n"
|
|
341
|
+
|
|
342
|
+
Bundler.settings.all.each do |setting|
|
|
343
|
+
Bundler.ui.confirm "#{setting}"
|
|
344
|
+
with_padding do
|
|
345
|
+
Bundler.settings.pretty_values_for(setting).each do |line|
|
|
346
|
+
Bundler.ui.info line
|
|
347
|
+
end
|
|
348
|
+
end
|
|
349
|
+
Bundler.ui.confirm ""
|
|
350
|
+
end
|
|
351
|
+
return
|
|
352
|
+
end
|
|
353
|
+
|
|
354
|
+
if values.empty?
|
|
355
|
+
Bundler.ui.confirm "Settings for `#{name}` in order of priority. The top value will be used"
|
|
356
|
+
with_padding do
|
|
357
|
+
Bundler.settings.pretty_values_for(name).each { |line| Bundler.ui.info line }
|
|
358
|
+
end
|
|
359
|
+
else
|
|
360
|
+
locations = Bundler.settings.locations(name)
|
|
361
|
+
|
|
362
|
+
if local = locations[:local]
|
|
363
|
+
Bundler.ui.info "Your application has set #{name} to #{local.inspect}. This will override the " \
|
|
364
|
+
"system value you are currently setting"
|
|
365
|
+
end
|
|
366
|
+
|
|
367
|
+
if global = locations[:global]
|
|
368
|
+
Bundler.ui.info "You are replacing the current system value of #{name}, which is currently #{global}"
|
|
369
|
+
end
|
|
370
|
+
|
|
371
|
+
if env = locations[:env]
|
|
372
|
+
Bundler.ui.info "You have set a bundler environment variable for #{env}. This will take precedence " \
|
|
373
|
+
"over the system value you are setting"
|
|
374
|
+
end
|
|
375
|
+
|
|
376
|
+
Bundler.settings.set_global(name, values.join(" "))
|
|
377
|
+
end
|
|
378
|
+
end
|
|
379
|
+
|
|
380
|
+
desc "open GEM", "Opens the source directory of the given bundled gem"
|
|
381
|
+
def open(name)
|
|
382
|
+
editor = [ENV['BUNDLER_EDITOR'], ENV['VISUAL'], ENV['EDITOR']].find{|e| !e.nil? && !e.empty? }
|
|
383
|
+
if editor
|
|
384
|
+
gem_path = locate_gem(name)
|
|
385
|
+
Dir.chdir(gem_path) do
|
|
386
|
+
command = "#{editor} #{gem_path}"
|
|
387
|
+
success = system(command)
|
|
388
|
+
Bundler.ui.info "Could not run '#{command}'" unless success
|
|
389
|
+
end
|
|
390
|
+
else
|
|
391
|
+
Bundler.ui.info("To open a bundled gem, set $EDITOR or $BUNDLER_EDITOR")
|
|
392
|
+
end
|
|
393
|
+
end
|
|
394
|
+
|
|
395
|
+
desc "console [GROUP]", "Opens an IRB session with the bundle pre-loaded"
|
|
396
|
+
def console(group = nil)
|
|
397
|
+
group ? Bundler.require(:default, *(group.split.map! {|g| g.to_sym })) : Bundler.require
|
|
398
|
+
ARGV.clear
|
|
399
|
+
|
|
400
|
+
require 'irb'
|
|
401
|
+
IRB.start
|
|
402
|
+
end
|
|
403
|
+
|
|
404
|
+
desc "version", "Prints the bundler's version information"
|
|
405
|
+
def version
|
|
406
|
+
Bundler.ui.info "Bundler version #{Bundler::VERSION}"
|
|
407
|
+
end
|
|
408
|
+
map %w(-v --version) => :version
|
|
409
|
+
|
|
410
|
+
desc 'viz', "Generates a visual dependency graph"
|
|
411
|
+
long_desc <<-D
|
|
412
|
+
Viz generates a PNG file of the current Gemfile as a dependency graph.
|
|
413
|
+
Viz requires the ruby-graphviz gem (and its dependencies).
|
|
414
|
+
The associated gems must also be installed via 'bundle install'.
|
|
415
|
+
D
|
|
416
|
+
method_option :file, :type => :string, :default => 'gem_graph.png', :aliases => '-f', :banner => "The name to use for the generated png file."
|
|
417
|
+
method_option :version, :type => :boolean, :default => false, :aliases => '-v', :banner => "Set to show each gem version."
|
|
418
|
+
method_option :requirements, :type => :boolean, :default => false, :aliases => '-r', :banner => "Set to show the version of each required dependency."
|
|
419
|
+
def viz
|
|
420
|
+
output_file = File.expand_path(options[:file])
|
|
421
|
+
graph = Graph.new( Bundler.load )
|
|
422
|
+
|
|
423
|
+
begin
|
|
424
|
+
graph.viz(output_file, options[:version], options[:requirements])
|
|
425
|
+
Bundler.ui.info output_file
|
|
426
|
+
rescue LoadError => e
|
|
427
|
+
Bundler.ui.error e.inspect
|
|
428
|
+
Bundler.ui.warn "Make sure you have the graphviz ruby gem. You can install it with:"
|
|
429
|
+
Bundler.ui.warn "`gem install ruby-graphviz`"
|
|
430
|
+
rescue StandardError => e
|
|
431
|
+
if e.message =~ /GraphViz not installed or dot not in PATH/
|
|
432
|
+
Bundler.ui.error e.message
|
|
433
|
+
Bundler.ui.warn "The ruby graphviz gem requires GraphViz to be installed"
|
|
434
|
+
else
|
|
435
|
+
raise
|
|
436
|
+
end
|
|
437
|
+
end
|
|
438
|
+
end
|
|
439
|
+
|
|
440
|
+
desc "gem GEM", "Creates a skeleton for creating a rubygem"
|
|
441
|
+
method_option :bin, :type => :boolean, :default => false, :aliases => '-b', :banner => "Generate a binary for your library."
|
|
442
|
+
def gem(name)
|
|
443
|
+
target = File.join(Dir.pwd, name)
|
|
444
|
+
constant_name = name.split('_').map{|p| p.capitalize}.join
|
|
445
|
+
constant_name = constant_name.split('-').map{|q| q.capitalize}.join('::') if constant_name =~ /-/
|
|
446
|
+
constant_array = constant_name.split('::')
|
|
447
|
+
FileUtils.mkdir_p(File.join(target, 'lib', name))
|
|
448
|
+
opts = {:name => name, :constant_name => constant_name, :constant_array => constant_array}
|
|
449
|
+
template(File.join("newgem/Gemfile.tt"), File.join(target, "Gemfile"), opts)
|
|
450
|
+
template(File.join("newgem/Rakefile.tt"), File.join(target, "Rakefile"), opts)
|
|
451
|
+
template(File.join("newgem/gitignore.tt"), File.join(target, ".gitignore"), opts)
|
|
452
|
+
template(File.join("newgem/newgem.gemspec.tt"), File.join(target, "#{name}.gemspec"), opts)
|
|
453
|
+
template(File.join("newgem/lib/newgem.rb.tt"), File.join(target, "lib/#{name}.rb"), opts)
|
|
454
|
+
template(File.join("newgem/lib/newgem/version.rb.tt"), File.join(target, "lib/#{name}/version.rb"), opts)
|
|
455
|
+
if options[:bin]
|
|
456
|
+
template(File.join("newgem/bin/newgem.tt"), File.join(target, 'bin', name), opts)
|
|
457
|
+
end
|
|
458
|
+
Bundler.ui.info "Initializating git repo in #{target}"
|
|
459
|
+
Dir.chdir(target) { `git init`; `git add .` }
|
|
460
|
+
end
|
|
461
|
+
|
|
462
|
+
def self.source_root
|
|
463
|
+
File.expand_path(File.join(File.dirname(__FILE__), 'templates'))
|
|
464
|
+
end
|
|
465
|
+
|
|
466
|
+
desc "clean", "Cleans up unused gems in your bundler directory"
|
|
467
|
+
def clean
|
|
468
|
+
clean_output = Bundler.load.clean
|
|
469
|
+
if !clean_output
|
|
470
|
+
Bundler.ui.error "Can only use bundle clean when --path is set"
|
|
471
|
+
end
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
private
|
|
475
|
+
|
|
476
|
+
def have_groff?
|
|
477
|
+
!(`which groff` rescue '').empty?
|
|
478
|
+
end
|
|
479
|
+
|
|
480
|
+
def locate_gem(name)
|
|
481
|
+
spec = Bundler.load.specs.find{|s| s.name == name }
|
|
482
|
+
raise GemNotFound, "Could not find gem '#{name}' in the current bundle." unless spec
|
|
483
|
+
if spec.name == 'bundler'
|
|
484
|
+
return File.expand_path('../../../', __FILE__)
|
|
485
|
+
end
|
|
486
|
+
spec.full_gem_path
|
|
487
|
+
end
|
|
488
|
+
|
|
489
|
+
end
|
|
490
|
+
end
|