line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Web-Server - configuration handler |
2
|
|
|
|
|
|
|
package PONAPI::Server::ConfigReader; |
3
|
|
|
|
|
|
|
|
4
|
3
|
|
|
3
|
|
2517
|
use Moose; |
|
3
|
|
|
|
|
1415267
|
|
|
3
|
|
|
|
|
33
|
|
5
|
|
|
|
|
|
|
|
6
|
3
|
|
|
3
|
|
21634
|
use Moose::Util::TypeConstraints; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
31
|
|
7
|
3
|
|
|
3
|
|
9222
|
use Path::Class::Dir; |
|
3
|
|
|
|
|
78231
|
|
|
3
|
|
|
|
|
77
|
|
8
|
3
|
|
|
3
|
|
2188
|
use YAML::XS (); |
|
3
|
|
|
|
|
8581
|
|
|
3
|
|
|
|
|
65
|
|
9
|
|
|
|
|
|
|
|
10
|
3
|
|
|
3
|
|
1763
|
use PONAPI::DAO; |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
2094
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
class_type 'Path::Class::Dir'; |
13
|
|
|
|
|
|
|
coerce 'Path::Class::Dir', |
14
|
|
|
|
|
|
|
from 'Str', |
15
|
|
|
|
|
|
|
via { Path::Class::Dir->new($_) }; |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
has dir => ( |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'Path::Class::Dir', |
20
|
|
|
|
|
|
|
coerce => 1, |
21
|
|
|
|
|
|
|
required => 1, |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
has config => ( |
25
|
|
|
|
|
|
|
is => 'ro', |
26
|
|
|
|
|
|
|
isa => 'HashRef', |
27
|
|
|
|
|
|
|
lazy => 1, |
28
|
|
|
|
|
|
|
builder => '_build_conf', |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _build_conf { |
32
|
9
|
|
|
9
|
|
19
|
my $self = shift; |
33
|
9
|
|
|
|
|
340
|
return YAML::XS::Load( scalar $self->dir->file('server.yml')->slurp ); |
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub read_config { |
37
|
9
|
|
|
9
|
0
|
23
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
9
|
|
|
|
|
35
|
$self->_set_server_json_api_version; |
40
|
|
|
|
|
|
|
|
41
|
9
|
|
|
|
|
37
|
$self->_set_server_sorting; |
42
|
9
|
|
|
|
|
34
|
$self->_set_server_send_header; |
43
|
9
|
|
|
|
|
37
|
$self->_set_server_self_link; |
44
|
9
|
|
|
|
|
90
|
$self->_set_server_relative_links; |
45
|
9
|
|
|
|
|
38
|
$self->_set_repository; |
46
|
|
|
|
|
|
|
|
47
|
9
|
|
|
|
|
50
|
$self->{'ponapi.mediatype'} = 'application/vnd.api+json'; |
48
|
|
|
|
|
|
|
|
49
|
9
|
|
|
|
|
17
|
return %{$self}; |
|
9
|
|
|
|
|
107
|
|
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub _set_server_respond_to_updates_status { |
53
|
0
|
|
|
0
|
|
0
|
my $self = shift; |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
$self->{'ponapi.respond_to_updates_with_200'} = |
56
|
0
|
|
|
|
|
0
|
$self->config->{server}{respond_to_updates_with_200}; |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _set_server_sorting { |
60
|
9
|
|
|
9
|
|
20
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my $sort_allowed = $self->config->{server}{sort_allowed} |
63
|
9
|
|
50
|
|
|
347
|
// die "[PONAPI Server] server sorting configuration is missing"; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
$self->{'ponapi.sort_allowed'} = |
66
|
27
|
|
|
|
|
66
|
( grep { $sort_allowed eq $_ } qw< yes true 1 > ) ? 1 : |
67
|
9
|
50
|
|
|
|
26
|
( grep { $sort_allowed eq $_ } qw< no false 0 > ) ? 0 : |
|
27
|
50
|
|
|
|
64
|
|
68
|
|
|
|
|
|
|
die "[PONAPI Server] server sorting is misconfigured"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _set_server_json_api_version { |
72
|
9
|
|
|
9
|
|
18
|
my $self = shift; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
my $spec_version = $self->config->{server}{spec_version} |
75
|
9
|
|
50
|
|
|
409
|
// die "[PONAPI Server] server JSON API version configuration is missing"; |
76
|
|
|
|
|
|
|
|
77
|
9
|
|
|
|
|
28
|
$self->{'ponapi.spec_version'} = $spec_version; |
78
|
|
|
|
|
|
|
} |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
sub _set_server_send_header { |
81
|
9
|
|
|
9
|
|
17
|
my $self = shift; |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
$self->{'ponapi.spec_version'} = $self->config->{server}{spec_version} |
84
|
9
|
|
50
|
|
|
351
|
// die "[PONAPI Server] server spec version is not configured"; |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
$self->{'ponapi.send_version_header'} = |
87
|
9
|
50
|
|
|
|
22
|
( grep { $self->config->{server}{send_version_header} eq $_ } qw< yes true 1 > ) ? 1 : 0; |
|
27
|
|
|
|
|
1060
|
|
88
|
|
|
|
|
|
|
} |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
sub _set_server_self_link { |
91
|
9
|
|
|
9
|
|
20
|
my $self = shift; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
$self->{'ponapi.doc_auto_self_link'} = |
94
|
9
|
50
|
|
|
|
17
|
( grep { $self->config->{server}{send_document_self_link} eq $_ } qw< yes true 1 > ) ? 1 : 0; |
|
27
|
|
|
|
|
1105
|
|
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub _set_server_relative_links { |
98
|
9
|
|
|
9
|
|
19
|
my $self = shift; |
99
|
|
|
|
|
|
|
|
100
|
9
|
50
|
|
|
|
18
|
grep { $self->config->{server}{links_type} eq $_ } qw< relative full > |
|
18
|
|
|
|
|
663
|
|
101
|
|
|
|
|
|
|
or die "[PONAPI Server] server links_type is misconfigured"; |
102
|
|
|
|
|
|
|
|
103
|
9
|
|
|
|
|
398
|
$self->{'ponapi.relative_links'} = $self->config->{server}{links_type}; |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
sub _set_repository { |
107
|
9
|
|
|
9
|
|
19
|
my $self = shift; |
108
|
9
|
|
|
|
|
332
|
$self->{'repository.class'} = $self->config->{repository}{class}; |
109
|
9
|
|
|
|
|
334
|
$self->{'repository.args'} = $self->config->{repository}{args}; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
113
|
3
|
|
|
3
|
|
23
|
no Moose; 1; |
|
3
|
|
|
|
|
9
|
|
|
3
|
|
|
|
|
17
|
|
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
__END__ |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=pod |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=encoding UTF-8 |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
=head1 NAME |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
PONAPI::Server::ConfigReader - Web-Server - configuration handler |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=head1 VERSION |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
version 0.002006 |
128
|
|
|
|
|
|
|
|
129
|
|
|
|
|
|
|
=head1 AUTHORS |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=over 4 |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=item * |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
Mickey Nasriachi <mickey@cpan.org> |
136
|
|
|
|
|
|
|
|
137
|
|
|
|
|
|
|
=item * |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
Stevan Little <stevan@cpan.org> |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
Brian Fraser <hugmeir@cpan.org> |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=back |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
This software is copyright (c) 2016 by Mickey Nasriachi, Stevan Little, Brian Fraser. |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
152
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
=cut |