File Coverage

blib/lib/Devel/AssertOS.pm
Criterion Covered Total %
statement 19 19 100.0
branch 8 8 100.0
condition n/a
subroutine 4 4 100.0
pod n/a
total 31 31 100.0


line stmt bran cond sub pod time code
1             package Devel::AssertOS;
2              
3 6     6   5889 use Devel::CheckOS;
  6         18  
  6         233  
4              
5 6     6   33 use strict;
  6         10  
  6         106  
6 6     6   25 use warnings;
  6         11  
  6         1142  
7              
8             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 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 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             sub import {
34 11     11   4129 shift;
35 11 100       61 die("Devel::AssertOS needs at least one parameter\n") unless(@_);
36              
37 10         24 my @oses = @_;
38              
39 10         19 my ( @must, @must_not );
40              
41 10         22 for my $os ( @oses ) {
42 13 100       63 if ( $os =~ s/^-// ) {
43 6         15 push @must_not, $os;
44             }
45             else {
46 7         17 push @must, $os;
47             }
48             }
49              
50 10 100       50 Devel::CheckOS::die_if_os_is(@must_not) if @must_not;
51 7 100       62 Devel::CheckOS::die_if_os_isnt(@must) if @must;
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.
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
66              
67             =head1 SEE ALSO
68              
69             $^O in L
70              
71             L
72              
73             L
74              
75             L
76              
77             The use-devel-assertos script
78              
79             L
80              
81             =head1 AUTHOR
82              
83             David Cantrell EFE
84              
85             Thanks to David Golden for suggesting that I add this utility module.
86              
87             =head1 COPYRIGHT and LICENCE
88              
89             Copyright 2023 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             $^O;