File Coverage

lib/Rex/User.pm
Criterion Covered Total %
statement 23 30 76.6
branch 6 12 50.0
condition n/a
subroutine 7 7 100.0
pod 0 1 0.0
total 36 50 72.0


line stmt bran cond sub pod time code
1             #
2             # (c) Jan Gehring
3             #
4              
5             package Rex::User;
6              
7 33     33   446 use v5.12.5;
  33         124  
8 33     33   165 use warnings;
  33         63  
  33         1752  
9              
10             our $VERSION = '1.14.3'; # VERSION
11              
12 33     33   223 use Rex::Commands::Gather;
  33         70  
  33         402  
13 33     33   235 use Rex::Logger;
  33         85  
  33         928  
14              
15             sub get {
16              
17 2     2 0 8 my $user_o = "Linux";
18 2 50       15 if (is_freebsd) {
    50          
    50          
    50          
    50          
19 0         0 $user_o = "FreeBSD";
20             }
21             elsif (is_netbsd) {
22 0         0 $user_o = "NetBSD";
23             }
24             elsif (is_openbsd) {
25 0         0 $user_o = "OpenBSD";
26             }
27             elsif ( operating_system_is("SunOS") ) {
28 0         0 $user_o = "SunOS";
29             }
30             elsif (is_openwrt) {
31 0         0 $user_o = "OpenWrt";
32             }
33              
34 2         58 my $class = "Rex::User::" . $user_o;
35 2     1   234 eval "use $class";
  1     1   32  
  1         3  
  1         18  
  1         15  
  1         12  
  1         27  
36              
37 2 50       43 if ($@) {
38              
39 0         0 Rex::Logger::info("OS not supported");
40 0         0 die("OS not supported");
41              
42             }
43              
44 2         30 return $class->new;
45              
46             }
47              
48             1;