Class: Bundler::Plugin::VaultSource
- Inherits:
-
Object
- Object
- Bundler::Plugin::VaultSource
- Defined in:
- lib/bundler/plugin/vault_source.rb
Overview
Bundler plugin source that installs gems from a .gemv vault file. A thin doorway over the Bundler Source API: it resolves the vault path, hands Bundler the gemspecs it can install, and delegates each gem's placement in the bundle to a VaultedGem.
Instance Method Summary collapse
-
#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.
- #fetch_gemspec_files ⇒ Object
-
#initialize(opts) ⇒ VaultSource
constructor
A new instance of VaultSource.
- #install(spec, opts = {}) ⇒ Object
-
#local_only! ⇒ Object
The inverse of remote!.
- #options_to_lock ⇒ Object
-
#prefer_local! ⇒ Object
Also invoked on every source during resolution (Definition#prefer_local!, for
--prefer-local). -
#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.
- #to_s ⇒ Object
Constructor Details
#initialize(opts) ⇒ VaultSource
Returns a new instance of VaultSource.
13 14 15 16 17 |
# File 'lib/bundler/plugin/vault_source.rb', line 13 def initialize(opts) super @vault_path = Pathname(@uri).(Bundler.root) @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.
69 |
# File 'lib/bundler/plugin/vault_source.rb', line 69 def cache(spec, custom_path = nil); end |
#fetch_gemspec_files ⇒ Object
19 20 21 22 23 24 25 26 27 |
# File 'lib/bundler/plugin/vault_source.rb', line 19 def fetch_gemspec_files validate_vault_exists! Gemvault::Vault.open(@vault_path) do |vault| vault.gem_entries .map { |entry| vault.spec_from_blob(entry) } .filter_map { |spec| gemspec_file_for(spec) } end end |
#install(spec, opts = {}) ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/bundler/plugin/vault_source.rb', line 54 def install(spec, opts = {}) gem = VaultedGem.new(spec) return gem.adopt if gem.installed? && !opts[:force] Bundler.ui.confirm "Installing #{gem.} from vault #{@uri}" extract(spec) { |gem_path| gem.install(gem_path:, build_args: opts[:build_args] || []) } end |
#local_only! ⇒ Object
The inverse of remote!. Bundler's local-only resolve (Definition#check!,
reached by bundle check) calls local_only! on every source. The base
Bundler::Plugin::API::Source defines no such hook, so without this the
command dies with NoMethodError; here it simply stops advertising gems
that live only inside the archive.
45 46 47 |
# File 'lib/bundler/plugin/vault_source.rb', line 45 def local_only! @allow_remote = false end |
#options_to_lock ⇒ Object
62 63 64 |
# File 'lib/bundler/plugin/vault_source.rb', line 62 def {} end |
#prefer_local! ⇒ Object
Also invoked on every source during resolution (Definition#prefer_local!,
for --prefer-local). The vault reads from one local file already, so
there is no remote to deprioritize.
52 |
# File 'lib/bundler/plugin/vault_source.rb', line 52 def prefer_local!; 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.
36 37 38 |
# File 'lib/bundler/plugin/vault_source.rb', line 36 def remote! @allow_remote = true end |
#to_s ⇒ Object
71 72 73 |
# File 'lib/bundler/plugin/vault_source.rb', line 71 def to_s "vault at #{@uri}" end |