| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Labyrinth::Paths; |
|
2
|
|
|
|
|
|
|
|
|
3
|
5
|
|
|
5
|
|
71272
|
use warnings; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
156
|
|
|
4
|
5
|
|
|
5
|
|
15
|
use strict; |
|
|
5
|
|
|
|
|
6
|
|
|
|
5
|
|
|
|
|
180
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
our $VERSION = '0.01'; |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
# ------------------------------------- |
|
9
|
|
|
|
|
|
|
# Library Modules |
|
10
|
|
|
|
|
|
|
|
|
11
|
5
|
|
|
5
|
|
1815
|
use IO::File; |
|
|
5
|
|
|
|
|
27738
|
|
|
|
5
|
|
|
|
|
491
|
|
|
12
|
5
|
|
|
5
|
|
2508
|
use JSON::XS; |
|
|
5
|
|
|
|
|
23854
|
|
|
|
5
|
|
|
|
|
305
|
|
|
13
|
5
|
|
|
5
|
|
3288
|
use Labyrinth; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
use Labyrinth::Variables; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
# ------------------------------------- |
|
17
|
|
|
|
|
|
|
# The Subs |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=head1 FUNCTIONS |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 Constructor |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=over 4 |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=item new() |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
Create a new path object. |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=back |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=cut |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub new { |
|
34
|
|
|
|
|
|
|
my ($class,$pathfile) = @_; |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
# create an attributes hash |
|
37
|
|
|
|
|
|
|
my $atts = { |
|
38
|
|
|
|
|
|
|
pathfile => $pathfile || $settings{pathfile} || './pathfile.json' |
|
39
|
|
|
|
|
|
|
}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
# create the object |
|
42
|
|
|
|
|
|
|
bless $atts, $class; |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
$atts->load; |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
return $atts; |
|
47
|
|
|
|
|
|
|
}; |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=head2 Methods |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=head3 Handling Actions |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=over 4 |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item load( [$file] ) |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
Load the given path file, which can be the default, or specified as a parameter. |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
=item parse() |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
Parse the current path and reset cgiparams and settings values as appropriate. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=back |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub load { |
|
68
|
|
|
|
|
|
|
my $self = shift; |
|
69
|
|
|
|
|
|
|
my $file = shift; |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
if($file) { |
|
72
|
|
|
|
|
|
|
return unless(-f $file); |
|
73
|
|
|
|
|
|
|
$self->{pathfile} = $file; |
|
74
|
|
|
|
|
|
|
} else { |
|
75
|
|
|
|
|
|
|
return unless(-f $self->{pathfile}); |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
my $fh = IO::File->new($self->{pathfile},'r') or return; |
|
79
|
|
|
|
|
|
|
local $/ = undef; |
|
80
|
|
|
|
|
|
|
my $json = <$fh>; |
|
81
|
|
|
|
|
|
|
$fh->close; |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
eval { |
|
84
|
|
|
|
|
|
|
my $data = decode_json($json); |
|
85
|
|
|
|
|
|
|
$self->{data} = $data->{paths}; |
|
86
|
|
|
|
|
|
|
}; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
return; |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
sub parse { |
|
92
|
|
|
|
|
|
|
my $self = shift; |
|
93
|
|
|
|
|
|
|
my $path = $ENV{SCRIPT_URL} || $ENV{SCRIPT_NAME}; |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
for my $data (@{$self->{data}}) { |
|
96
|
|
|
|
|
|
|
if($path =~ /$data->{path}/) { |
|
97
|
|
|
|
|
|
|
my @vars = ($1,$2,$3,$4,$5,$6,$7,$8,$9); |
|
98
|
|
|
|
|
|
|
while($data->{variables} && @{$data->{variables} && @vars}) { |
|
99
|
|
|
|
|
|
|
my $name = shift $data->{variables}; |
|
100
|
|
|
|
|
|
|
$cgiparams{$name} = shift @vars; |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
$cgiparams{$_} = $self->{cgiparams}{$_} for(keys %{$self->{cgiparams}}); |
|
104
|
|
|
|
|
|
|
$settings{$_} = $self->{settings}{$_} for(keys %{$self->{settings}}); |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
return; |
|
107
|
|
|
|
|
|
|
} |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
} |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
1; |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
__END__ |