Need help with baked_file_system?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

schovi
149 Stars 16 Forks MIT License 56 Commits 4 Opened issues

Description

Virtual File System for Crystal language. Embedding your assets into final binary.

Services available

!
?

Need anything else?

Contributors list

# 175,248
Shell
create-...
Webpack
Crystal
26 commits
# 40,312
Crystal
postgre...
jsonb
SQL
17 commits
# 4,815
Ruby
cloudfl...
image-a...
sidekiq
4 commits
# 36,429
Elixir
Crystal
microfr...
unix-do...
3 commits
# 211,663
Shell
joycon
Crystal
Windows
1 commit
# 35,487
Crystal
Nim
repl
masonry...
1 commit

Baked File System

Include (bake them) static files into a binary at compile time and access them anytime you need.

Installation

Add this to your application's

shard.yml
:
dependencies:
  baked_file_system:
    github: schovi/baked_file_system
    version: 0.10.0

Usage

A custom type that extends

BakedFileSystem
is used as a file system. The macro
bake_folder
bakes all files in a given path into the virtual file system. Both relative and absolute paths are supported, as well as baking multiple folders.
require "baked_file_system"

class FileStorage extend BakedFileSystem

bake_folder "/home/my_name/work/crystal_project/public" bake_folder "../public" end

Files can be loaded using

get
and
get?
class methods.
file = FileStorage.get("path/to/file.png")

file.gets_to_end # returns content of file file.path # returns path of file file.size # returns size of original file

When try to get missing file,

get
raises a
BakedFileSystem::NoSuchFileError
exception while
get?
returns
nil
.
begin
  FileStorage.get "missing/file"
rescue BakedFileSystem::NoSuchFileError
  puts "File #{path} is missing"
end

FileStorage.get? "missing/file" # => nil

Development

TODO: Write development instructions here

Contributing

  1. Fork it ( https://github.com/schovi/bakedfilesystem/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

Contributors

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.