Class: Gemvault::VaultUpgrade

Inherits:
Object
  • Object
show all
Includes:
FileUtils
Defined in:
lib/gemvault/vault_upgrade.rb

Overview

Migrates a vault to the current storage format by reading it through its existing backend and rewriting it through the current-format writer, then atomically swapping the file into place. Each gem's created_at carries over as the source backend reports it -- which for a format-2 vault is a fresh stamp, its stored times being unreadable (see LegacyTarvault).

Defined Under Namespace

Classes: GemCopy, Plan

Instance Method Summary collapse

Constructor Details

#initialize(path, backup: true) ⇒ VaultUpgrade

Returns a new instance of VaultUpgrade.



38
39
40
41
# File 'lib/gemvault/vault_upgrade.rb', line 38

def initialize(path, backup: true)
  @path = Pathname(path).expand_path
  @backup = backup
end

Instance Method Details

#callObject



51
52
53
54
55
56
57
58
# File 'lib/gemvault/vault_upgrade.rb', line 51

def call
  summary = plan
  return summary if summary.no_op?

  backup! if @backup
  rebuild(summary.gem_count)
  summary
end

#planObject



43
44
45
46
47
48
49
# File 'lib/gemvault/vault_upgrade.rb', line 43

def plan
  Deprecation.silence do
    Vault.open(@path) do |vault|
      Plan.new(from_version: vault.format_version, to_version: Vault::CURRENT_FORMAT, gem_count: vault.size)
    end
  end
end