Class Index [+]

Quicksearch

Bundler

Constants

VERSION

We’re doing this because we might write tests that deal with other versions of bundler and we are unsure how to handle this better.

ORIGINAL_ENV
WINDOWS
FREEBSD
NULL

Attributes

rubygems[R]
ui[W]
bundle_path[W]

Public Class Methods

app_cache() click to toggle source
     # File lib/bundler.rb, line 174
174:     def app_cache
175:       root.join("vendor/cache")
176:     end
app_config_path() click to toggle source
     # File lib/bundler.rb, line 168
168:     def app_config_path
169:       ENV['BUNDLE_APP_CONFIG'] ?
170:         Pathname.new(ENV['BUNDLE_APP_CONFIG']).expand_path(root) :
171:         root.join('.bundle')
172:     end
bin_path() click to toggle source
    # File lib/bundler.rb, line 92
92:     def bin_path
93:       @bin_path ||= begin
94:         path = settings[:bin] || "bin"
95:         path = Pathname.new(path).expand_path(root)
96:         FileUtils.mkdir_p(path)
97:         Pathname.new(path).expand_path
98:       end
99:     end
bundle_path() click to toggle source
    # File lib/bundler.rb, line 88
88:     def bundle_path
89:       @bundle_path ||= Pathname.new(settings.path).expand_path(root)
90:     end
cache() click to toggle source
     # File lib/bundler.rb, line 160
160:     def cache
161:       bundle_path.join("cache/bundler")
162:     end
configure() click to toggle source
    # File lib/bundler.rb, line 77
77:     def configure
78:       @configured ||= begin
79:         configure_gem_home_and_path
80:         true
81:       end
82:     end
default_gemfile() click to toggle source
     # File lib/bundler.rb, line 194
194:     def default_gemfile
195:       SharedHelpers.default_gemfile
196:     end
default_lockfile() click to toggle source
     # File lib/bundler.rb, line 198
198:     def default_lockfile
199:       SharedHelpers.default_lockfile
200:     end
definition(unlock = nil) click to toggle source
     # File lib/bundler.rb, line 131
131:     def definition(unlock = nil)
132:       @definition = nil if unlock
133:       @definition ||= begin
134:         configure
135:         upgrade_lockfile
136:         Definition.build(default_gemfile, default_lockfile, unlock)
137:       end
138:     end
environment() click to toggle source
     # File lib/bundler.rb, line 127
127:     def environment
128:       Bundler::Environment.new(root, definition)
129:     end
home() click to toggle source
     # File lib/bundler.rb, line 148
148:     def home
149:       bundle_path.join("bundler")
150:     end
install_path() click to toggle source
     # File lib/bundler.rb, line 152
152:     def install_path
153:       home.join("gems")
154:     end
load() click to toggle source
     # File lib/bundler.rb, line 123
123:     def load
124:       @load ||= Runtime.new(root, definition)
125:     end
load_gemspec(file) click to toggle source
     # File lib/bundler.rb, line 229
229:     def load_gemspec(file)
230:       path = Pathname.new(file)
231:       # Eval the gemspec from its parent directory
232:       Dir.chdir(path.dirname.to_s) do
233:         contents = File.read(path.basename.to_s)
234:         begin
235:           Gem::Specification.from_yaml(contents)
236:           # Raises ArgumentError if the file is not valid YAML
237:         rescue ArgumentError, SyntaxError, Gem::EndOfYAMLException, Gem::Exception
238:           begin
239:             eval(contents, TOPLEVEL_BINDING, path.expand_path.to_s)
240:           rescue LoadError => e
241:             original_line = e.backtrace.find { |line| line.include?(path.to_s) }
242:             msg  = "There was a LoadError while evaluating #{path.basename}:\n  #{e.message}"
243:             msg << " from\n  #{original_line}" if original_line
244:             msg << "\n"
245: 
246:             if RUBY_VERSION >= "1.9.0"
247:               msg << "\nDoes it try to require a relative path? That doesn't work in Ruby 1.9."
248:             end
249: 
250:             raise GemspecError, msg
251:           end
252:         end
253:       end
254:     end
mkdir_p(path) click to toggle source
     # File lib/bundler.rb, line 213
213:     def mkdir_p(path)
214:       if requires_sudo?
215:         sudo "mkdir -p '#{path}'" unless File.exist?(path)
216:       else
217:         FileUtils.mkdir_p(path)
218:       end
219:     end
read_file(file) click to toggle source
     # File lib/bundler.rb, line 225
225:     def read_file(file)
226:       File.open(file, "rb") { |f| f.read }
227:     end
require(*groups) click to toggle source
     # File lib/bundler.rb, line 119
119:     def require(*groups)
120:       setup(*groups).require(*groups)
121:     end
requires_sudo?() click to toggle source
     # File lib/bundler.rb, line 202
202:     def requires_sudo?
203:       return @requires_sudo if defined?(@checked_for_sudo) && @checked_for_sudo
204: 
205:       path = bundle_path
206:       path = path.parent until path.exist?
207:       sudo_present = !(`which sudo` rescue '').empty?
208: 
209:       @checked_for_sudo = true
210:       @requires_sudo = settings.allow_sudo? && !File.writable?(path) && sudo_present
211:     end
root() click to toggle source
     # File lib/bundler.rb, line 164
164:     def root
165:       default_gemfile.dirname.expand_path
166:     end
ruby_scope() click to toggle source
     # File lib/bundler.rb, line 140
140:     def ruby_scope
141:       "#{Bundler.rubygems.ruby_engine}/#{Gem::ConfigMap[:ruby_version]}"
142:     end
settings() click to toggle source
     # File lib/bundler.rb, line 182
182:     def settings
183:       @settings ||= Settings.new(app_config_path)
184:     end
setup(*groups) click to toggle source
     # File lib/bundler.rb, line 101
101:     def setup(*groups)
102:       # Just return if all groups are already loaded
103:       return @setup if defined?(@setup)
104: 
105:       if groups.empty?
106:         # Load all groups, but only once
107:         @setup = load.setup
108:       else
109:         @completed_groups ||= []
110:         # Figure out which groups haven't been loaded yet
111:         unloaded = groups - @completed_groups
112:         # Record groups that are now loaded
113:         @completed_groups = groups
114:         # Load any groups that are not yet loaded
115:         unloaded.any? ? load.setup(*unloaded) : load
116:       end
117:     end
specs_path() click to toggle source
     # File lib/bundler.rb, line 156
156:     def specs_path
157:       bundle_path.join("specifications")
158:     end
sudo(str) click to toggle source
     # File lib/bundler.rb, line 221
221:     def sudo(str)
222:       `sudo -p 'Enter your password to install the bundled RubyGems to your system: ' #{str}`
223:     end
tmp() click to toggle source
     # File lib/bundler.rb, line 178
178:     def tmp
179:       user_bundle_path.join("tmp", Process.pid.to_s)
180:     end
ui() click to toggle source
    # File lib/bundler.rb, line 84
84:     def ui
85:       @ui ||= UI.new
86:     end
user_bundle_path() click to toggle source
     # File lib/bundler.rb, line 144
144:     def user_bundle_path
145:       Pathname.new(Bundler.rubygems.user_home).join(".bundler")
146:     end
with_clean_env() click to toggle source
     # File lib/bundler.rb, line 186
186:     def with_clean_env
187:       bundled_env = ENV.to_hash
188:       ENV.replace(ORIGINAL_ENV)
189:       yield
190:     ensure
191:       ENV.replace(bundled_env.to_hash)
192:     end

Private Class Methods

configure_gem_home_and_path() click to toggle source
     # File lib/bundler.rb, line 258
258:     def configure_gem_home_and_path
259:       if settings[:disable_shared_gems]
260:         ENV['GEM_PATH'] = ''
261:         ENV['GEM_HOME'] = File.expand_path(bundle_path, root)
262:       elsif Bundler.rubygems.gem_dir != bundle_path.to_s
263:         possibles = [Bundler.rubygems.gem_dir, Bundler.rubygems.gem_path]
264:         paths = possibles.flatten.compact.uniq.reject { |p| p.empty? }
265:         ENV["GEM_PATH"] = paths.join(File::PATH_SEPARATOR)
266:         ENV["GEM_HOME"] = bundle_path.to_s
267:       end
268: 
269:       # TODO: This mkdir_p is only needed for JRuby <= 1.5 and should go away (GH #602)
270:       FileUtils.mkdir_p bundle_path.to_s rescue nil
271: 
272:       Bundler.rubygems.clear_paths
273:     end
upgrade_lockfile() click to toggle source
     # File lib/bundler.rb, line 275
275:     def upgrade_lockfile
276:       lockfile = default_lockfile
277:       if lockfile.exist? && lockfile.read(3) == "---"
278:         Bundler.ui.warn "Detected Gemfile.lock generated by 0.9, deleting..."
279:         lockfile.rmtree
280:       end
281:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.