File Coverage

blib/lib/CPAN/Reporter/Smoker/OpenBSD/PerlConfig.pm
Criterion Covered Total %
statement 28 30 93.3
branch 2 4 50.0
condition n/a
subroutine 6 6 100.0
pod 2 2 100.0
total 38 42 90.4


line stmt bran cond sub pod time code
1             package CPAN::Reporter::Smoker::OpenBSD::PerlConfig;
2              
3 1     1   973 use strict;
  1         2  
  1         50  
4 1     1   12 use warnings;
  1         6  
  1         43  
5 1     1   22 use Config;
  1         5  
  1         56  
6 1     1   504 use Hash::Util qw(lock_hash);
  1         3495  
  1         7  
7              
8             our $VERSION = '0.021'; # 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 875 my $class = shift;
42             my $self = {
43             osname => $Config{osname},
44             archname => $Config{archname}
45 1         7 };
46 1         4 my $attrib_name = 'useithreads';
47              
48 1 50       6 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         5  
57 1         25 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 6 my $self = shift;
70 1         1 my %attribs = %{$self};
  1         4  
71 1         3 my $attrib_name = 'useithreads';
72              
73 1 50       2 if ( $self->{$attrib_name} ) {
74 0         0 $attribs{$attrib_name} = 'define';
75             }
76             else {
77 1         3 $attribs{$attrib_name} = '^$';
78             }
79              
80 1         4 return \%attribs;
81             }
82              
83             =head1 SEE ALSO
84              
85             =over
86              
87             =item *
88              
89             L
90              
91             =back
92              
93             =head1 AUTHOR
94              
95             Alceu Rodrigues de Freitas Junior, Earfreitas@cpan.orgE
96              
97             =head1 COPYRIGHT AND LICENSE
98              
99             This software is copyright (c) 2017 of Alceu Rodrigues de Freitas Junior, arfreitas@cpan.org
100              
101             This file is part of CPAN OpenBSD Smoker.
102              
103             CPAN OpenBSD Smoker is free software: you can redistribute it and/or modify
104             it under the terms of the GNU General Public License as published by
105             the Free Software Foundation, either version 3 of the License, or
106             (at your option) any later version.
107              
108             CPAN OpenBSD Smoker is distributed in the hope that it will be useful,
109             but WITHOUT ANY WARRANTY; without even the implied warranty of
110             MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
111             GNU General Public License for more details.
112              
113             You should have received a copy of the GNU General Public License
114             along with CPAN OpenBSD Smoker. If not, see .
115              
116             =cut
117              
118             1;