Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 168 lines (139 sloc) 4.13 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'
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
2a24019 @indirect Print a useful error if a gemspec require fails
indirect authored
45 class GemspecError < BundlerError; status_code(14) ; end
7514b20 @wycats If an option is invalid, don't fail silently
wycats authored
46 class InvalidOption < BundlerError; status_code(15) ; end
67859e4 Moving in thor
Carlhuda authored
47
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
48 class << self
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
49 attr_writer :ui, :bundle_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
50
51 def configure
52 @configured ||= begin
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
53 configure_gem_home_and_path
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
54 true
55 end
56 end
434fb42 First pass at output
Carlhuda authored
57
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
58 def ui
59 @ui ||= UI.new
60 end
434fb42 First pass at output
Carlhuda authored
61
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
62 def bundle_path
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
63 @bundle_path ||= begin
58b31d8 Namespace the default bundle path to support with the ruby engine and ve...
Carlhuda authored
64 path = settings[:path] || "#{Gem.user_home}/.bundle/#{Gem.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
65 Pathname.new(path).expand_path(root)
66 end
5ad1279 Add the ability to set bundle env settings in a .bundleconfig file
Carl Lerche authored
67 end
68
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
69 def setup(*groups)
625818a @indirect Clean up bundler.rb a bit
indirect authored
70 load.setup(*groups)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
71 end
ce350cc Get a simple bbl install working
Carlhuda authored
72
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
73 def require(*groups)
69acfd8 @indirect Call Bundler.setup from Bundler.require, only set up each group once
indirect authored
74 setup(*groups).require(*groups)
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
75 end
76
625818a @indirect Clean up bundler.rb a bit
indirect authored
77 def load
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
78 if current_env_file?
79 SharedHelpers.gem_loaded = true
80 Kernel.require env_file
81 Bundler
82 else
83 runtime
84 end
85 end
86
87 def runtime
88 Runtime.new(root, definition)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
89 end
67859e4 Moving in thor
Carlhuda authored
90
625818a @indirect Clean up bundler.rb a bit
indirect authored
91 def definition
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
92 configure
78a6b48 Rename vendor/lock.yml to Gemfile.lock
Carl Lerche authored
93 lockfile = root.join("Gemfile.lock")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
94 if lockfile.exist?
95 Definition.from_lock(lockfile)
96 else
625818a @indirect Clean up bundler.rb a bit
indirect authored
97 Definition.from_gemfile(default_gemfile)
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
98 end
88741e6 First pass at bbl lock
Carlhuda authored
99 end
f31835e More work towards awesomeness
Carlhuda authored
100
ab5b1fc Add Bundler.flexdef, move locking into Environment, and lock from flex_i...
Carlhuda authored
101 # TODO: obvious
102 def flexdef
103 configure
104 lockfile = root.join("Gemfile.lock")
105 Definition.flexdef(default_gemfile, lockfile)
106 end
107
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
108 def home
625818a @indirect Clean up bundler.rb a bit
indirect authored
109 bundle_path.join("bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
110 end
f31835e More work towards awesomeness
Carlhuda authored
111
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
112 def install_path
113 home.join("gems")
114 end
0d2492d Add more stuff for git
Carl Lerche authored
115
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
116 def specs_path
117 bundle_path.join("specifications")
118 end
119
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
120 def cache
0d92de7 @indirect Add Bundler::Source::BundlerGems, to distingush from SystemGems.
indirect authored
121 bundle_path.join("cache/bundler")
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
122 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
123
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
124 def root
125 default_gemfile.dirname
126 end
127
ea08895 Add the ability to specify a location with bundle install
Carl Lerche authored
128 def settings
129 @settings ||= Settings.new(root)
130 end
131
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
132 def env_file
133 SharedHelpers.env_file
134 end
135
33154fd @joshbuddy Add Bundler.with_clean_env for blocks of ruby without a bundled env
joshbuddy authored
136 def with_clean_env
137 bundled_env = ENV.to_hash
138 ENV.replace(ORIGINAL_ENV)
139 yield
140 ensure
141 ENV.replace(bundled_env.to_hash)
142 end
143
fb1e725 Make bundler/setup something you can add to your .profile. To do this, a...
Carlhuda authored
144 private
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
145
fb1e725 Make bundler/setup something you can add to your .profile. To do this, a...
Carlhuda authored
146 def default_gemfile
147 SharedHelpers.default_gemfile
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
148 end
149
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
150 def configure_gem_home_and_path
3d82929 Separate bundle install foo and bundle install --disable-shared-gems.
Carl Lerche authored
151 if settings[:disable_shared_gems]
152 ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
153 ENV['GEM_PATH'] = ''
154 else
7a7628c @indirect Don't duplicate gem paths
indirect authored
155 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
156 ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
739c0f3 Install bundles to ~/.bundle by default
Carlhuda authored
157 ENV["GEM_HOME"] = bundle_path.to_s
158 end
159
bc310f7 First pass at being able to set the bundle install path.
Carl Lerche authored
160 Gem.clear_paths
161 end
76c6bb7 @indirect Bundler.setup now loads .bundle/environment.rb if it is current
indirect authored
162
163 def current_env_file?
164 env_file.exist? && (env_file.read(100) =~ /Bundler #{Bundler::VERSION}/)
165 end
ee0e2c1 Start working on the environment.rb lock file
Carl Lerche authored
166 end
a8cbf77 @jeremy Group autorequire: pass :require => 'autorequire' option to gem dependen...
jeremy authored
167 end
Something went wrong with that request. Please try again.