Class: WebpackerLite::Manifest

Inherits:
FileLoader show all
Defined in:
lib/webpacker_lite/manifest.rb

Instance Attribute Summary

Attributes inherited from FileLoader

#data, #mtime

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from FileLoader

load_instance

Class Method Details

.exist?Boolean

Helper method to determine if the manifest file exists.

Returns:

  • (Boolean)


15
16
17
18
# File 'lib/webpacker_lite/manifest.rb', line 15

def exist?
  path_object = WebpackerLite::Configuration.manifest_path
  path_object.exist?
end

.file_pathObject



20
21
22
# File 'lib/webpacker_lite/manifest.rb', line 20

def file_path
  WebpackerLite::Configuration.manifest_path
end

.lookup(name) ⇒ Object

Find the real file name from the manifest key.



41
42
43
44
45
46
47
# File 'lib/webpacker_lite/manifest.rb', line 41

def lookup(name)
  instance.confirm_manifest_exists

  load_instance
  raise WebpackerLite::FileLoader::FileLoaderError.new("WebpackerLite::Manifest.load must be called first") unless instance
  instance.data[name.to_s]
end

.lookup!(name) ⇒ Object

Same as lookup, but raises an error.



36
37
38
# File 'lib/webpacker_lite/manifest.rb', line 36

def lookup!(name)
  lookup(name) || missing_file_from_manifest_error(name)
end

.missing_file_from_manifest_error(bundle_name) ⇒ Object



24
25
26
27
28
29
30
31
32
33
# File 'lib/webpacker_lite/manifest.rb', line 24

def missing_file_from_manifest_error(bundle_name)
  msg = "    WebpackerLite can't find \#{bundle_name} in your manifest \#{file_path}. Possible causes:\n      1. You are hot reloading.\n      2. Webpack has not re-run to reflect updates.\n      3. You have misconfigured WebpackerLite's config/webpacker_lite.yml file.\n      4. Your Webpack configuration is not creating a manifest.\n  MSG\n  raise(WebpackerLite::FileLoader::NotFoundError.new(msg))\nend\n"

Instance Method Details

#confirm_manifest_existsObject



50
51
52
# File 'lib/webpacker_lite/manifest.rb', line 50

def confirm_manifest_exists
  raise missing_manifest_file_error(@path) unless File.exist?(@path)
end