blib/lib/Devel/AssertOS.pm

filter: Statementstmt 100% 21 / 21 Branchbran 100% 8 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 100% 33 / 33 CC 6 SCAR 14.7
CC
6
Cov
100%
import
6.0
BEGIN
1.0
BEGIN
1.0
CRAP 4.3
« blib/lib/Devel/CheckOS/Helpers/LinuxOSrelease.pm ↑ Summary blib/lib/Devel/AssertOS/MacOSX/v10_0.pm »
1 package Devel::AssertOS;
2  
3 13 ▶use Devel::CheckOS;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 13 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 13 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 13 our $VERSION = '1.21';
9  
10 =head1 NAME
11  
12 Devel::AssertOS - require that we are running on a particular OS
13  
14 =head1 DESCRIPTION
15  
16 Devel::AssertOS is a utility module for Devel::CheckOS and
17 Devel::AssertOS::*. It is nothing but a magic C<import()> that lets you
18 do this:
19  
20 use Devel::AssertOS qw(Linux FreeBSD Cygwin);
21  
22 which will die unless the platform the code is running on is Linux, FreeBSD
23 or Cygwin.
24  
25 To assert that the OS is B<not> a specific platform, prepend the platform name
26 with a minus sign. For example, to run on anything but Amiga, do:
27  
28 use Devel::AssertOS qw(-Amiga);
29  
30  
31 =cut
32  
33 30 ▶sub import {
Subroutine import: called CC=6 SCAR=17.9
34 30 shift;
35 30 ▶ die("Devel::AssertOS needs at least one parameter\n") unless(@_);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ 8 22 30
36  
37 22 my @oses = @_;
38  
39 22 my ( @must, @must_not );
40  
41 22 for my $os ( @oses ) {
42 25 ▶ if ( $os =~ s/^-// ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($os =~ s/^-//) { } 6 19 25
43 6 push @must_not, $os;
44 }
45 else {
46 19 push @must, $os;
47 }
48 }
49  
50 22 ▶ Devel::CheckOS::die_if_os_is(@must_not) if @must_not;
Branch: 1 branch
BranchTrueFalseTotal
if @must_not 6 16 22
51 19 ▶ Devel::CheckOS::die_if_os_isnt(@must) if @must;
Branch: 1 branch
BranchTrueFalseTotal
if @must 17 2 19
52 }
53  
54 =head1 BUGS and FEEDBACK
55  
56 I welcome feedback about my code, including constructive criticism.
57 Bug reports should be made using L<https://github.com/DrHyde/perl-modules-Devel-CheckOS/issues>.
58  
59 You will need to include in your bug report the exact value of $^O, what
60 the OS is called (eg Windows Vista 64 bit Ultimate Home Edition), and,
61 if relevant, what "OS family" it should be in and who wrote it.
62  
63 If you are feeling particularly generous you can encourage me in my
64 open source endeavours by buying me something from my wishlist:
65 L<http://www.cantrell.org.uk/david/wishlist/>
66  
67 =head1 SEE ALSO
68  
69 $^O in L<perlvar>
70  
71 L<perlport>
72  
73 L<Devel::CheckOS>
74  
75 L<Devel::AssertOS::Extending>
76  
77 The use-devel-assertos script
78  
79 L<Module::Install::AssertOS>
80  
81 =head1 AUTHOR
82  
83 David Cantrell E<lt>F<david@cantrell.org.uk>E<gt>
84  
85 Thanks to David Golden for suggesting that I add this utility module.
86  
87 =head1 COPYRIGHT and LICENCE
88  
89 Copyright 2024 David Cantrell
90  
91 This software is free-as-in-speech software, and may be used, distributed, and modified under the terms of either the GNU General Public Licence version 2 or the Artistic Licence. It's up to you which one you use. The full text of the licences can be found in the files GPL2.txt and ARTISTIC.txt, respectively.
92  
93 =head1 CONSPIRACY
94  
95 This module is also free-as-in-mason software.
96  
97 =cut
98  
99 13 $^O;
« blib/lib/Devel/CheckOS/Helpers/LinuxOSrelease.pm ↑ Summary blib/lib/Devel/AssertOS/MacOSX/v10_0.pm »