Class: Bundler::RubyGemsGemInstaller
- Inherits:
-
Gem::Installer
- Object
- Gem::Installer
- Bundler::RubyGemsGemInstaller
- Defined in:
- lib/bundler/rubygems_gem_installer.rb
Direct Known Subclasses
Instance Method Summary collapse
- #build_extensions ⇒ Object
- #check_executable_overwrite(filename) ⇒ Object
- #ensure_writable_dir(dir) ⇒ Object
- #gem_checksum ⇒ Object
- #generate_bin_script(filename, bindir) ⇒ Object
- #generate_plugins ⇒ Object
- #install ⇒ Object
- #pre_install_checks ⇒ Object
- #spec ⇒ Object
Instance Method Details
#build_extensions ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/bundler/rubygems_gem_installer.rb', line 106 def build_extensions extension_cache_path = [:bundler_extension_cache_path] extension_dir = spec.extension_dir unless extension_cache_path && extension_dir prepare_extension_build(extension_dir) return super end build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?) if build_complete && ![:force] SharedHelpers.filesystem_access(File.dirname(extension_dir)) do |p| FileUtils.mkpath p end SharedHelpers.filesystem_access(extension_cache_path) do FileUtils.cp_r extension_cache_path, extension_dir end else prepare_extension_build(extension_dir) super 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 |
#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 |
#ensure_writable_dir(dir) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/bundler/rubygems_gem_installer.rb', line 63 def ensure_writable_dir(dir) super rescue Gem::FilePermissionError # Ignore permission checks in RubyGems. Instead, go on, and try to write # for real. We properly handle permission errors when they happen. nil end |
#gem_checksum ⇒ Object
140 141 142 |
# File 'lib/bundler/rubygems_gem_installer.rb', line 140 def gem_checksum Checksum.from_gem_package(@package) end |
#generate_bin_script(filename, bindir) ⇒ Object
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 |
# File 'lib/bundler/rubygems_gem_installer.rb', line 87 def generate_bin_script(filename, bindir) bin_script_path = File.join bindir, formatted_program_filename(filename) Gem.open_file_with_lock(bin_script_path) do require "fileutils" FileUtils.rm_f bin_script_path # prior install may have been --no-wrappers File.open(bin_script_path, "wb", 0o755) do |file| file.write app_script_text(filename) file.chmod([:prog_mode] || 0o755) end end verbose bin_script_path generate_windows_script filename, bindir end |
#generate_plugins ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/bundler/rubygems_gem_installer.rb', line 71 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 |
#install ⇒ Object
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 47 48 49 50 51 |
# 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 SharedHelpers.filesystem_access(gem_dir, :write) do extract_files end build_extensions if spec.extensions.any? write_build_info_file run_post_build_hooks SharedHelpers.filesystem_access(bin_dir, :write) do generate_bin end generate_plugins write_spec SharedHelpers.filesystem_access("#{gem_home}/cache", :write) do write_cache_file end say spec. unless spec..nil? run_post_install_hooks spec end |
#pre_install_checks ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/bundler/rubygems_gem_installer.rb', line 54 def pre_install_checks super rescue Gem::FilePermissionError # Ignore permission checks in RubyGems. Instead, go on, and try to write # for real. We properly handle permission errors when they happen. nil end |