Class: Bundler::Plugin::VaultSource

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/plugin/vault_source.rb

Overview

Bundler plugin source that installs gems from a .gemv vault file.

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ VaultSource

Returns a new instance of VaultSource.



8
9
10
11
12
# File 'lib/bundler/plugin/vault_source.rb', line 8

def initialize(opts)
  super
  @vault_path = resolve_vault_path(@uri)
  @allow_remote = false
end

Instance Method Details

#cache(spec, custom_path = nil) ⇒ Object

No source-level install_path to copy: VaultSource#install installs each gem into Bundler.bundle_path via RubyGemsGemInstaller, so the default Source#cache would dereference a non-existent directory.



49
# File 'lib/bundler/plugin/vault_source.rb', line 49

def cache(spec, custom_path = nil); end

#fetch_gemspec_filesObject



14
15
16
17
18
19
20
# File 'lib/bundler/plugin/vault_source.rb', line 14

def fetch_gemspec_files
  validate_vault_exists!

  Gemvault::Vault.open(@vault_path) do |vault|
    vault.gem_entries.filter_map { |entry| gemspec_file_for(vault, entry) }
  end
end

#install(spec, opts = {}) ⇒ Object



33
34
35
36
37
38
39
40
# File 'lib/bundler/plugin/vault_source.rb', line 33

def install(spec, opts = {})
  gem_dir = gem_dir_for(spec.full_name)
  return use_installed_gem(spec, gem_dir) if File.directory?(gem_dir) && !opts[:force]

  Bundler.ui.confirm "Installing #{version_message(spec)} from vault #{@uri}"
  install_into_bundle(spec, opts)
  spec.post_install_message
end

#options_to_lockObject



42
43
44
# File 'lib/bundler/plugin/vault_source.rb', line 42

def options_to_lock
  {}
end

#remote!Object

Bundler first asks a source, in local mode, which gems are already unpacked so it can tell what still needs installing, then switches to remote mode to resolve and install the rest. A vault gem is not on the load path until it is unpacked, so advertising one that still lives only inside the archive makes Bundler believe it is installed: it skips the install and the later require fails. Advertise not-yet-unpacked gems only once Bundler has asked for remote specs.



29
30
31
# File 'lib/bundler/plugin/vault_source.rb', line 29

def remote!
  @allow_remote = true
end

#to_sObject



51
52
53
# File 'lib/bundler/plugin/vault_source.rb', line 51

def to_s
  "vault at #{@uri}"
end