1Devel::AssertOS::ExtendUisnegr(3C)ontributed Perl DocumeDnetvaetli:o:nAssertOS::Extending(3)
2
3
4

NAME

6       Devel::AssertOS::Extending - how to write Devel::AssertOS::* modules
7       that check what platform they're running on
8

DESCRIPTION

10       Devel::AssertOS::* modules are used by Devel::CheckOS to figure out
11       what OS it is running on.  A set of modules are provided which should
12       correctly detect all platforms that perl *currently* runs on, as well
13       as detecting OS 'families' like 'Unix' and 'Windows'.
14
15       You can also use Devel::AssertOS::* modules on their own to quickly
16       check whether you're running on the right platform.
17
18       If you try to "use" a Devel::AssertOS module on the wrong platform, it
19       will "die" by calling "Devel::CheckOS::die_unsupported()".  This
20       conveniently spits out the text that CPAN-testers look for to see if
21       your code failed simply because they're doing something as silly as
22       testing your Solaris-only code on HPUX.
23

HOW TO WRITE YOUR OWN MODULES

25       If you want to add support for new platforms, you need to write a
26       module called Devel::AssertOS::PlatformName which looks like:
27
28           package Devel::AssertOS::Linux;
29           use Devel::CheckOS;
30           $VERSION = '1.0';
31           sub os_is { $^O eq 'linux' ? 1 : 0; }
32           Devel::CheckOS::die_unsupported() unless(os_is());
33           1;
34
35       And that's it.  The subroutine must be called "os_is" and loading the
36       module must die in precisely that manner if your code is running on the
37       wrong platform.
38
39       If you want to support a 'family' of OSes, then change the subroutine
40       to match any of several values of $^O like this:
41
42           package Devel::AssertOS::FreeSoftware;
43           ...
44           sub os_is {
45               $^O =~ /^(
46                   linux     |
47                   freebsd   |
48                   netbsd    |
49                   openbsd   |
50                   dragonfly
51               )$/x ? 1 : 0;
52           }
53           ...
54
55       Or you could make it a wrapper around several "eval()"ed 'use'
56       statements to try all of Devel::AssertOS::Linux,
57       Devel::AssertOS::FreeBSD etc in turn.  See the sourcecode for
58       Devel::AssertOS::Unix for an example.
59
60       You may also add a subroutine called "expn" which should return a small
61       snipper of explanatory text.  Again, see Devel::AssertOS::Unix for an
62       example.  This is particularly useful for 'family' modules.
63

VERSIONS OF AN OS

65       Two levels of name are supported.  So "Devel::AssertOS::Linux::v2_6" is
66       legal.  More than two levels are not supported.  Be careful to pick
67       names that are both legal perl package names and legal filenames on all
68       platforms.  In general, this means anything that matches
69       "/[_a-z]\w*/i".
70

OS FEATURES

72       I would like to reserve the namespace "Devel::AssertOS::OSFeatures::*".
73       If you want to release a module that tells the user whether a
74       particular feature is available (eg, whether POSIX shell redirection
75       can be expected to work) then please discuss it with me first.
76

BUGS and FEEDBACK

78       I welcome feedback about my code, including constructive criticism.
79       Bug reports should be made using <http://rt.cpan.org/> or by email.
80
81       If you are feeling particularly generous you can encourage me in my
82       open source endeavours by buying me something from my wishlist:
83         <http://www.cantrell.org.uk/david/wishlist/>
84

SEE ALSO

86       Devel::CheckOS
87
88       $^O in perlvar
89
90       perlport
91

AUTHOR

93       David Cantrell <david@cantrell.org.uk>
94
95       Thanks to David Golden for the name and ideas about the interface, and
96       for the cpan-testers-discuss mailing list for prompting me to write it
97       in the first place.
98
100       Copyright 2007 - 2008 David Cantrell
101
102       This documentation is free-as-in-speech.  It may be used, distributed
103       and modified under the terms of the Creative Commons Attribution-Share
104       Alike 2.0 UK: England & Wales License, whose text you may read at
105       http://creativecommons.org/licenses/by-sa/2.0/uk/
106       <http://creativecommons.org/licenses/by-sa/2.0/uk/>.
107

CONSPIRACY

109       This documentation is also free-as-in-mason.
110
111
112
113perl v5.12.0                      2008-11-05     Devel::AssertOS::Extending(3)
Impressum