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 5     5   4237 use Devel::CheckOS;
  5         11  
  5         148  
4              
5 5     5   23 use strict;
  5         7  
  5         68  
6 5     5   18 use warnings;
  5         8  
  5         737  
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 10     10   3494 shift;
35 10 100       40 die("Devel::AssertOS needs at least one parameter\n") unless(@_);
36              
37 9         21 my @oses = @_;
38              
39 9         14 my ( @must, @must_not );
40              
41 9         19 for my $os ( @oses ) {
42 12 100       44 if ( $os =~ s/^-// ) {
43 6         12 push @must_not, $os;
44             }
45             else {
46 6         13 push @must, $os;
47             }
48             }
49              
50 9 100       38 Devel::CheckOS::die_if_os_is(@must_not) if @must_not;
51 6 100       40 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 2007 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;