File Coverage

lib/Slaughter/Info/generic.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition 1 3 33.3
subroutine 4 4 100.0
pod 2 2 100.0
total 23 25 92.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl -w
2              
3             =head1 NAME
4            
5             Slaughter::Info::generic - Determine information about a generic host.
6            
7             =cut
8              
9             =head1 SYNOPSIS
10            
11             This module is the generic version of the Slaughter information-gathering
12             module.
13            
14             Modules beneath the C<Slaughter::Info> namespace are loaded when slaughter
15             is executed, they are used to populate a hash with information about
16             the current host.
17            
18             This module is loaded when no specific module matches the local system,
19             and is essentially a no-operation module. A real info-module is loaded
20             by consulting with the value of C<$^O>, so for example we might load
21             C<Slaughter::Info::linux>.
22            
23             The information discovered can be dumped by running C<slaughter>
24            
25             =for example begin
26            
27             ~# slaughter --dump
28            
29             =for example end
30            
31             Usage of this module is as follows:
32            
33             =for example begin
34            
35             use Slaughter::Info::generic;
36            
37             my $obj = Slaughter::Info::generic->new();
38             my $data = $obj->getInformation();
39            
40             =for example end
41            
42             B<NOTE>: The data retrieved by this generic module is almost empty.
43            
44             The only user-callable method is the C<getInformation> method which
45             is designed to return a hash of data about the current system.
46            
47             =cut
48              
49              
50             =head1 METHODS
51            
52             Now follows documentation on the available methods.
53            
54             =cut
55              
56              
57 1     1   1222 use strict;
  1         3  
  1         47  
58 1     1   5 use warnings;
  1         1  
  1         140  
59              
60              
61             package Slaughter::Info::generic;
62              
63             #
64             # The version of our release.
65             #
66             our $VERSION = "3.0.5";
67              
68              
69              
70             =head2 new
71            
72             Create a new instance of this object.
73            
74             =cut
75              
76             sub new
77             {
78 1     1 1 523     my ( $proto, %supplied ) = (@_);
79 1   33     18     my $class = ref($proto) || $proto;
80              
81 1         2     my $self = {};
82 1         3     bless( $self, $class );
83 1         2     return $self;
84              
85             }
86              
87              
88             =head2 getInformation
89            
90             This function retrieves meta-information about the current host,
91             and is the fall-back module which is used if a system-specific
92             information module cannot be loaded.
93            
94             The return value is a hash-reference of data determined dynamically.
95            
96             Currently the following OS-specific modules exist:
97            
98             =over 8
99            
100             =item C<Slaughter::Info::linux>
101            
102             =item C<Slaughter::Info::MSWin32>
103            
104             =back
105            
106             =cut
107              
108             sub getInformation
109             {
110 1     1 1 908     my ($self) = (@_);
111              
112             #
113             # The data we will return.
114             #
115 1         3     my $ref;
116              
117             #
118             # We're unknown..?
119             #
120 1         3     $ref->{ 'unknown' } = "all";
121              
122             #
123             # This should be portable.
124             #
125 1         3     $ref->{ 'path' } = $ENV{ 'PATH' };
126              
127             # return the data.
128 1         3     return ($ref);
129             }
130              
131              
132              
133             1;
134              
135              
136              
137             =head1 AUTHOR
138            
139             Steve Kemp <steve@steve.org.uk>
140            
141             =cut
142              
143             =head1 LICENSE
144            
145             Copyright (c) 2010-2015 by Steve Kemp. All rights reserved.
146            
147             This module is free software;
148             you can redistribute it and/or modify it under
149             the same terms as Perl itself.
150             The LICENSE file contains the full text of the license.
151            
152             =cut
153