• 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

80.52
/lib/Rex/Shared/Var/Array.pm
1
#
2
# (c) Jan Gehring <jan.gehring@gmail.com>
3
#
4

5
package Rex::Shared::Var::Array;
6

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

10
use Rex::Shared::Var::Common qw/__lock __store __retrieve/;
72✔
11

12
our $VERSION = '9999.99.99_99'; # VERSION
13

14
sub TIEARRAY {
15
  my $self = { varname => $_[1], };
73✔
16
  bless $self, $_[0];
73✔
17
}
18

19
sub STORE {
20
  my $self  = shift;
35✔
21
  my $index = shift;
35✔
22
  my $value = shift;
35✔
23

24
  return __lock sub {
25
    my $ref = __retrieve;
35✔
26
    my $ret = $ref->{ $self->{varname} }->{data}->[$index] = $value;
35✔
27
    __store $ref;
35✔
28

29
    return $ret;
35✔
30
  };
35✔
31
}
32

33
sub FETCH {
34
  my $self  = shift;
481✔
35
  my $index = shift;
481✔
36

37
  return __lock sub {
38
    my $ref = __retrieve;
481✔
39
    my $ret = $ref->{ $self->{varname} }->{data}->[$index];
481✔
40

41
    return $ret;
481✔
42
  };
481✔
43
}
44

45
sub CLEAR {
46
  my $self = shift;
42✔
47

48
  __lock sub {
49
    my $ref = __retrieve;
42✔
50
    $ref->{ $self->{varname} } = { data => [] };
42✔
51
    __store $ref;
42✔
52
  };
42✔
53
}
54

55
sub DELETE {
56
  my $self  = shift;
×
57
  my $index = shift;
×
58

59
  __lock sub {
60
    my $ref = __retrieve;
×
61
    delete $ref->{ $self->{varname} }->{data}->[$index];
×
62
    __store $ref;
×
63
  };
×
64
}
65

66
sub EXISTS {
67
  my $self  = shift;
×
68
  my $index = shift;
×
69

70
  return __lock sub {
71
    my $ref = __retrieve;
×
72
    return exists $ref->{ $self->{varname} }->{data}->[$index];
×
73
  };
×
74
}
75

76
sub PUSH {
77
  my $self = shift;
57✔
78
  my @data = @_;
57✔
79

80
  __lock sub {
81
    my $ref = __retrieve;
57✔
82

83
    if ( ref( $ref->{ $self->{varname} }->{data} ) ne "ARRAY" ) {
57✔
84
      $ref->{ $self->{varname} }->{data} = [];
8✔
85
    }
86

87
    push( @{ $ref->{ $self->{varname} }->{data} }, @data );
57✔
88

89
    __store $ref;
57✔
90
  };
57✔
91
}
92

93
sub UNSHIFT {
94
  my $self = shift;
14✔
95
  my @data = @_;
14✔
96

97
  __lock sub {
98
    my $ref = __retrieve;
14✔
99

100
    if ( ref( $ref->{ $self->{varname} }->{data} ) ne "ARRAY" ) {
14✔
101
      $ref->{ $self->{varname} }->{data} = [];
×
102
    }
103

104
    unshift( @{ $ref->{ $self->{varname} }->{data} }, @data );
14✔
105

106
    __store $ref;
14✔
107
  };
14✔
108
}
109

110
sub SHIFT {
111
  my $self = shift;
14✔
112
  my @data = @_;
14✔
113
  my $result;
14✔
114

115
  __lock sub {
116
    my $ref = __retrieve;
14✔
117

118
    $result = shift( @{ $ref->{ $self->{varname} }->{data} } );
14✔
119

120
    __store $ref;
14✔
121
  };
14✔
122

123
  return $result;
14✔
124
}
125

126
sub POP {
127
  my $self = shift;
14✔
128
  my @data = @_;
14✔
129
  my $result;
14✔
130

131
  __lock sub {
132
    my $ref = __retrieve;
14✔
133

134
    $result = pop( @{ $ref->{ $self->{varname} }->{data} } );
14✔
135

136
    __store $ref;
14✔
137
  };
14✔
138

139
  return $result;
14✔
140
}
141

142
sub EXTEND {
143
  my $self  = shift;
14✔
144
  my $count = shift;
14✔
145
}
146

147
sub STORESIZE {
148
  my $self    = shift;
×
149
  my $newsize = shift;
×
150
}
151

152
sub FETCHSIZE {
153
  my $self = shift;
243✔
154

155
  return __lock sub {
156
    my $ref = __retrieve;
243✔
157
    if ( !exists $ref->{ $self->{varname} } ) {
243✔
158
      return 0;
×
159
    }
160
    return scalar( @{ $ref->{ $self->{varname} }->{data} } );
243✔
161
  };
243✔
162
}
163

164
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