File Coverage

blib/lib/ExtUtils/Config.pm
Criterion Covered Total %
statement 29 32 90.6
branch 5 6 83.3
condition 1 6 16.6
subroutine 9 10 90.0
pod 7 7 100.0
total 51 61 83.6


line stmt bran cond sub pod time code
1             package ExtUtils::Config;
2             $ExtUtils::Config::VERSION = '0.010';
3 2     2   275675 use strict;
  2         4  
  2         75  
4 2     2   11 use warnings;
  2         8  
  2         122  
5 2     2   58 use Config;
  2         4  
  2         995  
6              
7             sub new {
8 3     3 1 157993 my ($pack, $args) = @_;
9 3 100       36 return bless {
10             values => ($args ? { %$args } : {}),
11             }, $pack;
12             }
13              
14             sub get {
15 3     3 1 48 my ($self, $key) = @_;
16 3 50       134 return exists $self->{values}{$key} ? $self->{values}{$key} : $Config{$key};
17             }
18              
19             sub exists {
20 2     2 1 13 my ($self, $key) = @_;
21 2   33     75 return exists $self->{values}{$key} || exists $Config{$key};
22             }
23              
24             sub values_set {
25 4     4 1 12515 my $self = shift;
26 4         10 return { %{$self->{values}} };
  4         46  
27             }
28              
29             sub all_config {
30 4     4 1 12 my $self = shift;
31 4         12465 return { %Config, %{ $self->{values}} };
  4         13741  
32             }
33              
34             sub serialize {
35 0     0 1 0 my $self = shift;
36 0         0 require Data::Dumper;
37 0   0     0 return $self->{serialized} ||= Data::Dumper->new([ $self->{values} ])->Terse(1)->Sortkeys(1)->Dump;
38             }
39              
40             sub but {
41 1     1 1 6 my ($self, $args) = @_;
42 1         245 my %new = %{ $self->{values} };
  1         10  
43 1         6 for my $key (keys %$args) {
44 2 100       7 if (defined $args->{$key}) {
45 1         3 $new{$key} = $args->{$key}
46             }
47             else {
48 1         11 delete $new{$key};
49             }
50             }
51 1         11 return bless { values => \%new }, ref $self;
52             }
53              
54             1;
55              
56             # ABSTRACT: A wrapper for perl's configuration
57              
58             __END__