BakedFileSystem
A BakedFileSystem allows to include ("bake") static files into a compiled
binary and make them accessible at runtime using their path.
Usage
# Using BakedFileSystem.load
class MyFileSystem
extend BakedFileSystem
bake_folder "path/to/root/folder"
end
# Creating a file manually
class MyFileSystem
extend BakedFileSystem
bake_file "hello-world.txt", "Hello World\n"
end
Constants
Instance methods
Creates a BakedFile at path with content content and adds it to this file system.
Returns a BakedFile at path.
Raises NoSuchFileError if the virtual file does not exist.
Opens a file and yields it to the block, ensuring it's closed afterwards.
MyFiles.get("file.txt") do |file|
file.gets_to_end
end
Returns a BakedFile at path or nil if the virtual file does not exist.
Macros
Bakes all files in path into this baked file system.
If path is relative, it will be based on dir which defaults to __DIR__.
It will raise if there are no files found in path unless allow_empty is set to true.
The include_patterns parameter accepts an array of glob patterns to include specific files.
The exclude_patterns parameter accepts an array of glob patterns to exclude specific files.
The max_size parameter can be used to enforce a maximum total stored size limit (in bytes).
The compress parameter can be set to false to store files without gzip compression.
Creates a baked file system and loads contents of files in path.
If path is relative, it will be based on dir which defaults to __DIR__.
It will raise if there are no files found in path unless allow_empty is set to true.
DEPRECATED: Use extend BakedFileSystem and bake_folder instead.