File Coverage

blib/lib/ExtUtils/Config.pm
Criterion Covered Total %
statement 24 26 92.3
branch 3 4 75.0
condition 2 6 33.3
subroutine 9 10 90.0
pod 6 6 100.0
total 44 52 84.6


line stmt bran cond sub pod time code
1             package ExtUtils::Config;
2             $ExtUtils::Config::VERSION = '0.008';
3 1     1   29354 use strict;
  1         2  
  1         41  
4 1     1   6 use warnings;
  1         1  
  1         34  
5 1     1   15 use Config;
  1         2  
  1         50  
6 1     1   1969 use Data::Dumper ();
  1         11674  
  1         279  
7              
8             sub new {
9 2     2 1 99481 my ($pack, $args) = @_;
10 2 100       21 return bless {
11             values => ($args ? { %$args } : {}),
12             }, $pack;
13             }
14              
15             sub get {
16 3     3 1 4615 my ($self, $key) = @_;
17 3 50       58 return exists $self->{values}{$key} ? $self->{values}{$key} : $Config{$key};
18             }
19              
20             sub exists {
21 2     2 1 9 my ($self, $key) = @_;
22 2   66     953 return exists $self->{values}{$key} || exists $Config{$key};
23             }
24              
25             sub values_set {
26 2     2 1 6762 my $self = shift;
27 2         4 return { %{$self->{values}} };
  2         19  
28             }
29              
30             sub all_config {
31 2     2 1 13321 my $self = shift;
32 2         18 return { %Config, %{ $self->{values}} };
  2         13765  
33             }
34              
35             sub serialize {
36 0     0 1   my $self = shift;
37 0   0       return $self->{serialized} ||= Data::Dumper->new([$self->values_set])->Terse(1)->Sortkeys(1)->Dump;
38             }
39              
40             1;
41              
42             # ABSTRACT: A wrapper for perl's configuration
43              
44             __END__
45              
46             =pod
47              
48             =encoding UTF-8
49              
50             =head1 NAME
51              
52             ExtUtils::Config - A wrapper for perl's configuration
53              
54             =head1 VERSION
55              
56             version 0.008
57              
58             =head1 SYNOPSIS
59              
60             my $config = ExtUtils::Config->new();
61             $config->get('installsitelib');
62              
63             =head1 DESCRIPTION
64              
65             ExtUtils::Config is an abstraction around the %Config hash. By itself it is not a particularly interesting module by any measure, however it ties together a family of modern toolchain modules.
66              
67             =head1 METHODS
68              
69             =head2 new(\%config)
70              
71             Create a new ExtUtils::Config object. The values in C<\%config> are used to initialize the object.
72              
73             =head2 get($key)
74              
75             Get the value of C<$key>. If not overridden it will return the value in %Config.
76              
77             =head2 exists($key)
78              
79             Tests for the existence of $key.
80              
81             =head2 values_set()
82              
83             Get a hashref of all overridden values.
84              
85             =head2 all_config()
86              
87             Get a hashref of the complete configuration, including overrides.
88              
89             =head2 serialize()
90              
91             This method serializes the object to some kind of string.
92              
93             =head1 AUTHORS
94              
95             =over 4
96              
97             =item *
98              
99             Ken Williams <kwilliams@cpan.org>
100              
101             =item *
102              
103             Leon Timmermans <leont@cpan.org>
104              
105             =back
106              
107             =head1 COPYRIGHT AND LICENSE
108              
109             This software is copyright (c) 2006 by Ken Williams, Leon Timmermans.
110              
111             This is free software; you can redistribute it and/or modify it under
112             the same terms as the Perl 5 programming language system itself.
113              
114             =cut