This commit is contained in:
Adrian Malacoda 2017-10-26 02:38:08 -05:00
parent 0b87d77759
commit 42d1a87585
2 changed files with 29 additions and 0 deletions

View File

@ -1,2 +1,6 @@
# Plushie Narwhal
A loosely organized group of utilities for generating resources, bundling them, and generating code to use them.
For example: call browserify on an input javascript file, bake the resulting javascript into the binary, and wrap it in a Rocket route which serves it up.
This was yanked out of a build script for another project, so while it can be used standalone, the API is not particularly great yet.

25
TODO.md Normal file
View File

@ -0,0 +1,25 @@
# TODO
Make an API that actually makes sense. I'm thinking something along the lines of:
* ResourceGenerator, which accepts an input (always a file, static byte or character source, etc), and
transforms it into some other representation
* Convenience methods that add a file or an entire directory structure, guessing the content type etc.
* ResourceWriter, which just wraps the Generators and spits out the output file
## Sample
let mut routes = RocketRouteGenerator::new();
routes.add(RocketRoute {
source: browserify("foo.js"),
mountpoint: String::from("/foo.js"),
content_type: "JavaScript"
});
let mut templates = HandlebarsGenerator::new();
templates.add(HandlebarsTemplate {
source: PathBuf::from("templates/foo.hbs"),
name: "foo"
});
let mut writer = ResourceWriter::new();
writer.add_resources(routes);
writer.add_resources(templates);
writer.write("resources.rs");