-
-
13 Jul 2016 03:38:34 UTC
- Distribution: DBIx-POS-Template
- Source (raw)
- Browse (raw)
- Changes
- How to Contribute
- Issues
- Testers (758 / 0 / 0)
- Kwalitee
Bus factor: 1- 72.13% Coverage
- License: perl_5
- Perl: v5.6.0
- Activity
24 month- Tools
- Download (7.98KB)
- MetaCPAN Explorer
- Permissions
- Subscribe to distribution
- Permalinks
- This version
- Latest version
- Dependencies
- Hash::Merge
- Pod::Parser
- Text::Template
- and possibly others
- Reverse dependencies
- CPAN Testers List
- Dependency graph
- DBIx::POS::Template
- VERSION
- NAME
- SYNOPSIS
- DESCRIPTION
- METHODS
- SEE ALSO
- AUTHOR
- BUGS / CONTRIBUTING
- COPYRIGHT
DBIx::POS::Template
Доброго всем
¡ ¡ ¡ ALL GLORY TO GLORIA ! ! !
VERSION
0.067
NAME
DBIx::POS::Template - is a fork of DBIx::POS. Define a dictionary of SQL statements in a POD dialect (POS) plus expand template sql with embedded Perl using Text::Template.
SYNOPSIS
use DBIx::POS::Template; # separate object my $pos = DBIx::POS::Template->new(__FILE__, ...); # or singleton DBIx::POS::Template->instance($file, ...); my $sql = $pos->{test1}->template(where => "bar = ?"); # or $pos->template('test1', where => "bar = ?") =pod =name test1 =desc test the DBIx::POS::Template module =param # Some arbitrary parameters as perl code (eval) { cache=>1, # will be prepare_cached } =sql select * from foo {% $where %} ; =cut
Or:
package POS::Foo; use DBIx::POS::Template; use Hash::Merge qw(merge); my $default = {foo=>'bar',}; sub new { my $proto = shift; DBIx::POS::Template->new(__FILE__, template => merge({@_}, $default)); # or DBIx::POS::Template->instance(... }
DESCRIPTION
DBIx::POS::Template is subclass Pod::Parser to define a POD dialect for writing a SQL dictionary(s) with templating.
By separating the SQL code from its normal context of execution, it encourages you to do other things with it---for instance, it is easy to create a script that can do performance testing of certain SQL statements in isolation, or to create generic command-line wrapper around your SQL statements.
By giving a framework for documenting the SQL, it encourages documentation of the intent and/or implementation of the SQL code. It also provides all of that information in a format from which other documentation could be generated---say, a chunk of DocBook for incorporation into a guide to programming the application.
This class whould work as separate objects per pod-file or as singleton for all processed files with one dictionary of them.
METHODS
new($file, <options>)
Create separate object and process $file POS with options names:
TT | tt
Optional hashref will passing to Text::Template->new() for each parsed statement. By default only defined the key:
..., TT => {DELIMITERS => ['{%', '%}'],},
For instance this hashref will be merged with previous instance invokes.
template
..., template => {foo=>1,},
Optional hashref of default values for each statement template. For instance this hashref will be merged with previous instance invokes.
instance($file, <options>)
Return singleton dictionary object, parsed $file keys will collapse/override with previous instances files. Same options as
new
. tt and template options merge with previous options of instance invokes.template($key, var1 => ..., var2 => ...)
Fill in dictionary sql with variables by Text::Template#HASH. Other syntax:
$pos->{$key}->template(var1 => ..., var2 => ...)
SEE ALSO
AUTHOR
Михаил Че (Mikhail Che),
<mche[-at-]cpan.org>
BUGS / CONTRIBUTING
Please report any bugs or feature requests at https://github.com/mche/DBIx-POS-Template/issues. Pull requests also welcome.
COPYRIGHT
Copyright 2016 Mikhail Che.
This module is free software; you can redistribute it and/or modify it under the term of the Perl itself.
Module Install Instructions
To install DBIx::POS::Template, copy and paste the appropriate command in to your terminal.
cpanm DBIx::POS::Template
perl -MCPAN -e shell install DBIx::POS::Template
For more information on module installation, please visit the detailed CPAN module installation guide.