class Simpacker::Manifest

Attributes

config[R]

Public Class Methods

new(config) click to toggle source
# File lib/simpacker/manifest.rb, line 8
def initialize(config)
  @config = config
end

Public Instance Methods

lookup(*names) click to toggle source
# File lib/simpacker/manifest.rb, line 12
def lookup(*names)
  data.dig(*names.map(&:to_s))
end
lookup!(*names) click to toggle source
# File lib/simpacker/manifest.rb, line 16
def lookup!(*names)
  lookup(*names) || handle_missing_entry(names)
end

Private Instance Methods

data() click to toggle source
# File lib/simpacker/manifest.rb, line 26
def data
  if config.cache_manifest?
    @data ||= load
  else
    load
  end
end
handle_missing_entry(names) click to toggle source
# File lib/simpacker/manifest.rb, line 22
def handle_missing_entry(names)
  raise Simpacker::Manifest::MissingEntryError, "Missing field: #{names.join('.')}"
end
load() click to toggle source
# File lib/simpacker/manifest.rb, line 34
def load
  if config.manifest_path.exist? && config.manifest_path.file?
    JSON.parse(config.manifest_path.read)
  else
    raise Simpacker::Manifest::MissingFileError, "Missing manifest file: #{config.manifest_path}"
  end
end