Class: Gemvault::VaultUpgrade
- Inherits:
-
Object
- Object
- Gemvault::VaultUpgrade
- 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. Preserves each gem's created_at.
Defined Under Namespace
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(path, backup: true) ⇒ VaultUpgrade
constructor
A new instance of VaultUpgrade.
- #plan ⇒ Object
Constructor Details
#initialize(path, backup: true) ⇒ VaultUpgrade
Returns a new instance of VaultUpgrade.
36 37 38 39 |
# File 'lib/gemvault/vault_upgrade.rb', line 36 def initialize(path, backup: true) @path = Pathname(path). @backup = backup end |
Instance Method Details
#call ⇒ Object
49 50 51 52 53 54 55 56 |
# File 'lib/gemvault/vault_upgrade.rb', line 49 def call summary = plan return summary if summary.no_op? backup! if @backup rebuild(summary.gem_count) summary end |
#plan ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/gemvault/vault_upgrade.rb', line 41 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 |