Nile/Module.pm

filter: Statementstmt 86.6% 39 / 45 Branchbran 62.5% 5 / 8 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 1 totaltotal 76.4% 52 / 68 CC 6 SCAR 14.4
CC
6
Cov
79%
setting
12.0
import
4.0
BEGIN
1.0
CRAP 4.2
« Nile/Filter.pm ↑ Summary Nile/Plugin/Elasticsearch.pm »
1 # Copyright Infomation
2 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
3 # Author : Dr. Ahmed Amin Elsheshtawy, Ph.D.
4 # Website: https://github.com/mewsoft/Nile, http://www.mewsoft.com
5 # Email : mewsoft@cpan.org, support@mewsoft.com
6 # Copyrights (c) 2014-2015 Mewsoft Corp. All rights reserved.
7 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8 package Nile::Module;
9  
10 1 our $VERSION = '0.55';
11 1 our $AUTHORITY = 'cpan:MEWSOFT';
12  
13 =pod
14  
15 =encoding utf8
16  
17 =head1 NAME
18  
19 Nile::Module - Module base class for the Nile framework.
20  
21 =head1 SYNOPSIS
22  
23 package Nile::Module::Home::Home;
24  
25 use Nile::Module; # automatically extends Nile::Module
26
27 =head1 DESCRIPTION
28  
29 Nile::Module - Module base class for the Nile framework.
30  
31 =cut
32  
33 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
34 1 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
35 1 ▶use Moose;
Subroutine BEGIN: called CC=1 SCAR=0.0
36 1 ▶use Nile::Say;
Subroutine BEGIN: called CC=1 SCAR=0.0
37  
38 1 ▶use Import::Into;
Subroutine BEGIN: called CC=1 SCAR=0.0
39 1 ▶use Module::Runtime qw(use_module);
Subroutine BEGIN: called CC=1 SCAR=0.0
40 1 ▶use MooseX::MethodAttributes;
Subroutine BEGIN: called CC=1 SCAR=0.0
41  
42 1 our @EXPORT_MODULES = (
43 Moose => [],
44 utf8 => [],
45 'Nile::Say' => [],
46 'MooseX::MethodAttributes' => [],
47 );
48 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
49 3 ▶sub import {
Subroutine import: called CC=4 SCAR=13.9
50  
51 3 my ($class, @args) = @_;
52  
53 3 my ($caller, $script) = caller;
54  
55 3 my $package = __PACKAGE__;
56
57 # ignore calling from child import
58 3 ▶ return if ($class ne $package);
Branch: 1 branch
BranchTrueFalseTotal
if $class ne $package 1 2 3
59  
60 2 my @modules = @EXPORT_MODULES;
61  
62 2 ▶ while (@modules) {
Branch: 1 branch
BranchTrueFalseTotal
if (@modules) 8 2 10
63 8 my $module = shift @modules;
64 8 ▶ my $imports = ref($modules[0]) eq 'ARRAY' ? shift @modules : [];
Branch: 1 branch
BranchTrueFalseTotal
ref $modules[0] eq 'ARRAY' ? : 8 0 8
65 8 use_module($module)->import::into($caller, @{$imports});
66 }
67  
68 {
69 1 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
70 2 @{"${caller}::ISA"} = ($package, @{"${caller}::ISA"});
71 }
72  
73 }
74 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
75 =head2 setting()
76
77 # inside modules, return current modules config settings
78 my $setting = $self->setting();
79 my %setting = $self->setting();
80  
81 # inside modules, return specific modules config settings
82 my $setting = $self->setting("payment");
83 my %setting = $self->setting("payment");
84  
85 Returns module settings from configuration files loaded.
86 Module settings in config files must be in inside the module tag. The module name must be lower case tag, so module C<Payment> should be C<payment>.
87  
88 Exampler settings for C<payment> module below:
89  
90 <module>
91 <payment>
92 <url>localhost</url>
93 <user>merchant</user>
94 <pass>1234</pass>
95 </payment>
96 </module>
97  
98 =cut
99  
100 0 ▶sub setting {
Subroutine setting: not called CC=3 SCAR=24.8
Pod undocumented
101 0 my ($self, $module) = @_;
102  
103 0 ▶ $module ||= caller();
Condition0%0/3
$module ||= caller()
l!l&&r!l&&!r
000
MC/DC0%0/2
$module ||= caller()
$module caller()
Truth table0%0/3
A ||= B
A= $moduleB= caller()
ABresult
1X1
011
000
104 0 $module =~ s/^(.*):://;
105 0 $module = lc($module);
106  
107 0 ▶ return wantarray ? %{ $self->app->config->var->{module}->{$module} } : $self->app->config->var->{module}->{$module};
Branch: 1 branch
BranchTrueFalseTotal
wantarray ? : 0 0 0
108 }
109 #~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
110  
111 =pod
112  
113 =head1 Bugs
114  
115 This project is available on github at L<https://github.com/mewsoft/Nile>.
116  
117 =head1 HOMEPAGE
118  
119 Please visit the project's homepage at L<https://metacpan.org/release/Nile>.
120  
121 =head1 SOURCE
122  
123 Source repository is at L<https://github.com/mewsoft/Nile>.
124  
125 =head1 SEE ALSO
126  
127 See L<Nile> for details about the complete framework.
128  
129 =head1 AUTHOR
130  
131 Ahmed Amin Elsheshtawy, احمد امين الششتاوى <mewsoft@cpan.org>
132 Website: http://www.mewsoft.com
133  
134 =head1 COPYRIGHT AND LICENSE
135  
136 Copyright (C) 2014-2015 by Dr. Ahmed Amin Elsheshtawy احمد امين الششتاوى mewsoft@cpan.org, support@mewsoft.com,
137 L<https://github.com/mewsoft/Nile>, L<http://www.mewsoft.com>
138  
139 This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
140  
141 =cut
142  
143 1 1;
« Nile/Filter.pm ↑ Summary Nile/Plugin/Elasticsearch.pm »