Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 186 lines (156 sloc) 4.789 kb
63b636b First pass at gemfile pack
Carlhuda authored
1 require 'fileutils'
ce350cc Get a simple bbl install working
Carlhuda authored
2 require 'pathname'
88741e6 First pass at bbl lock
Carlhuda authored
3 require 'yaml'
820bb93 Rename rubygems-ext to rubygems_ext
Carl Lerche authored
4 require 'bundler/rubygems_ext'
1da7eb3 Don't generate bundler.gemspec anymore
Carlhuda authored
5 require 'bundler/version'
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
6
152a50a Rename gemfile back to bundler
Carl Lerche authored
7 module Bundler
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
8 ORIGINAL_ENV = ENV.to_hash
67859e4 Moving in thor
Carlhuda authored
9
152a50a Rename gemfile back to bundler
Carl Lerche authored
10 autoload :Definition, 'bundler/definition'
11 autoload :Dependency, 'bundler/dependency'
12 autoload :Dsl, 'bundler/dsl'
13 autoload :Environment, 'bundler/environment'
14 autoload :Index, 'bundler/index'
15 autoload :Installer, 'bundler/installer'
f779dee First pass at lockfile parser
Carlhuda authored
16 autoload :LazySpecification, 'bundler/lazy_specification'
ba579f4 Remove temporary flex stuff
Carlhuda authored
17 autoload :LockfileParser, 'bundler/lockfile_parser'
152a50a Rename gemfile back to bundler
Carl Lerche authored
18 autoload :RemoteSpecification, 'bundler/remote_specification'
19 autoload :Resolver, 'bundler/resolver'
c0f8641 Persist spec groups to the lockfile
Carl Lerche authored
20 autoload :Runtime, 'bundler/runtime'
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
21 autoload :Settings, 'bundler/settings'
f7bfdde Actually disable system gems in .bundle/environment.rb
Carlhuda authored
22 autoload :SharedHelpers, 'bundler/shared_helpers'
529d792 Use tsort to order specifications. It makes teh crazy work.
Carl Lerche authored
23 autoload :SpecSet, 'bundler/spec_set'
152a50a Rename gemfile back to bundler
Carl Lerche authored
24 autoload :Source, 'bundler/source'
0f97e4f @indirect Gems from git need their full_gem_path fixed, even when locked
indirect authored
25 autoload :Specification, 'bundler/shared_helpers'
434fb42 First pass at output
Carlhuda authored
26 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
27
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
28 class BundlerError < StandardError
29 def self.status_code(code = nil)
30 return @code unless code
31 @code = code
32 end
33
34 def status_code
35 self.class.status_code
36 end
37 end
38
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
39 class GemfileNotFound < BundlerError; status_code(10) ; end
40 class GemNotFound < BundlerError; status_code(7) ; end
41 class VersionConflict < BundlerError; status_code(6) ; end
42 class GemfileError < BundlerError; status_code(4) ; end
ef6a00f @indirect Print better error during install when you need to relock
indirect authored
43 class GemfileChanged < GemfileError; status_code(4) ; end
248ca34 Raise a better error in the case that a git repo is not cloned yet.
Carl Lerche authored
44 class PathError < BundlerError; status_code(13) ; end
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
45 class GitError < BundlerError; status_code(11) ; end
6a82ed0 @indirect Add GemspecError so it can be raised
indirect authored
46 class GemspecError < BundlerError; status_code(14) ; end
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
47 class DeprecatedMethod < BundlerError; status_code(12) ; end
48 class DeprecatedOption < BundlerError; status_code(12) ; end
2a24019 @indirect Print a useful error if a gemspec require fails
indirect authored
49 class GemspecError < BundlerError; status_code(14) ; end
7514b20 @wycats If an option is invalid, don't fail silently
wycats authored
50 class InvalidOption < BundlerError; status_code(15) ; end
67859e4 Moving in thor
Carlhuda authored
51
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
52 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
53 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
54
55 def configure
56 @configured ||= begin
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
57 configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
58 true
59 end
60 end
434fb42 First pass at output
Carlhuda authored
61
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
62 def ui
63 @ui ||= UI.new
64 end
434fb42 First pass at output
Carlhuda authored
65
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
66 def bundle_path
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
67 @bundle_path ||= begin
8f2099b Have bundler install to $GEM_HOME by default instead of ~/.bundle. Th…
Carlhuda authored
68 path = settings[:path] || Gem.dir
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
69 Pathname.new(path).expand_path(root)
70 end
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
71 end
72
5f26a03 Have bundler generate executable stubs into ~/.bundler/bin that will …
Carl Lerche authored
73 def bin_path
74 @bin_path ||= begin
75 path = settings[:bin] || "#{Gem.user_home}/.bundler/bin"
76 FileUtils.mkdir_p(path)
77 Pathname.new(path).expand_path
78 end
79 end
80
1674aef No need to alias setup and require in Bundler
Carl Lerche authored
81 def setup(*groups)
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
82 return @setup if @setup
83
5dfc54c @indirect Don't call exit! if Bundler.setup has an exception
indirect authored
84 if groups.empty?
85 # Load all groups, but only once
86 @setup = load.setup
87 else
88 # Figure out which groups haven't been loaded yet
89 unloaded = groups - (@completed_groups || [])
90 # Record groups that are now loaded
91 @completed_groups = groups | (@completed_groups || [])
92 # Load any groups that are not yet loaded
93 unloaded.any? ? load.setup(*unloaded) : load
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
94 end
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
95 end
ce350cc Get a simple bbl install working
Carlhuda authored
96
1674aef No need to alias setup and require in Bundler
Carl Lerche authored
97 def require(*groups)
69acfd8 @indirect Call Bundler.setup from Bundler.require, only set up each group once
indirect authored
98 setup(*groups).require(*groups)
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
99 end
100
625818a @indirect Clean up bundler.rb a bit
indirect authored
101 def load
91c74f4 Bundle.load and Bundle.runtime are the same thing again.
Carl Lerche authored
102 @load ||= Runtime.new(root, definition)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
103 end
67859e4 Moving in thor
Carlhuda authored
104
625818a @indirect Clean up bundler.rb a bit
indirect authored
105 def definition
2b9094e Scope specs in the lock file by source
Carl Lerche authored
106 @definition ||= begin
107 configure
108 lockfile = root.join("Gemfile.lock")
109 Definition.build(default_gemfile, lockfile)
110 end
ab5b1fc Add Bundler.flexdef, move locking into Environment, and lock from fle…
Carlhuda authored
111 end
112
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
113 def home
625818a @indirect Clean up bundler.rb a bit
indirect authored
114 bundle_path.join("bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
115 end
f31835e More work towards awesomeness
Carlhuda authored
116
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
117 def install_path
118 home.join("gems")
119 end
0d2492d Add more stuff for git
Carl Lerche authored
120
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
121 def specs_path
122 bundle_path.join("specifications")
123 end
124
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
125 def cache
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
126 bundle_path.join("cache/bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
127 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
128
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
129 def root
2d87c36 Move <root>/vendor/cache to a Bundler class method
Carl Lerche authored
130 default_gemfile.dirname.expand_path
131 end
132
133 def app_cache
134 root.join("vendor/cache")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
135 end
136
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by…
Carl Lerche authored
137 def tmp
138 "#{Gem.user_home}/.bundler/tmp"
139 end
140
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
141 def settings
142 @settings ||= Settings.new(root)
143 end
144
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
145 def with_clean_env
146 bundled_env = ENV.to_hash
147 ENV.replace(ORIGINAL_ENV)
148 yield
149 ensure
150 ENV.replace(bundled_env.to_hash)
151 end
152
fb1e725 Make bundler/setup something you can add to your .profile. To do this…
Carlhuda authored
153 def default_gemfile
154 SharedHelpers.default_gemfile
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
155 end
156
32a2eb2 First pass at getting bundler to play well when $GEM_HOME is owned by…
Carl Lerche authored
157 def requires_sudo?
158 case
159 when File.writable?(bundle_path) ||
160 `which sudo 2>NUL`.empty? ||
161 File.owned?(bundle_path)
162 false
163 else
164 true
165 end
166 rescue Errno::ENOENT
167 false
168 end
169
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
170 private
171
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
172 def configure_gem_home_and_path
3d82929 Separate bundle install foo and bundle install --disable-shared-gems.
Carl Lerche authored
173 if settings[:disable_shared_gems]
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
174 ENV['GEM_PATH'] = ''
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
175 ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
176 else
7a7628c @indirect Don't duplicate gem paths
indirect authored
177 paths = [Gem.dir, Gem.path].flatten.compact.uniq.reject{|p| p.empty? }
55509f2 @indirect Ignore paths like GEM_HOME that are empty strings
indirect authored
178 ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
179 ENV["GEM_HOME"] = bundle_path.to_s
180 end
181
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
182 Gem.clear_paths
183 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
184 end
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
185 end
Something went wrong with that request. Please try again.