line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Pg::CLI::pg_config; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
106875
|
use strict; |
|
1
|
|
|
|
|
14
|
|
|
1
|
|
|
|
|
52
|
|
4
|
1
|
|
|
1
|
|
18
|
use warnings; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
45
|
|
5
|
1
|
|
|
1
|
|
469
|
use namespace::autoclean; |
|
1
|
|
|
|
|
20038
|
|
|
1
|
|
|
|
|
4
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
our $VERSION = '0.14'; |
8
|
|
|
|
|
|
|
|
9
|
1
|
|
|
1
|
|
495
|
use MooseX::Types::Moose qw( HashRef Maybe Str ); |
|
1
|
|
|
|
|
520811
|
|
|
1
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
|
11
|
1
|
|
|
1
|
|
5710
|
use Moose; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
9
|
|
12
|
1
|
|
|
1
|
|
8145
|
use MooseX::SemiAffordanceAccessor; |
|
1
|
|
|
|
|
13224
|
|
|
1
|
|
|
|
|
5
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
with 'Pg::CLI::Role::Executable'; |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has _config_info => ( |
17
|
|
|
|
|
|
|
is => 'ro', |
18
|
|
|
|
|
|
|
isa => HashRef [ Maybe [Str] ], |
19
|
|
|
|
|
|
|
init_arg => undef, |
20
|
|
|
|
|
|
|
lazy => 1, |
21
|
|
|
|
|
|
|
builder => '_build_config_info', |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
my @attrs = qw( |
25
|
|
|
|
|
|
|
bindir |
26
|
|
|
|
|
|
|
cc |
27
|
|
|
|
|
|
|
cflags |
28
|
|
|
|
|
|
|
cflags_sl |
29
|
|
|
|
|
|
|
configure |
30
|
|
|
|
|
|
|
cppflags |
31
|
|
|
|
|
|
|
docdir |
32
|
|
|
|
|
|
|
htmldir |
33
|
|
|
|
|
|
|
includedir |
34
|
|
|
|
|
|
|
includedir_server |
35
|
|
|
|
|
|
|
ldflags |
36
|
|
|
|
|
|
|
ldflags_sl |
37
|
|
|
|
|
|
|
libdir |
38
|
|
|
|
|
|
|
libs |
39
|
|
|
|
|
|
|
localedir |
40
|
|
|
|
|
|
|
mandir |
41
|
|
|
|
|
|
|
pgxs |
42
|
|
|
|
|
|
|
pkgincludedir |
43
|
|
|
|
|
|
|
pkglibdir |
44
|
|
|
|
|
|
|
sharedir |
45
|
|
|
|
|
|
|
sysconfdir |
46
|
|
|
|
|
|
|
version |
47
|
|
|
|
|
|
|
); |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
for my $attr (@attrs) { |
50
|
|
|
|
|
|
|
has $attr => ( |
51
|
|
|
|
|
|
|
is => 'ro', |
52
|
|
|
|
|
|
|
isa => Maybe [Str], |
53
|
|
|
|
|
|
|
init_arg => undef, |
54
|
|
|
|
|
|
|
lazy => 1, |
55
|
|
|
|
|
|
|
default => sub { $_[0]->_config_info()->{$attr} }, |
56
|
|
|
|
|
|
|
); |
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
sub _build_config_info { |
60
|
1
|
|
|
1
|
|
3
|
my $self = shift; |
61
|
|
|
|
|
|
|
|
62
|
1
|
|
|
|
|
2
|
my %info; |
63
|
1
|
|
|
|
|
4
|
for my $line ( $self->_pg_config_output() ) { |
64
|
22
|
|
|
|
|
44
|
chomp $line; |
65
|
22
|
|
|
|
|
49
|
my ( $key, $val ) = split / = /, $line, 2; |
66
|
|
|
|
|
|
|
|
67
|
22
|
|
|
|
|
34
|
$key =~ s/-/_/; |
68
|
|
|
|
|
|
|
|
69
|
22
|
100
|
|
|
|
72
|
$info{ lc $key } = $val =~ /\S/ ? $val : undef; |
70
|
|
|
|
|
|
|
} |
71
|
|
|
|
|
|
|
|
72
|
1
|
|
|
|
|
31
|
return \%info; |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
# Separate method so it can be overridden for tests |
76
|
|
|
|
|
|
|
sub _pg_config_output { |
77
|
0
|
|
|
0
|
|
|
my $self = shift; |
78
|
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
my $command = $self->executable(); |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
## no critic (InputOutput::ProhibitBacktickOperators) |
82
|
0
|
|
|
|
|
|
return `$command`; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
__PACKAGE__->meta()->make_immutable(); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
1; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# ABSTRACT: Wrapper for the F<psql> utility |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
__END__ |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=pod |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
=encoding UTF-8 |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 NAME |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Pg::CLI::pg_config - Wrapper for the F<psql> utility |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=head1 VERSION |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
version 0.14 |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
=head1 SYNOPSIS |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
my $pg_config = Pg::CLI::pg_config->new(); |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
print $pg_config()->sharedir(); |
110
|
|
|
|
|
|
|
print $pg_config()->version(); |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=head1 DESCRIPTION |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
This class provides a wrapper for the F<pg_config> utility. |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=head1 METHODS |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
This class provides the following methods: |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=head2 Pg::CLI::pg_config->new() |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
The constructor accepts one parameter: |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * executable |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
The path to F<pg_config>. By default, this will look for F<pg_config> in your |
129
|
|
|
|
|
|
|
path and throw an error if it cannot be found. |
130
|
|
|
|
|
|
|
|
131
|
|
|
|
|
|
|
=back |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=head2 Config Info Methods |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
This class provides the following methods, each of which returns the relevant |
136
|
|
|
|
|
|
|
configuration info. If there was no value for the item, the method returns |
137
|
|
|
|
|
|
|
C<undef>. |
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
=over 4 |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=item * $pg_config->bindir() |
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
=item * $pg_config->cc() |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=item * $pg_config->cflags() |
146
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
=item * $pg_config->cflags_sl() |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=item * $pg_config->configure() |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
=item * $pg_config->cppflags() |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=item * $pg_config->docdir() |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
=item * $pg_config->htmldir() |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=item * $pg_config->includedir() |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=item * $pg_config->includedir_server() |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=item * $pg_config->ldflags() |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=item * $pg_config->ldflags_sl() |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=item * $pg_config->libdir() |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
=item * $pg_config->libs() |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=item * $pg_config->localedir() |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
=item * $pg_config->mandir() |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=item * $pg_config->pgxs() |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
=item * $pg_config->pkgincludedir() |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=item * $pg_config->pkglibdir() |
178
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
=item * $pg_config->sharedir() |
180
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=item * $pg_config->sysconfdir() |
182
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
=item * $pg_config->version() |
184
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=back |
186
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
=head1 SUPPORT |
188
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
Bugs may be submitted at L<http://rt.cpan.org/Public/Dist/Display.html?Name=Pg-CLI> or via email to L<bug-pg-cli@rt.cpan.org|mailto:bug-pg-cli@rt.cpan.org>. |
190
|
|
|
|
|
|
|
|
191
|
|
|
|
|
|
|
I am also usually active on IRC as 'autarch' on C<irc://irc.perl.org>. |
192
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 SOURCE |
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
The source code repository for Pg-CLI can be found at L<https://github.com/houseabsolute/Pg-CLI>. |
196
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 AUTHOR |
198
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Dave Rolsky <autarch@urth.org> |
200
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
202
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
This software is Copyright (c) 2018 by Dave Rolsky. |
204
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
This is free software, licensed under: |
206
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
The Artistic License 2.0 (GPL Compatible) |
208
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
The full text of the license can be found in the |
210
|
|
|
|
|
|
|
F<LICENSE> file included with this distribution. |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
=cut |