Debian Codegraph @

lib/bundler/source/path/installer.rb

raw
1 # frozen_string_literal: true
2
3 require_relative "../../rubygems_gem_installer"
4
5 module Bundler
6 class Source
7 class Path
8 class Installer < Bundler::RubyGemsGemInstaller
9 attr_reader :spec
10
11 def initialize(spec, options = {})
12 @options = options
13 @spec = spec
14 @gem_dir = Bundler.rubygems.path(spec.full_gem_path)
15 @wrappers = true
16 @env_shebang = true
17 @format_executable = options[:format_executable] || false
18 @build_args = options[:build_args] || Bundler.rubygems.build_args
19 @gem_bin_dir = "#{Bundler.rubygems.gem_dir}/bin"
20 @disable_extensions = options[:disable_extensions]
21 @bin_dir = @gem_bin_dir
22 end
23
24 def post_install
25 run_hooks(:pre_install)
26
27 unless @disable_extensions
28 build_extensions
29 run_hooks(:post_build)
30 end
31
32 generate_bin unless spec.executables.empty?
33
34 run_hooks(:post_install)
35 end
36
37 private
38
39 def run_hooks(type)
40 hooks_meth = "#{type}_hooks"
41 return unless Gem.respond_to?(hooks_meth)
42 Gem.send(hooks_meth).each do |hook|
43 result = hook.call(self)
44 next unless result == false
45 location = " at #{$1}" if hook.inspect =~ /@(.*:\d+)/
46 message = "#{type} hook#{location} failed for #{spec.full_name}"
47 raise InstallHookError, message
48 end
49 end
50 end
51 end
52 end
53 end