Included Modules

Bundler::Runtime

Constants

REGEXPS

Public Instance Methods

cache() click to toggle source
    # File lib/bundler/runtime.rb, line 83
83:     def cache
84:       FileUtils.mkdir_p(cache_path)
85: 
86:       Bundler.ui.info "Updating .gem files in vendor/cache"
87:       specs.each do |spec|
88:         next if spec.name == 'bundler'
89:         spec.source.cache(spec) if spec.source.respond_to?(:cache)
90:       end
91:       prune_cache unless Bundler.settings[:no_prune]
92:     end
dependencies_for(*groups) click to toggle source
    # File lib/bundler/runtime.rb, line 73
73:     def dependencies_for(*groups)
74:       if groups.empty?
75:         dependencies
76:       else
77:         dependencies.select { |d| (groups & d.groups).any? }
78:       end
79:     end
prune_cache() click to toggle source
     # File lib/bundler/runtime.rb, line 94
 94:     def prune_cache
 95:       FileUtils.mkdir_p(cache_path)
 96: 
 97:       resolve = @definition.resolve
 98:       cached  = Dir["#{cache_path}/*.gem"]
 99: 
100:       cached = cached.delete_if do |path|
101:         spec = Gem::Format.from_file_by_path(path).spec
102: 
103:         resolve.any? do |s|
104:           s.name == spec.name && s.version == spec.version
105:         end
106:       end
107: 
108:       if cached.any?
109:         Bundler.ui.info "Removing outdated .gem files from vendor/cache"
110: 
111:         cached.each do |path|
112:           Bundler.ui.info "  * #{File.basename(path)}"
113:           File.delete(path)
114:         end
115:       end
116:     end
require(*groups) click to toggle source
    # File lib/bundler/runtime.rb, line 47
47:     def require(*groups)
48:       groups.map! { |g| g.to_sym }
49:       groups = [:default] if groups.empty?
50: 
51:       @definition.dependencies.each do |dep|
52:         # Skip the dependency if it is not in any of the requested
53:         # groups
54:         next unless ((dep.groups & groups).any? && dep.current_platform?)
55: 
56:         required_file = nil
57: 
58:         begin
59:           # Loop through all the specified autorequires for the
60:           # dependency. If there are none, use the dependency's name
61:           # as the autorequire.
62:           Array(dep.autorequire || dep.name).each do |file|
63:             required_file = file
64:             Kernel.require file
65:           end
66:         rescue LoadError => e
67:           REGEXPS.find { |r| r =~ e.message }
68:           raise if dep.autorequire || $1 != required_file
69:         end
70:       end
71:     end
setup(*groups) click to toggle source
    # File lib/bundler/runtime.rb, line 7
 7:     def setup(*groups)
 8:       # Has to happen first
 9:       clean_load_path
10: 
11:       specs = groups.any? ? @definition.specs_for(groups) : requested_specs
12: 
13:       setup_environment
14:       cripple_rubygems(specs)
15: 
16:       # Activate the specs
17:       specs.each do |spec|
18:         unless spec.loaded_from
19:           raise GemNotFound, "#{spec.full_name} is missing. Run `bundle` to get it."
20:         end
21: 
22:         if activated_spec = Gem.loaded_specs[spec.name] and activated_spec.version != spec.version
23:           e = Gem::LoadError.new "You have already activated #{activated_spec.name} #{activated_spec.version}, "                                   "but your Gemfile requires #{spec.name} #{spec.version}. Consider using bundle exec."
24:           e.name = spec.name
25:           e.version_requirement = Gem::Requirement.new(spec.version.to_s)
26:           raise e
27:         end
28: 
29:         Gem.loaded_specs[spec.name] = spec
30:         load_paths = spec.load_paths.reject {|path| $LOAD_PATH.include?(path)}
31:         $LOAD_PATH.unshift(*load_paths)
32:       end
33: 
34:       lock
35: 
36:       self
37:     end

Private Instance Methods

cache_path() click to toggle source
     # File lib/bundler/runtime.rb, line 120
120:     def cache_path
121:       root.join("vendor/cache")
122:     end
setup_environment() click to toggle source
     # File lib/bundler/runtime.rb, line 124
124:     def setup_environment
125:       begin
126:         ENV["BUNDLE_BIN_PATH"] = Gem.bin_path("bundler", "bundle", VERSION)
127:       rescue Gem::GemNotFoundException
128:         ENV["BUNDLE_BIN_PATH"] = File.expand_path("../../../bin/bundle", __FILE__)
129:       end
130: 
131:       # Set PATH
132:       paths = (ENV["PATH"] || "").split(File::PATH_SEPARATOR)
133:       paths.unshift "#{Bundler.bundle_path}/bin"
134:       ENV["PATH"] = paths.uniq.join(File::PATH_SEPARATOR)
135: 
136:       # Set BUNDLE_GEMFILE
137:       ENV["BUNDLE_GEMFILE"] = default_gemfile.to_s
138: 
139:       # Set RUBYOPT
140:       rubyopt = [ENV["RUBYOPT"]].compact
141:       if rubyopt.empty? || rubyopt.first !~ /-rbundler\/setup/
142:         rubyopt.unshift "-rbundler/setup"
143:         rubyopt.unshift "-I#{File.expand_path('../..', __FILE__)}"
144:         ENV["RUBYOPT"] = rubyopt.join(' ')
145:       end
146:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.