Class Index [+]

Quicksearch

Bundler::Installer

Attributes

post_install_messages[RW]

Public Class Methods

install(root, definition, options = {}) click to toggle source
    # File lib/bundler/installer.rb, line 10
10:     def self.install(root, definition, options = {})
11:       installer = new(root, definition)
12:       installer.run(options)
13:       installer
14:     end

Public Instance Methods

run(options) click to toggle source
    # File lib/bundler/installer.rb, line 16
16:     def run(options)
17:       # Create the BUNDLE_PATH directory
18:       begin
19:         Bundler.bundle_path.mkpath unless Bundler.bundle_path.exist?
20:       rescue Errno::EEXIST
21:         raise PathError, "Could not install to path `#{Bundler.settings[:path]}` " +
22:           "because of an invalid symlink. Remove the symlink so the directory can be created."
23:       end
24: 
25:       if Bundler.settings[:frozen]
26:         @definition.ensure_equivalent_gemfile_and_lockfile(options[:deployment])
27:       end
28: 
29:       if dependencies.empty?
30:         Bundler.ui.warn "The Gemfile specifies no dependencies"
31:         lock
32:         return
33:       end
34: 
35:       if Bundler.default_lockfile.exist? && !options["update"]
36:         begin
37:           tmpdef = Definition.build(Bundler.default_gemfile, Bundler.default_lockfile, nil)
38:           local = true unless tmpdef.new_platform? || tmpdef.missing_specs.any?
39:         rescue BundlerError
40:         end
41:       end
42: 
43:       # Since we are installing, we can resolve the definition
44:       # using remote specs
45:       unless local
46:         options["local"] ?
47:           @definition.resolve_with_cache! :
48:           @definition.resolve_remotely!
49:       end
50: 
51:       # Must install gems in the order that the resolver provides
52:       # as dependencies might actually affect the installation of
53:       # the gem.
54:       Installer.post_install_messages = {}
55:       specs.each do |spec|
56:         install_gem_from_spec(spec, options[:standalone])
57:       end
58: 
59:       lock
60:       generate_standalone(options[:standalone]) if options[:standalone]
61:     end

Private Instance Methods

generate_bundler_executable_stubs(spec) click to toggle source
     # File lib/bundler/installer.rb, line 98
 98:     def generate_bundler_executable_stubs(spec)
 99:       bin_path = Bundler.bin_path
100:       template = File.read(File.expand_path('../templates/Executable', __FILE__))
101:       relative_gemfile_path = Bundler.default_gemfile.relative_path_from(bin_path)
102:       ruby_command = Thor::Util.ruby_command
103: 
104:       spec.executables.each do |executable|
105:         next if executable == "bundle"
106:         File.open "#{bin_path}/#{executable}", 'w', 0755 do |f|
107:           f.puts ERB.new(template, nil, '-').result(binding)
108:         end
109:       end
110:     end
generate_standalone(groups) click to toggle source
     # File lib/bundler/installer.rb, line 127
127:     def generate_standalone(groups)
128:       standalone_path = Bundler.settings[:path]
129:       bundler_path = File.join(standalone_path, "bundler")
130:       FileUtils.mkdir_p(bundler_path)
131: 
132:       paths = []
133: 
134:       if groups.empty?
135:         specs = Bundler.definition.requested_specs
136:       else
137:         specs = Bundler.definition.specs_for groups.map { |g| g.to_sym }
138:       end
139: 
140:       specs.each do |spec|
141:         next if spec.name == "bundler"
142: 
143:         spec.require_paths.each do |path|
144:           full_path = File.join(spec.full_gem_path, path)
145:           paths << Pathname.new(full_path).relative_path_from(Bundler.root.join(bundler_path))
146:         end
147:       end
148: 
149: 
150:       File.open File.join(bundler_path, "setup.rb"), "w" do |file|
151:         file.puts "path = File.expand_path('..', __FILE__)"
152:         paths.each do |path|
153:           file.puts %{$:.unshift File.expand_path("\#{path}/#{path}")}
154:         end
155:       end
156:     end
generate_standalone_bundler_executable_stubs(spec) click to toggle source
     # File lib/bundler/installer.rb, line 112
112:     def generate_standalone_bundler_executable_stubs(spec)
113:       bin_path = Bundler.bin_path
114:       template = File.read(File.expand_path('../templates/Executable.standalone', __FILE__))
115:       ruby_command = Thor::Util.ruby_command
116: 
117:       spec.executables.each do |executable|
118:         next if executable == "bundle"
119:         standalone_path = Pathname(Bundler.settings[:path]).expand_path.relative_path_from(bin_path)
120:         executable_path = Pathname(spec.full_gem_path).join(spec.bindir, executable).relative_path_from(bin_path)
121:         File.open "#{bin_path}/#{executable}", 'w', 0755 do |f|
122:           f.puts ERB.new(template, nil, '-').result(binding)
123:         end
124:       end
125:     end
install_gem_from_spec(spec, standalone = false) click to toggle source
    # File lib/bundler/installer.rb, line 65
65:     def install_gem_from_spec(spec, standalone = false)
66:       # Download the gem to get the spec, because some specs that are returned
67:       # by rubygems.org are broken and wrong.
68:       Bundler::Fetcher.fetch(spec) if spec.source.is_a?(Bundler::Source::Rubygems)
69: 
70:       # Fetch the build settings, if there are any
71:       settings = Bundler.settings["build.#{spec.name}"]
72:       Bundler.rubygems.with_build_args [settings] do
73:         spec.source.install(spec)
74:         Bundler.ui.debug "from #{spec.loaded_from} "
75:       end
76: 
77:       # newline comes after installing, some gems say "with native extensions"
78:       Bundler.ui.info ""
79:       if Bundler.settings[:bin]
80:         standalone ? generate_standalone_bundler_executable_stubs(spec) : generate_bundler_executable_stubs(spec)
81:       end
82: 
83:       FileUtils.rm_rf(Bundler.tmp)
84:     rescue Exception => e
85:       # install hook failed
86:       raise e if e.is_a?(Bundler::InstallHookError)
87: 
88:       # other failure, likely a native extension build failure
89:       Bundler.ui.info ""
90:       Bundler.ui.warn "#{e.class}: #{e.message}"
91:       msg = "An error occured while installing #{spec.name} (#{spec.version}),"
92:       msg << " and Bundler cannot continue.\nMake sure that `gem install"
93:       msg << " #{spec.name} -v '#{spec.version}'` succeeds before bundling."
94:       Bundler.ui.debug e.backtrace.join("\n")
95:       raise Bundler::InstallError, msg
96:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.