blib/lib/DBIx/Changeset/App.pm

filter: Statementstmt 97.5% 40 / 41 Branchbran 66.6% 4 / 6 Conditioncond 60.0% 3 / 5 MC/DCmcdc 33.3% 1 / 3 Subroutinesub 90.0% 9 / 10 Podpod 100% 2 / 2 totaltotal 88.0% 59 / 67 CC 7 SCAR 13.2
CC
7
Cov
90%
config
7.1
default_plugin
2.0
BEGIN
1.0
CRAP 3.8
« blib/lib/DBIx/Changeset/History.pm ↑ Summary blib/lib/DBIx/Changeset.pm »
1 package DBIx::Changeset::App;
2  
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 3 ▶use base qw/App::Cmd/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 3 ▶use YAML 'LoadFile';
Subroutine BEGIN: called CC=1 SCAR=0.0
8 3 ▶use Path::Class 'file';
Subroutine BEGIN: called CC=1 SCAR=0.0
9 3 ▶use Hash::Merge qw( merge );
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 3 ▶use vars qw{$VERSION};
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 $VERSION = '1.11';
14 }
15  
16 =head1 NAME
17  
18 DBIx::Changeset::App - Main App File to the command line app
19  
20 =head1 SYNOPSIS
21  
22 Main App File to the command line app
23  
24 create a script like so:
25  
26 #!/usr/bin/env perl
27 use DBIx::Changeset::App;
28  
29 my $cmd = DBIx::Changeset::App->new();
30 $cmd->config('config.yml');
31 $cmd->run;
32  
33  
34 =head1 METHODS
35  
36 =head2 config
37  
38 Load Given YAML files as config
39 expects a YAML File with following format
40  
41 globaloption: <value>
42 command:
43 commandoption: <value>
44  
45 =cut
46 4 ▶sub config {
Subroutine config: called CC=7 SCAR=19.7
Pod documented
47 4 my ($app,$config) = @_;
48  
49 4 $app->{'config'} = {};
50 4 Hash::Merge::set_behavior( 'RIGHT_PRECEDENT' );
51
52 4 my @config_files;
53 4 ▶ if ( defined $config && ref $config eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $config and ref $config eq 'ARRAY') { } 3 1 4
Condition66%2/3
defined $config and ref $config eq "ARRAY"
!ll&&!rl&&r
013
MC/DC50%1/2
defined $config and ref $config eq "ARRAY"
defined $config ref $config eq "ARRAY"
Truth table66%2/3
A and B
A= defined $configB= ref $config eq "ARRAY"
ABresult
0X0
100
111
54 3 @config_files = @{$config};
55 } else {
56 1 ▶ my $config_file = $config || 'config.yml';
Condition50%1/2
$config || 'config.yml'
l!l
10
MC/DC0%0/1
$config || 'config.yml'
$config
Truth table50%1/2
A
A= $config
Aresult
11
00
57 1 push @config_files, $config_file;
58 }
59 4 foreach my $config_file ( @config_files ) {
60 6 ▶ $config_file = file('.', $config_file) unless file($config_file)->is_absolute;
Branch: 1 branch
BranchTrueFalseTotal
unless file($config_file)->is_absolute 6 0 6
61 6 ▶ next unless -e $config_file;
Branch: 1 branch
BranchTrueFalseTotal
unless -e $config_file 0 6 6
62 6 my $conf = LoadFile($config_file);
63 6 %{$app->{'config'}} = %{ merge( $app->{'config'}, $conf ) };
64 }
65 4 return;
66 }
67  
68 =head2 default_plugin
69  
70 Called by App::Cmd to set the default command when none is given this should automatically be
71 'help' with documented default_command method but doest work so must be a bug in App::Cmd..
72  
73 =cut
74  
75 0 ▶sub default_plugin {
Subroutine default_plugin: not called CC=1 SCAR=6.9
Pod documented
76 0 return 'help';
77 }
78  
79 =head1 COPYRIGHT & LICENSE
80  
81 Copyright 2004-2008 Grox Pty Ltd.
82  
83 This program is free software; you can redistribute it and/or modify it
84 under the same terms as Perl itself.
85  
86 The full text of the license can be found in the LICENSE file included with this module.
87  
88 =cut
89  
90 3 1; # End of DBIx::Changeset
« blib/lib/DBIx/Changeset/History.pm ↑ Summary blib/lib/DBIx/Changeset.pm »