File Coverage

blib/lib/Data/Context/Actions.pm
Criterion Covered Total %
statement 33 35 94.2
branch 3 6 50.0
condition n/a
subroutine 10 10 100.0
pod 1 1 100.0
total 47 52 90.3


line stmt bran cond sub pod time code
1             package Data::Context::Actions;
2              
3             # Created on: 2012-04-13 09:54:58
4             # Create by: Ivan Wills
5             # $Id$
6             # $Revision$, $HeadURL$, $Date$
7             # $Revision$, $Source$, $Date$
8              
9 7     7   73779 use Moose;
  7         607376  
  7         56  
10 7     7   41859 use warnings;
  7         15  
  7         251  
11 7     7   814 use version;
  7         2198  
  7         57  
12 7     7   576 use Carp;
  7         14  
  7         547  
13 7     7   41 use Scalar::Util;
  7         12  
  7         284  
14 7     7   35 use List::Util;
  7         12  
  7         410  
15 7     7   827 use Data::Dumper qw/Dumper/;
  7         6202  
  7         507  
16 7     7   897 use English qw/ -no_match_vars /;
  7         2388  
  7         58  
17 7     7   4029 use Data::Context::Util qw/lol_path lol_iterate/;
  7         14  
  7         2041  
18              
19             our $VERSION = version->new('0.1.8');
20              
21             sub expand_vars {
22 24     24 1 1062 my ( $self, $value, $vars, $path, $dci ) = @_;
23              
24 24 100       79 if ( ref $value eq 'HASH' ) {
25 13 50       45 if ( !exists $value->{value} ) {
26 0 0       0 $dci->dc->log->warn( "expand_vars called as a hash but without a value in ".$dci->path." at $path" ) if $dci;
27 0         0 return;
28             }
29 13         33 $value = $value->{value} ;
30             }
31              
32             # remove #'s
33 24         141 $value =~ s/^[#] | [#]$//gxms;
34              
35 24         78 return Data::Context::Util::lol_path( $vars, $value );
36             }
37              
38             1;
39              
40             __END__
41              
42             =head1 NAME
43              
44             Data::Context::Actions - Contains all the default actions available to a config
45              
46             =head1 VERSION
47              
48             This documentation refers to Data::Context::Actions version 0.1.8.
49             =head1 SYNOPSIS
50              
51             use Data::Context::Actions;
52              
53             # expand variables
54             my $expanded = Data::Context::Actions->expand_var( '#path.to.item#', undef, 'path.in.config', {...} );
55              
56             =head1 DESCRIPTION
57              
58             =head1 SUBROUTINES/METHODS
59              
60             =head2 C<expand_vars ( $value, $dc, $path, $vars )>
61              
62             Expands C<$value> in C<$vars>
63              
64             =head1 DIAGNOSTICS
65              
66             =head1 CONFIGURATION AND ENVIRONMENT
67              
68             =head1 DEPENDENCIES
69              
70             =head1 INCOMPATIBILITIES
71              
72             =head1 BUGS AND LIMITATIONS
73              
74             There are no known bugs in this module.
75              
76             Please report problems to Ivan Wills (ivan.wills@gmail.com).
77              
78             Patches are welcome.
79              
80             =head1 AUTHOR
81              
82             Ivan Wills - (ivan.wills@gmail.com)
83              
84             =head1 LICENSE AND COPYRIGHT
85              
86             Copyright (c) 2012 Ivan Wills (14 Mullion Close, Hornsby Heights, NSW Australia 2077).
87             All rights reserved.
88              
89             This module is free software; you can redistribute it and/or modify it under
90             the same terms as Perl itself. See L<perlartistic>. This program is
91             distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
92             without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
93             PARTICULAR PURPOSE.
94              
95             =cut