line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
|
|
|
|
our $VERSION = '0.54'; |
11
|
|
|
|
|
|
|
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
|
|
|
1
|
|
4
|
use utf8; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
35
|
1
|
|
|
1
|
|
29
|
use Moose; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
6
|
|
36
|
1
|
|
|
1
|
|
5155
|
use Nile::Say; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
37
|
|
|
|
|
|
|
|
38
|
1
|
|
|
1
|
|
5
|
use Import::Into; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
22
|
|
39
|
1
|
|
|
1
|
|
4
|
use Module::Runtime qw(use_module); |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
7
|
|
40
|
1
|
|
|
1
|
|
42
|
use MooseX::MethodAttributes; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
8
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
our @EXPORT_MODULES = ( |
43
|
|
|
|
|
|
|
Moose => [], |
44
|
|
|
|
|
|
|
utf8 => [], |
45
|
|
|
|
|
|
|
'Nile::Say' => [], |
46
|
|
|
|
|
|
|
'MooseX::MethodAttributes' => [], |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
49
|
|
|
|
|
|
|
sub import { |
50
|
|
|
|
|
|
|
|
51
|
3
|
|
|
3
|
|
7
|
my ($class, @args) = @_; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
10
|
my ($caller, $script) = caller; |
54
|
|
|
|
|
|
|
|
55
|
3
|
|
|
|
|
3
|
my $package = __PACKAGE__; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
# ignore calling from child import |
58
|
3
|
100
|
|
|
|
44
|
return if ($class ne $package); |
59
|
|
|
|
|
|
|
|
60
|
2
|
|
|
|
|
7
|
my @modules = @EXPORT_MODULES; |
61
|
|
|
|
|
|
|
|
62
|
2
|
|
|
|
|
5
|
while (@modules) { |
63
|
8
|
|
|
|
|
3555
|
my $module = shift @modules; |
64
|
8
|
50
|
|
|
|
22
|
my $imports = ref($modules[0]) eq 'ARRAY' ? shift @modules : []; |
65
|
8
|
|
|
|
|
26
|
use_module($module)->import::into($caller, @{$imports}); |
|
8
|
|
|
|
|
206
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
{ |
69
|
1
|
|
|
1
|
|
6314
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
193
|
|
|
2
|
|
|
|
|
4685
|
|
70
|
2
|
|
|
|
|
4
|
@{"${caller}::ISA"} = ($package, @{"${caller}::ISA"}); |
|
2
|
|
|
|
|
103
|
|
|
2
|
|
|
|
|
6
|
|
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
|
|
|
|
|
|
|
sub setting { |
101
|
0
|
|
|
0
|
0
|
|
my ($self, $module) = @_; |
102
|
|
|
|
|
|
|
|
103
|
0
|
|
0
|
|
|
|
$module ||= caller(); |
104
|
0
|
|
|
|
|
|
$module =~ s/^(.*):://; |
105
|
0
|
|
|
|
|
|
$module = lc($module); |
106
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
return wantarray ? %{ $self->app->config->var->{module}->{$module} } : $self->app->config->var->{module}->{$module}; |
|
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; |