class Webpacker::Manifest

Public Class Methods

file_path() click to toggle source
# File lib/webpacker/manifest.rb, line 12
def file_path
  Webpacker::Configuration.manifest_path
end
lookup(name) click to toggle source
# File lib/webpacker/manifest.rb, line 16
def lookup(name)
  load if Webpacker.env.development?

  if Webpacker.env.test?
    find(name) || compile_and_find!(name)
  else
    find!(name)
  end
end
lookup_path(name) click to toggle source
# File lib/webpacker/manifest.rb, line 26
def lookup_path(name)
  Rails.root.join(File.join(Webpacker::Configuration.public_path, lookup(name)))
end

Private Class Methods

compile_and_find!(name) click to toggle source
# File lib/webpacker/manifest.rb, line 40
def compile_and_find!(name)
  Webpacker.compile
  find!(name)
end
find(name) click to toggle source
# File lib/webpacker/manifest.rb, line 31
def find(name)
  instance.data[name.to_s] if instance
end
find!(name) click to toggle source
# File lib/webpacker/manifest.rb, line 35
def find!(name)
  raise Webpacker::FileLoader::FileLoaderError.new("Webpacker::Manifest.load must be called first") unless instance
  instance.data[name.to_s] || raise(Webpacker::FileLoader::NotFoundError.new("Can't find #{name} in #{file_path}. Is webpack still compiling?"))
end

Private Instance Methods

load() click to toggle source
Calls superclass method Webpacker::FileLoader::load
# File lib/webpacker/manifest.rb, line 47
def load
  return super unless File.exist?(@path)
  JSON.parse(File.read(@path))
end