• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ferki / Rex / 15240232617

28 Feb 2025 09:08AM UTC coverage: 50.961% (+10.2%) from 40.73%
15240232617

push

github

ferki
Use placeholders for template hints

10072 of 19764 relevant lines covered (50.96%)

101.57 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

32.69
/lib/Rex/Interface/Connection/Base.pm
1
#
2
# (c) Jan Gehring <jan.gehring@gmail.com>
3
#
4

5
package Rex::Interface::Connection::Base;
6

7
use v5.12.5;
78✔
8
use warnings;
78✔
9

10
our $VERSION = '9999.99.99_99'; # VERSION
11

12
use Rex::Interface::Fs;
78✔
13
use Rex::Interface::Exec;
78✔
14

15
sub new {
16
  my $that  = shift;
141✔
17
  my $proto = ref($that) || $that;
141✔
18
  my $self  = {@_};
141✔
19

20
  bless( $self, $proto );
141✔
21

22
  $self->{__sudo_options__} = [];
141✔
23

24
  return $self;
141✔
25
}
26

27
sub error                 { die("Must be implemented by Interface Class"); }
×
28
sub connect               { die("Must be implemented by Interface Class"); }
×
29
sub disconnect            { die("Must be implemented by Interface Class"); }
×
30
sub get_connection_object { die("Must be implemented by Interface Class"); }
×
31
sub is_connected          { die("Must be implemented by Interface Class"); }
×
32
sub is_authenticated      { die("Must be implemented by Interface Class"); }
×
33
sub get_connection_type   { die("Must be implemented by Interface Class") }
×
34
sub reconnect             { }
35

36
sub get_fs_connection_object {
37
  my ($self) = @_;
×
38
  return $self;
×
39
}
40

41
sub get_fs {
42
  my $fs = Rex::Interface::Fs->create;
×
43
  return $fs;
×
44
}
45

46
sub get_exec {
47
  my $exec = Rex::Interface::Exec->create;
×
48
  return $exec;
×
49
}
50

51
sub server {
52
  my ($self) = @_;
473✔
53
  return $self->{server};
473✔
54
}
55

56
sub get_auth_user {
57
  my ($self) = @_;
×
58

59
  if ( exists $self->{__auth_info__} ) {
×
60
    return $self->{__auth_info__}->{user};
×
61
  }
62

63
  return "";
×
64
}
65

66
sub get_auth {
67
  my ($self) = @_;
12✔
68

69
  if ( exists $self->{__auth_info__} ) {
12✔
70
    return $self->{__auth_info__};
×
71
  }
72
}
73

74
sub push_sudo_options {
75
  my ( $self, @option ) = @_;
×
76
  if ( ref $option[0] eq "HASH" ) {
×
77
    push @{ $self->{__sudo_options__} }, $option[0];
×
78
  }
79
  else {
80
    push @{ $self->{__sudo_options__} }, {@option};
×
81
  }
82
}
83

84
sub get_current_sudo_options {
85
  my ($self) = @_;
×
86
  return $self->{__sudo_options__}->[-1];
×
87
}
88

89
sub push_use_sudo {
90
  my ( $self, $use ) = @_;
×
91
  push @{ $self->{__use_sudo__} }, $use;
×
92
}
93

94
sub get_current_use_sudo {
95
  my ($self) = @_;
3,982✔
96

97
  if ( $self->{is_sudo} ) {
3,982✔
98
    return 1;
×
99
  }
100
  return $self->{__use_sudo__}->[-1];
3,982✔
101
}
102

103
sub pop_sudo_options {
104
  my ($self) = @_;
×
105
  pop @{ $self->{__sudo_options__} };
×
106
}
107

108
sub pop_use_sudo {
109
  my ($self) = @_;
×
110
  pop @{ $self->{__use_sudo__} };
×
111
}
112

113
sub run_sudo_unmodified {
114
  my ( $self, $code ) = @_;
×
115
  $self->push_sudo_options( {} );
×
116
  $code->();
×
117
  $self->pop_sudo_options();
×
118
}
119

120
1;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc