Class: Gemvault::LegacyTarvault

Inherits:
Object
  • Object
show all
Extended by:
VaultSession
Includes:
GemExtraction
Defined in:
lib/gemvault/legacy_tarvault.rb

Overview

Read-only reader for a format-2 vault: a tarball whose index is the manifest.json gemvault wrote through 0.2.x. It exists so gemvault upgrade migrates such a vault through the same pipeline every other format takes, rather than leaving the gems stranded behind an error.

It does not read that manifest. The index is derived from the payload instead: each stored .gem carries its own gemspec, which is where the manifest's identity fields came from in the first place. That keeps the old notation from re-entering the codebase to be parsed (issue #25) and makes the reader indifferent to a manifest that is damaged or missing.

Two things the old index held are consequently gone. Each gem's stored time is unrecoverable, so entries are stamped when the vault is opened; and the per-gem digests cannot be checked, so a migrated gem is trusted as the bytes found in the archive -- the new vault records fresh digests of exactly what it copied.

Constant Summary collapse

FORMAT_VERSION =
2

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from VaultSession

open

Methods included from GemExtraction

#spec_from_blob, #specs, #with_gem_file

Constructor Details

#initialize(path) ⇒ LegacyTarvault

Returns a new instance of LegacyTarvault.



41
42
43
44
45
46
# File 'lib/gemvault/legacy_tarvault.rb', line 41

def initialize(path)
  @path = Pathname(path).expand_path
  @archive = Tarball.new(@path)
  @closed = false
  open_vault!
end

Instance Attribute Details

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

Instance Method Details

#addObject



48
49
50
# File 'lib/gemvault/legacy_tarvault.rb', line 48

def add(*)
  raise Vault::ReadOnlyError, read_only_message
end

#closeObject



71
72
73
# File 'lib/gemvault/legacy_tarvault.rb', line 71

def close
  @closed = true
end

#closed?Boolean

Returns:

  • (Boolean)


75
# File 'lib/gemvault/legacy_tarvault.rb', line 75

def closed? = @closed

#format_versionObject



67
# File 'lib/gemvault/legacy_tarvault.rb', line 67

def format_version = FORMAT_VERSION

#gem_data(entry) ⇒ Object



56
57
58
59
60
61
# File 'lib/gemvault/legacy_tarvault.rb', line 56

def gem_data(entry)
  bytes = @archive.read(entry.filename)
  raise Vault::NotFoundError, "Gem not found: #{entry}" unless bytes

  bytes
end

#gem_entriesObject



63
64
65
# File 'lib/gemvault/legacy_tarvault.rb', line 63

def gem_entries
  @gem_entries ||= derived_entries
end

#removeObject



52
53
54
# File 'lib/gemvault/legacy_tarvault.rb', line 52

def remove(*)
  raise Vault::ReadOnlyError, read_only_message
end

#sizeObject



69
# File 'lib/gemvault/legacy_tarvault.rb', line 69

def size = gem_members.size