Class: Bundler::RubyGemsGemInstaller

Inherits:
Gem::Installer
  • Object
show all
Defined in:
lib/bundler/rubygems_gem_installer.rb

Direct Known Subclasses

Source::Path::Installer

Instance Method Summary collapse

Instance Method Details

#build_extensionsObject



67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/bundler/rubygems_gem_installer.rb', line 67

def build_extensions
  extension_cache_path = options[:bundler_extension_cache_path]
  unless extension_cache_path && extension_dir = spec.extension_dir
    require "shellwords" unless Bundler.rubygems.provides?(">= 3.2.25")
    return super
  end

  extension_dir = Pathname.new(extension_dir)
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
  if build_complete && !options[:force]
    SharedHelpers.filesystem_access(extension_dir.parent, &:mkpath)
    SharedHelpers.filesystem_access(extension_cache_path) do
      FileUtils.cp_r extension_cache_path, spec.extension_dir
    end
  else
    require "shellwords" # compensate missing require in rubygems before version 3.2.25
    super
    if extension_dir.directory? # not made for gems without extensions
      SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
      SharedHelpers.filesystem_access(extension_cache_path) do
        FileUtils.cp_r extension_dir, extension_cache_path
      end
    end
  end
end

#check_executable_overwrite(filename) ⇒ Object



7
8
9
# File 'lib/bundler/rubygems_gem_installer.rb', line 7

def check_executable_overwrite(filename)
  # Bundler needs to install gems regardless of binstub overwriting
end

#generate_pluginsObject



48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/bundler/rubygems_gem_installer.rb', line 48

def generate_plugins
  return unless Gem::Installer.instance_methods(false).include?(:generate_plugins)

  latest = Gem::Specification.stubs_for(spec.name).first
  return if latest && latest.version > spec.version

  ensure_writable_dir @plugins_dir

  if spec.plugins.empty?
    remove_plugins_for(spec, @plugins_dir)
  else
    regenerate_plugins_for(spec, @plugins_dir)
  end
end

#installObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/bundler/rubygems_gem_installer.rb', line 11

def install
  pre_install_checks

  run_pre_install_hooks

  spec.loaded_from = spec_file

  # Completely remove any previous gem files
  strict_rm_rf gem_dir
  strict_rm_rf spec.extension_dir

  SharedHelpers.filesystem_access(gem_dir, :create) do
    FileUtils.mkdir_p gem_dir, :mode => 0o755
  end

  extract_files

  build_extensions
  write_build_info_file
  run_post_build_hooks

  generate_bin
  generate_plugins

  write_spec

  SharedHelpers.filesystem_access("#{gem_home}/cache", :write) do
    write_cache_file
  end

  say spec.post_install_message unless spec.post_install_message.nil?

  run_post_install_hooks

  spec
end

#pre_install_checksObject



63
64
65
# File 'lib/bundler/rubygems_gem_installer.rb', line 63

def pre_install_checks
  super && validate_bundler_checksum(options[:bundler_expected_checksum])
end