Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 174 lines (145 sloc) 4.397 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'
ea9d8e1 @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
ea9d8e1 @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'
16 autoload :RemoteSpecification, 'bundler/remote_specification'
17 autoload :Resolver, 'bundler/resolver'
c0f8641 Persist spec groups to the lockfile
Carl Lerche authored
18 autoload :Runtime, 'bundler/runtime'
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
19 autoload :Settings, 'bundler/settings'
f7bfdde Actually disable system gems in .bundle/environment.rb
Carlhuda authored
20 autoload :SharedHelpers, 'bundler/shared_helpers'
529d792 Use tsort to order specifications. It makes teh crazy work.
Carl Lerche authored
21 autoload :SpecSet, 'bundler/spec_set'
152a50a Rename gemfile back to bundler
Carl Lerche authored
22 autoload :Source, 'bundler/source'
23 autoload :Specification, 'bundler/specification'
434fb42 First pass at output
Carlhuda authored
24 autoload :UI, 'bundler/ui'
67859e4 Moving in thor
Carlhuda authored
25
de5054a Rescue all Bundler exceptions and exit with appropriate error code
Carlhuda authored
26 class BundlerError < StandardError
27 def self.status_code(code = nil)
28 return @code unless code
29 @code = code
30 end
31
32 def status_code
33 self.class.status_code
34 end
35 end
36
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
37 class GemfileNotFound < BundlerError; status_code(10) ; end
38 class GemNotFound < BundlerError; status_code(7) ; end
39 class VersionConflict < BundlerError; status_code(6) ; end
40 class GemfileError < BundlerError; status_code(4) ; end
248ca34 Raise a better error in the case that a git repo is not cloned yet.
Carl Lerche authored
41 class PathError < BundlerError; status_code(13) ; end
5894862 Print useful warnings when deprecated options are used
Yehuda Katz authored
42 class GitError < BundlerError; status_code(11) ; end
43 class DeprecatedMethod < BundlerError; status_code(12) ; end
44 class DeprecatedOption < BundlerError; status_code(12) ; end
ffef5a1 @wycats If an option is invalid, don't fail silently
wycats authored
45 class InvalidOption < BundlerError; status_code(15) ; end
67859e4 Moving in thor
Carlhuda authored
46
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
47 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
48 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
49
50 def configure
51 @configured ||= begin
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
52 configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
53 true
54 end
55 end
434fb42 First pass at output
Carlhuda authored
56
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
57 def ui
58 @ui ||= UI.new
59 end
434fb42 First pass at output
Carlhuda authored
60
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
61 def bundle_path
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
62 @bundle_path ||= begin
58b31d8 Namespace the default bundle path to support with the ruby engine and…
Carlhuda authored
63 path = settings[:path] || "#{Gem.user_home}/.bundle/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
64 Pathname.new(path).expand_path(root)
65 end
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
66 end
67
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
68 def setup(*groups)
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
69 return @setup if @setup
70
71 if groups.empty?
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
72 # Load all groups, but only once
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
73 @setup = load.setup
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
74 else
75 # Figure out which groups haven't been loaded yet
76 unloaded = groups - (@completed_groups || [])
77 # Record groups that are now loaded
78 @completed_groups = groups | (@completed_groups || [])
79 # Load any groups that are not yet loaded
80 unloaded.any? ? load.setup(*unloaded) : load
81 end
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
82 end
ce350cc Get a simple bbl install working
Carlhuda authored
83
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
84 def require(*groups)
69acfd8 @indirect Call Bundler.setup from Bundler.require, only set up each group once
indirect authored
85 setup(*groups).require(*groups)
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
86 end
87
4c9a157 @indirect Clean up bundler.rb a bit, fix spec
indirect authored
88 def load
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
89 @load ||= begin
90 if current_env_file?
2c8d6ae @indirect Don't call #setup after loading env.rb in Bundler.load
indirect authored
91 @gem_loaded = true
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
92 Kernel.require env_file
93 Bundler
94 else
95 runtime
96 end
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
97 end
98 end
99
100 def runtime
4980111 @indirect Fix Bundler.setup so it can be called more than once safely
indirect authored
101 @runtime ||= Runtime.new(root, definition)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
102 end
67859e4 Moving in thor
Carlhuda authored
103
4c9a157 @indirect Clean up bundler.rb a bit, fix spec
indirect authored
104 def definition
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
105 configure
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
106 lockfile = root.join("Gemfile.lock")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
107 if lockfile.exist?
108 Definition.from_lock(lockfile)
109 else
4c9a157 @indirect Clean up bundler.rb a bit, fix spec
indirect authored
110 Definition.from_gemfile(default_gemfile)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
111 end
88741e6 First pass at bbl lock
Carlhuda authored
112 end
f31835e More work towards awesomeness
Carlhuda authored
113
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
114 def home
4c9a157 @indirect Clean up bundler.rb a bit, fix spec
indirect authored
115 bundle_path.join("bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
116 end
f31835e More work towards awesomeness
Carlhuda authored
117
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
118 def install_path
119 home.join("gems")
120 end
0d2492d Add more stuff for git
Carl Lerche authored
121
b42ee71 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
122 def specs_path
123 bundle_path.join("specifications")
124 end
125
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
126 def cache
b42ee71 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
127 bundle_path.join("cache/bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
128 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
129
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
130 def root
131 default_gemfile.dirname
132 end
133
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
134 def settings
135 @settings ||= Settings.new(root)
136 end
137
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
138 def env_file
139 SharedHelpers.env_file
140 end
141
ea9d8e1 @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
142 def with_clean_env
143 bundled_env = ENV.to_hash
144 ENV.replace(ORIGINAL_ENV)
145 yield
146 ensure
147 ENV.replace(bundled_env.to_hash)
148 end
149
fb1e725 Make bundler/setup something you can add to your .profile. To do this…
Carlhuda authored
150 def default_gemfile
151 SharedHelpers.default_gemfile
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
152 end
153
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
154 private
155
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
156 def configure_gem_home_and_path
3d82929 Separate bundle install foo and bundle install --disable-shared-gems.
Carl Lerche authored
157 if settings[:disable_shared_gems]
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
158 ENV['GEM_PATH'] = ''
9ef6aa6 @indirect Disable rubygems more fully when unlocked
indirect authored
159 ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
160 else
7a7628c @indirect Don't duplicate gem paths
indirect authored
161 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
162 ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
163 ENV["GEM_HOME"] = bundle_path.to_s
164 end
165
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
166 Gem.clear_paths
167 end
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
168
169 def current_env_file?
170 env_file.exist? && (env_file.read(100) =~ /Bundler #{Bundler::VERSION}/)
171 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
172 end
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem depen…
jeremy authored
173 end
Something went wrong with that request. Please try again.