Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jhthorsen/fuse-template
Read the output of templates in a mounted directory
https://github.com/jhthorsen/fuse-template
Last synced: 27 days ago
JSON representation
Read the output of templates in a mounted directory
- Host: GitHub
- URL: https://github.com/jhthorsen/fuse-template
- Owner: jhthorsen
- Created: 2009-07-23T08:45:54.000Z (over 15 years ago)
- Default Branch: master
- Last Pushed: 2010-06-19T11:49:59.000Z (over 14 years ago)
- Last Synced: 2024-10-16T11:58:42.945Z (3 months ago)
- Language: Perl
- Homepage: http://search.cpan.org/perldoc?Fuse::Template
- Size: 148 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README
- Changelog: Changes
Awesome Lists containing this project
README
NAME
Fuse::Template - Mount a directory with templates.VERSION
0.0201USAGE
"sudo" might be optional.MOUNT
Example SQLite:$ sudo fuse-template
--root /path/to/templates \
--mountpoint /path/to/mountpoint \
--schema dbi:SQLite:path/to/db \
;Example MySQL:
$ sudo fuse-template
--root /path/to/templates \
--mountpoint /path/to/mountpoint \
--schema "dbi:mysql:database=MyDB;host=127.1;port=3006 user pass" \
;See DBI for possible "--schema" formats.
UNMOUNT
This needs to be done manually for now. (Patches are welcome!)sudo umount /path/to/mountpoint;
DESCRIPTION
IMPORTANT! Version 0.02 of Fuse::Template breaks backward compat by
using the new "v7" naming convention from DBIx::Class::Schema::Loader.
Set the "SCHEMA_LOADER_BACKCOMPAT" environment variable, if you want the
old behavior.The idea with this project is to auto-maintain password files, and other
plain text files for different systems, with data from a database.See "examples/" in this distribution for templates.
Example file system structure:
root/ -> mountpooit/
root/somefile -> mountpoint/somefile
root/foo.tt -> mountpoint/foo
root/bar/baz.txt.tt -> mountpoint/bar/baz.txt"somefile" is accessible directly at "mountpoint". Template files (.tt)
are parsed and the output is accessible on mountpoint side. This is done
using Template::Toolkit.Files in mountpoint are read-only for now.
TEMPLATES
Here is an example template:root = [% self.root %]
[% rs = schema.resultset('MyTable') %]
[% rs = MyTable; # same as schema.resultset(...) %]
[% WHILE (row = rs.next) # get next row in resultset %]
col_name = [% row.col_name # retrieve column data %]
[% END %]See DBIx::Class for information on how to use the schema object, and
DBIx::Class::Resultset on how to select data and more...Available variables:
root
mountpoint
mountopts
self # this object
schema # DBIx::Class object
+ all resultsetset/tablesResultset use this naming convention to convert tablenames:
Table Name | Moniker Name
---------------------------
luser | Luser
luser_group | LuserGroup
luser-opts | LuserOptsSee "moniker_map" in DBIx::Class::Schema::Loader for details
INSTALLATION
On ubuntu:$ sudo aptitude install libfuse-perl
$ wget -q http://xrl.us/cpanm | perl - --sudo Fuse::TemplateSee App::cpanminus if you are curious about the "wget" command.
ATTRIBUTES
root
$object = $self->root;$object must be stringified to path where templates/files are located.
$object must follow the same API as Fuse::Template::Root.Can be set in constructor as:
root => \%constructor_args
root => $path_to_root%constructor_args can override defaults, while $path_to_root will only
override "path" attribute in root-object.mountpoint
$path = $self->mountpoint;Path to where the filesystem should be mounted.
mountopts
$str = $self->mountopts;Example mount option: "allow_other"
schema
$dbic_object = $self->schema;Can be set in constructor as:
schema => \%args
schema => "$dsn $username $password"See Fuse::Template::Schema for details.
debug
$bool = $self->debug;Enable/disable debug output from Fuse. Default is disabled.
METHODS
find_file
$real_path = $self->find_file($virtual_path);Returns path to the file in root path.
log
$bool = $self->log($level => $format => @args);AUTHOR
Jan Henning ThorsenLICENSE
This library is free software, you can redistribute it and/or modify it
under the same terms as Perl itself.