Class: Bundler::Plugin::VaultedGem
- Inherits:
-
Object
- Object
- Bundler::Plugin::VaultedGem
- Defined in:
- lib/bundler/plugin/vaulted_gem.rb
Overview
A gem sourced from a vault as it lives (or will live) inside the bundle. Owns where the gem unpacks, whether it is already installed, installing an extracted .gem file, and anchoring its gemspec inside the gem directory -- Bundler derives full_gem_path from dirname(loaded_from), so the gemspec must sit beside the gem, not in specifications/.
Instance Method Summary collapse
-
#adopt ⇒ Object
Point the Bundler spec at the already-unpacked gem.
- #anchor(spec_ruby, dir: @gem_dir) ⇒ Object
-
#initialize(spec) ⇒ VaultedGem
constructor
A new instance of VaultedGem.
-
#install(gem_path:, build_args:) ⇒ Object
Install the extracted .gem file into the bundle, point the spec at it, and return its post-install message.
- #installed? ⇒ Boolean
- #version_message ⇒ Object
Constructor Details
#initialize(spec) ⇒ VaultedGem
Returns a new instance of VaultedGem.
11 12 13 14 |
# File 'lib/bundler/plugin/vaulted_gem.rb', line 11 def initialize(spec) @spec = spec @gem_dir = Bundler.bundle_path.join("gems", spec.full_name) end |
Instance Method Details
#adopt ⇒ Object
Point the Bundler spec at the already-unpacked gem.
27 28 29 30 31 32 |
# File 'lib/bundler/plugin/vaulted_gem.rb', line 27 def adopt Bundler.ui.debug "Using #{} from vault" @spec.full_gem_path = @gem_dir.to_s @spec.loaded_from = anchor(@spec.to_ruby) nil end |
#anchor(spec_ruby, dir: @gem_dir) ⇒ Object
43 44 45 46 47 |
# File 'lib/bundler/plugin/vaulted_gem.rb', line 43 def anchor(spec_ruby, dir: @gem_dir) gemspec = Pathname(dir).join("#{@spec.full_name}.gemspec") gemspec.write(spec_ruby) unless gemspec.exist? gemspec.to_s end |
#install(gem_path:, build_args:) ⇒ Object
Install the extracted .gem file into the bundle, point the spec at it, and return its post-install message.
36 37 38 39 40 41 |
# File 'lib/bundler/plugin/vaulted_gem.rb', line 36 def install(gem_path:, build_args:) installed = installer(gem_path:, build_args:).install @spec.full_gem_path = installed.full_gem_path @spec.loaded_from = anchor(installed.to_ruby, dir: installed.full_gem_path) @spec. end |
#installed? ⇒ Boolean
16 17 18 |
# File 'lib/bundler/plugin/vaulted_gem.rb', line 16 def installed? @gem_dir.directory? end |
#version_message ⇒ Object
20 21 22 23 24 |
# File 'lib/bundler/plugin/vaulted_gem.rb', line 20 def = "#{@spec.name} #{@spec.version}" += " (#{@spec.platform})" if @spec.platform != Gem::Platform::RUBY && !@spec.platform.nil? end |