File Coverage

blib/lib/CPAN/Reporter/Smoker/OpenBSD/PerlConfig.pm
Criterion Covered Total %
statement 29 31 93.5
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 39 43 90.7


line stmt bran cond sub pod time code
1             package CPAN::Reporter::Smoker::OpenBSD::PerlConfig;
2              
3 1     1   1378 use strict;
  1         2  
  1         50  
4 1     1   9 use warnings;
  1         8  
  1         55  
5 1     1   28 use Config;
  1         3  
  1         77  
6 1     1   1339 use Hash::Util qw(lock_hash);
  1         4374  
  1         8  
7              
8             our $VERSION = '0.019'; # VERSION
9              
10             =pod
11              
12             =head1 NAME
13              
14             CPAN::Reporter::Smoker::OpenBSD::PerlConfig - class representing perl configuration
15              
16             =head1 SYNOPSIS
17              
18             use CPAN::Reporter::Smoker::OpenBSD::PerlConfig;
19              
20             my $cfg = CPAN::Reporter::Smoker::OpenBSD::PerlConfig->new;
21              
22             =head1 DESCRIPTION
23              
24             This class represents a C configuration in a way that can be used by the
25             C CLI.
26              
27             It was created to handle the details of a distroprefs implementation, specially
28             regarding dealing with C values.
29              
30             =head1 METHODS
31              
32             =head2 new
33              
34             Creates a new instance of this class.
35              
36             Expects nothing, returns a new instance.
37              
38             =cut
39              
40             sub new {
41 1     1 1 1018 my $class = shift;
42             my $self = {
43             osname => $Config{osname},
44             archname => $Config{archname}
45 1         8 };
46 1         3 my $attrib_name = 'useithreads';
47              
48 1 50       5 if ( defined( $Config{$attrib_name} ) ) {
49 0         0 $self->{$attrib_name} = 1;
50             }
51             else {
52 1         2 $self->{$attrib_name} = 0;
53             }
54              
55 1         3 bless $self, $class;
56 1         2 lock_hash( %{$self} );
  1         7  
57 1         27 return $self;
58             }
59              
60             =head2 dump
61              
62             This methods returns a instance attributes as a hash reference.
63              
64             This is particulary useful to use with YAML modules C function.
65              
66             =cut
67              
68             sub dump {
69 1     1 1 5 my $self = shift;
70 1         2 my %attribs = %{$self};
  1         4  
71 1         3 my $attrib_name = 'useithreads';
72              
73 1 50       3 if ( $self->{$attrib_name} ) {
74 0         0 $attribs{$attrib_name} = 'define';
75             }
76             else {
77 1         3 delete( $attribs{$attrib_name} );
78 1         3 $attribs{"no_$attrib_name"} = 'define';
79             }
80              
81 1         4 return \%attribs;
82             }
83              
84             =head1 SEE ALSO
85              
86             =over
87              
88             =item *
89              
90             L
91              
92             =back
93              
94             =head1 AUTHOR
95              
96             Alceu Rodrigues de Freitas Junior, Earfreitas@cpan.orgE
97              
98             =head1 COPYRIGHT AND LICENSE
99              
100             This software is copyright (c) 2017 of Alceu Rodrigues de Freitas Junior, arfreitas@cpan.org
101              
102             This file is part of CPAN OpenBSD Smoker.
103              
104             CPAN OpenBSD Smoker is free software: you can redistribute it and/or modify
105             it under the terms of the GNU General Public License as published by
106             the Free Software Foundation, either version 3 of the License, or
107             (at your option) any later version.
108              
109             CPAN OpenBSD Smoker is distributed in the hope that it will be useful,
110             but WITHOUT ANY WARRANTY; without even the implied warranty of
111             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
112             GNU General Public License for more details.
113              
114             You should have received a copy of the GNU General Public License
115             along with CPAN OpenBSD Smoker. If not, see .
116              
117             =cut
118              
119             1;