| 1 | package Config::Any::TT2; | ||||||||||||
| 2 | |||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | |||||||||||||
| 6 | 3 | ▶ | use base 'Config::Any::Base'; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 7 | |||||||||||||
| 8 | 3 | our $VERSION = '0.12'; | |||||||||||
| 9 | |||||||||||||
| 10 | =head1 NAME | ||||||||||||
| 11 | |||||||||||||
| 12 | Config::Any::TT2 - Config::Any plugin for Config::TT2 files | ||||||||||||
| 13 | |||||||||||||
| 14 | =head1 SYNOPSIS | ||||||||||||
| 15 | |||||||||||||
| 16 | use Config::Any; | ||||||||||||
| 17 | |||||||||||||
| 18 | my $cfg_file = 'cfg.tt2'; | ||||||||||||
| 19 | |||||||||||||
| 20 | my $configs = Config::Any->load_files( | ||||||||||||
| 21 | { | ||||||||||||
| 22 | files => [$cfg_file], | ||||||||||||
| 23 | flatten_to_hash => 1, | ||||||||||||
| 24 | use_ext => 1, | ||||||||||||
| 25 | } | ||||||||||||
| 26 | ); | ||||||||||||
| 27 | |||||||||||||
| 28 | my $cfg = $configs->{$cfg_file}; | ||||||||||||
| 29 | |||||||||||||
| 30 | =head1 DESCRIPTION | ||||||||||||
| 31 | |||||||||||||
| 32 | Loads Config::TT2 files. Example: | ||||||||||||
| 33 | |||||||||||||
| 34 | [% # tt2 directive start-tag | ||||||||||||
| 35 | scalar = 'string' | ||||||||||||
| 36 | |||||||||||||
| 37 | array = [ 10 20 30 ] # commas are optional | ||||||||||||
| 38 | rev = array.reverse # powerful virtual methods | ||||||||||||
| 39 | item = array.0 # interpolate previous value | ||||||||||||
| 40 | |||||||||||||
| 41 | hash = { foo = 'bar' # hashes to any depth | ||||||||||||
| 42 | moo = array # points to above arrayref | ||||||||||||
| 43 | } | ||||||||||||
| 44 | %] # tt2 directive end-tag | ||||||||||||
| 45 | |||||||||||||
| 46 | =head1 METHODS | ||||||||||||
| 47 | |||||||||||||
| 48 | =head2 extensions( ) | ||||||||||||
| 49 | |||||||||||||
| 50 | return an array of valid extensions (C<tt2>, C<tt>). | ||||||||||||
| 51 | |||||||||||||
| 52 | =cut | ||||||||||||
| 53 | |||||||||||||
| 54 | 5 | ▶ | sub extensions { | ||||||||||
|
Subroutine
extensions: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 55 | 5 | return qw( tt2 tt ); | |||||||||||
| 56 | } | ||||||||||||
| 57 | |||||||||||||
| 58 | =head2 load( $file ) | ||||||||||||
| 59 | |||||||||||||
| 60 | Attempts to load C<$file> via Config::TT2. | ||||||||||||
| 61 | |||||||||||||
| 62 | =cut | ||||||||||||
| 63 | |||||||||||||
| 64 | 5 | ▶ | sub load { | ||||||||||
|
Subroutine
load: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 65 | 5 | my $class = shift; | |||||||||||
| 66 | 5 | my $file = shift; | |||||||||||
| 67 | 5 | ▶ | my $args = shift || {}; | ||||||||||
|
Condition50%1/2
shift() || {}
MC/DC0%0/1
shift() || {}
shift()
Truth table50%1/2
A
A= shift()
| |||||||||||||
| 68 | |||||||||||||
| 69 | 5 | require Config::TT2; | |||||||||||
| 70 | 5 | my $cfg = Config::TT2->new( $args )->process( $file ); | |||||||||||
| 71 | |||||||||||||
| 72 | 2 | return $cfg; | |||||||||||
| 73 | |||||||||||||
| 74 | # maybe we need instead a shallow, unblessed copy for Config::Any | ||||||||||||
| 75 | # return { %$cfg }; | ||||||||||||
| 76 | } | ||||||||||||
| 77 | |||||||||||||
| 78 | =head2 requires_all_of( ) | ||||||||||||
| 79 | |||||||||||||
| 80 | Specifies that this module requires L<Config::TT2> in order to work. | ||||||||||||
| 81 | |||||||||||||
| 82 | =cut | ||||||||||||
| 83 | |||||||||||||
| 84 | 5 | ▶ | sub requires_all_of { [ 'Config::TT2' ] } | ||||||||||
|
Subroutine
requires_all_of: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||
| 85 | |||||||||||||
| 86 | =head1 AUTHOR | ||||||||||||
| 87 | |||||||||||||
| 88 | Karl Gaissmaier E<lt>gaissmai@cpan.orgE<gt> | ||||||||||||
| 89 | |||||||||||||
| 90 | =head1 COPYRIGHT AND LICENSE | ||||||||||||
| 91 | |||||||||||||
| 92 | Copyright 2012 by Karl Gaissmaier | ||||||||||||
| 93 | |||||||||||||
| 94 | This library is free software; you can redistribute it and/or modify | ||||||||||||
| 95 | it under the same terms as Perl itself. | ||||||||||||
| 96 | |||||||||||||
| 97 | =head1 SEE ALSO | ||||||||||||
| 98 | |||||||||||||
| 99 | =over 4 | ||||||||||||
| 100 | |||||||||||||
| 101 | =item * L<Config::Any> | ||||||||||||
| 102 | |||||||||||||
| 103 | =item * L<Config::TT2> | ||||||||||||
| 104 | |||||||||||||
| 105 | =back | ||||||||||||
| 106 | |||||||||||||
| 107 | =cut | ||||||||||||
| 108 | |||||||||||||
| 109 | 3 | 1; | |||||||||||