Object.pm

filter: Statementstmt 73.0% 233 / 319 Branchbran 67.2% 109 / 162 Conditioncond 53.8% 28 / 52 MC/DCmcdc 38.7% 12 / 31 Subroutinesub 76.6% 23 / 30 Podpod 100% 12 / 12 totaltotal 68.8% 417 / 606 SCAR 62.2
CC
116
Cov
69%
syncupdates_create
90.0
_syncupdates_submit
56.0
syncupdates_update
20.0
CRAP 500.9
↑ Summary Generic.pm »
1 package Net::Whois::Object;
2 33 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 33 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 33 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 33 ▶use IPC::Open2 qw/open2/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 33 ▶use List::Util qw/max/;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 33 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 33 our $LWP;
11  
12 BEGIN {
13 33 ▶ $LWP = do {
Subroutine BEGIN: called CC=2 SCAR=7.0
14 33 eval { require LWP::UserAgent; };
15 33 ▶ ($@) ? 0 : 1;
Branch: 1 branch
BranchTrueFalseTotal
$@ ? : 0 33 33
16 };
17 }
18  
19 =head1 NAME
20  
21 Net::Whois::Object - Object encapsulating RPSL data returned by Whois queries
22  
23 =head1 SYNOPSIS
24  
25 use Net::Whois::RIPE;
26  
27 my @objects = Net::Whois::Generic->query('AS30781');
28  
29 # Or you can use the previous way
30  
31 my $whois = Net::Whois::RIPE->new( %options );
32 $iterator = $whois->query('AS30781');
33  
34 push @objects, Net::Whois::Object->new($iterator);
35  
36 for my $object (@objects) {
37 # process Net::Whois::Object::xxx objects...
38 # Type of object is available via class() method
39 }
40  
41 =head1 USAGE
42  
43 =head2 Get the data
44  
45 # Get the Class we want to modify
46 my $whois = Net::Whois::RIPE->new( %options );
47 $iterator = $whois->query('POLK-RIPE');
48  
49 =head2 Filter objects
50  
51 Before you had to filter objects using the class() method.
52  
53 # Then to only get the Person object (and ignore Information objects)
54 my ($person) = grep {$_->class() eq 'Person'} Net::Whois::Object->new($iterator);
55  
56 But now the query() from Net::Whois::Generic method allows you to filter more easily
57  
58 my ($person) = Net::Whois::Generic->query('POLK-RIPE', { type => 'person' });
59  
60 You can even use the query() filtering capabilities a little further
61  
62 my @emails = Net::Whois::Generic->query('POLK-RIPE', { type => 'person', attribute => 'e_mail' });
63  
64 Please note, that as soon as you use the attribute filter, the values returned
65 are strings and no more Net::Whois::Objects.
66  
67 =head2 Modify the data
68  
69 # Add a phone number
70 $person->phone(' +33 4 88 00 65 15');
71  
72 Some attributes can have multiple values (remarks, mnt-by...) first implementation allowed only to
73 add one value
74  
75 # Add one maintener
76 $person->mnt_by('CPNY-MNT');
77
78 New implementation (post 2.00020) allow to do:
79  
80 $person->mnt_by({mode => 'append', value => 'CPNY-MNT'});
81  
82 Which is a verbose way to do exactly as the default mode above, but also
83  
84 # Append multiple values at once
85 $person->mnt_by({mode => 'append', value => ['CPNY-MNT2','CPNY-MNT3']});
86  
87 Or even
88  
89 # Replace CPNY-MNT2 by REPL-MNT
90 $person->mnt_by({mode => 'replace', value => {old => 'CPNY-MNT2', new => 'REPL-MNT'}});
91  
92 From release 2.002 you can also use the 'delete' mode to remove a specific attribute value
93  
94 $person->mnt_by({mode => 'delete', value => {old => 'REPL-MNT'}});
95
96 # Or if you want to remove all remarks (the regex '.' meaning any char, will match all remarks values)
97 $person->remarks({mode => 'delete', value => {old => '.'}});
98  
99  
100 =head2 Dump the current state of the data
101  
102 The dump() method, enable to print the object under the classic
103 text form, made of 'attribute: value' lines.
104  
105 # Dump the modified data
106 my $to_be_mailed = $person->dump();
107  
108 dump() handle the 'align' parameter passed though a hash ref.
109  
110 my $to_be_mailed = $person->dump( { align => 15 });
111  
112 =head2 Update the RIPE database
113  
114 The RIPE database update is currently under heavy development.
115  
116 B<*The update code is still to be considered as experimental.*>
117  
118 We plan to offer several ways to update the RIPE database
119  
120 =head3 Update through the web interface
121  
122 RIPE provides several web interfaces
123  
124 =head4 SyncUpdates (*Experimental*)
125  
126 Although not the latest one, this simple interface is the first to be wrapped
127 by this module.
128  
129 B<CAUTION: SyncUpdates features require LWP::UserAgent to be installed.>
130  
131 =head4 Create
132  
133 Once the object has been modified, locally, you can create it in the database
134 calling the syncupdates_create() method.
135  
136 The parameters are passed through a hash ref, and can be the maintener
137 authentication credentials ('password' or 'pgpkey') and the 'align' parameter
138  
139 $object->person('John Doe');
140 ...
141 my $primary_key = $object->syncupdates_create( { password => $password } );
142 # or
143 my $primary_key = $object->syncupdates_create( { pgpkey => $keyID, align => 8 } );
144  
145 The pgp key must be an eight digit hexadecimal key ID known to the local
146 C<gpg> executable.
147  
148 If the C<pgpkey> key is present in the hash reference passed to
149 syncupdates_create, you can also pass in the C<pgpexec> key to chose a program
150 to execute for signing (C<gpg> by default), and C<pgpopts>, which must be an
151 array reference of additional options to pass to the signing binary.
152  
153 The primary key of the object created is returned.
154 The attribute used as primary key can be obtained through
155 C<$object->attribute('primary')>
156  
157 =head4 Update
158  
159 An object existing in the RIPE database, can be retrieved, modified locally
160 and then updated through the syncupdates_update() method.
161  
162 Parameters are passed through a hash ref, and can be the maintener
163 authentication credentials ('password' or 'pgpkey') and the 'align' parameter
164 See L</Create> for more information on the authentication methods.
165  
166 $object->person('John Doe');
167 ...
168 $object->syncupdates_update( { password => $password } );
169  
170 =head4 Delete
171  
172 An object existing in the RIPE database, can be retrieved, and deleted in
173 the databased through the syncupdates_delete() method.
174 Parameters are passed through a hash ref, and can be the maintener
175 authentication credentials ('password' or 'pgpkey') and the 'reason' parameter
176 See L</Create> for more information on the authentication methods.
177  
178 $object->syncupdates_delete( { pgpkey => $keyID } );
179  
180 An additional parameter can be used as a reason for the deletion.
181  
182 $object->syncupdates_delete( { pgpkey => $keyID, reason => 'Obsoleted by XXX' } );
183  
184 If no reason is provided, a default one ('Not needed anymore') is used.
185
186 =head3 Update through email.
187  
188 Not implemented yet.
189  
190 =head1 SUBROUTINES/METHODS
191  
192 =head2 B<new( @lines|$iterator )>
193  
194 The constructor is a factory returning the appropriate Net::Whois::Objects
195 based on the first attribute of the block.
196 You can pass an array of lines or an iterator returned by Net::Whois::RIPE
197 as argument.
198  
199 The two following ways of using the constructor are possible
200  
201 my $whois = Net::Whois::RIPE->new( %options );
202 $iterator = $whois->query('AS30781');
203  
204 # Using the iterator way
205 push @objects, Net::Whois::Object->new($iterator);
206  
207 or
208  
209 # Using the previous (more circonvoluted) @lines way
210  
211 while ( ! $iterator->is_exhausted() ) {
212 my @lines = map { "$_\n"} split '\n', $iterator->value();
213 push @objects, Net::Whois::Object->new(@lines,"\n");
214 }
215  
216 =cut
217  
218 sub new {
219 36 ▶ my ( $class, @lines ) = @_;
Subroutine new: called CC=17 SCAR=28.4
Pod documented
220  
221 # If an iterator is passed as argument convert it to lines.
222 36 ▶ if ( ref $lines[0] eq 'Iterator' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $lines[0] eq "Iterator") 8 28 36
223 8 my $iterator = shift @lines;
224 8 ▶ while ( !$iterator->is_exhausted() ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($iterator->is_exhausted) 55 8 63
225 55 push @lines, map {"$_\n"} split '\n', $iterator->value();
226 55 push @lines, $/;
227 }
228 }
229  
230 36 my ( $attribute, $block, $object, @results, $value );
231  
232 36 for my $line (@lines) {
233 4337 ▶ next if !defined($line);
Branch: 1 branch
BranchTrueFalseTotal
unless defined $line 0 4337 4337
234  
235 4337 ▶ if ( $line =~ /^%(\S+)/ ) {
Branch: 5 branches
BranchTrueFalseTotal
if ($line =~ /^%(\S+)/) { } 1 4336 4337
elsif ($line =~ /^(\S+):\s*(.*)/) { } 4171 165 4336
elsif ($line =~ /^%\s+(.*)/) { } 72 93 165
elsif ($line =~ /^[^%]\s*(.+)/) { } 1 92 93
elsif ($line =~ /^$/) { } 92 0 92
236  
237 1 ▶ $block = 'response' unless $block;
Branch: 1 branch
BranchTrueFalseTotal
unless $block 1 0 1
238  
239 # Response line
240 1 $attribute = 'response';
241 1 $value = $1;
242  
243 } elsif ( $line =~ /^(\S+):\s*(.*)/ ) {
244  
245 # Attribute line
246 4171 $attribute = $1;
247 4171 $value = $2;
248  
249 } elsif ( $line =~ /^%\s+(.*)/ ) {
250  
251 72 ▶ $block = 'comment' unless $block;
Branch: 1 branch
BranchTrueFalseTotal
unless $block 40 32 72
252  
253 # Comment line
254 72 $attribute = 'comment';
255 72 $value = $1;
256  
257 } elsif ( $line =~ /^[^%]\s*(.+)/ ) {
258  
259 # Continuation line
260 1 $value = $1;
261  
262 } elsif ( $line =~ /^$/ ) {
263  
264 # Blank line
265 92 ▶ if ($object) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object) 80 12 92
266 80 $object = _object_factory( $object->{block}, $object->{value}, $object );
267 80 push @results, $object;
268 80 $attribute = undef;
269 80 $block = undef;
270 80 $object = undef;
271 }
272 92 next;
273  
274 }
275  
276 # Normalize attribute to Perl's sub name standards
277 4245 ▶ $attribute =~ s/-/_/g if $attribute;
Branch: 1 branch
BranchTrueFalseTotal
if $attribute 4245 0 4245
278  
279 # First attribute determine the block
280 4245 ▶ $block = $attribute unless $block;
Branch: 1 branch
BranchTrueFalseTotal
unless $block 39 4206 4245
281  
282 4245 ▶ if ( !$object ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($object) 80 4165 4245
283 80 $object = { block => $block, value => $value, attributes => [] };
284  
285 # $object = _object_factory( $block, $value ) unless $object;
286 # } elsif ( $object->can($attribute) ) {
287 # $object->$attribute($value);
288 80 ▶ if ( $block eq 'comment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($block eq "comment") 40 40 80
289  
290 # push @{$object->{attributes}},[ 'comment', $value ];
291 40 next;
292 }
293 }
294  
295 # } else {
296 4205 push @{ $object->{attributes} }, [ $attribute, $value ];
297  
298 # } else {
299 # warn "Objects of type " . ref($object) . " do not support attribute '$attribute', but it was supplied with value '$value'\n";
300 # }
301  
302 }
303  
304 # TODO: fix the trailing undef
305 36 return grep {defined} @results;
306 }
307  
308 =head2 B<clone( [\%options] )>
309  
310 Return a clone from a Net::Whois::RIPE object
311  
312 Current allowed option is remove => [attribute1, ..., attributen] where the specified
313 attribute AREN'T copied to the clone object (for example to ignore the 'changed' values)
314  
315 =cut
316  
317 sub clone {
318 3 ▶ my ( $self, $rh_options ) = @_;
Subroutine clone: called CC=8 SCAR=21.1
Pod documented
319  
320 3 my $clone;
321 my %filtered;
322  
323 3 for my $option ( keys %$rh_options ) {
324 2 ▶ if ( $option =~ /remove/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($option =~ /remove/i) { } 2 0 2
325 2 for my $att ( @{ $rh_options->{$option} } ) {
326 6 $filtered{ lc $att } = 1;
327 }
328 } else {
329 0 croak "Unknown option $option used while cloning a ", ref $self;
330 }
331 }
332  
333 3 my @lines;
334 3 my @tofilter = split /\n/, $self->dump;
335  
336 3 for my $line (@tofilter) {
337 39 ▶ if ( $line =~ /^(.+?):/ and $filtered{ lc $1 } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($line =~ /^(.+?):/ and $filtered{lc $1}) 18 21 39
Condition66%2/3
$line =~ /^(.+?):/ and $filtered{lc $1}
!ll&&!rl&&r
02118
MC/DC50%1/2
$line =~ /^(.+?):/ and $filtered{lc $1}
$line =~ /^(.+?):/ $filtered{lc $1}
Truth table66%2/3
A and B
A= $line =~ /^(.+?):/B= $filtered{lc $1}
ABresult
0X0
100
111
338 18 next;
339 }
340 21 push @lines, $line;
341  
342 }
343  
344 3 eval { ($clone) = Net::Whois::Object->new( @lines, $/ ); };
345 3 ▶ croak $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 3 3
346  
347 3 return $clone;
348 }
349  
350 =head2 B<attributes( [$type [, \@attributes]] )>
351  
352 Accessor to the attributes of the object.
353 C<$type> can be
354  
355 'primary' Primary/Lookup key
356 'mandatory' Required for update creation
357 'optional' Optionnal for update/creation
358 'multiple' Can have multiple values
359 'single' Have only one value
360 'all' You can't specify attributes for this special type
361 which provides all the attributes which have a type
362  
363 If no C<$type> is specified, 'all' is assumed.
364 Returns a list of attributes of the required type.
365  
366 =cut
367  
368 sub attributes {
369 502 ▶ my ( $self, $type, $ra_attributes ) = @_;
Subroutine attributes: called CC=11 SCAR=24.0
Pod documented
370 502 ▶ if ( not defined $type or $type =~ /all/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $type or $type =~ /all/i) 58 444 502
Condition100%3/3
not defined $type or $type =~ /all/i
l!l&&r!l&&!r
157444
MC/DC100%2/2
not defined $type or $type =~ /all/i
not defined $type $type =~ /all/i
Truth table100%3/3
not(A) or B
A= not defined $typeB= $type =~ /all/i
ABresult
1X1
011
000
371 58 return ( $self->attributes('mandatory'), $self->attributes('optional') );
372 }
373 444 ▶ croak "Invalid attribute's type ($type)" unless $type =~ m/(all|primary|mandatory|optional|single|multiple)/i;
Branch: 1 branch
BranchTrueFalseTotal
unless $type =~ /(all|primary|mandatory|optional|single|multiple)/i 0 444 444
374 444 ▶ if ($ra_attributes) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ra_attributes) 185 259 444
375 185 for my $a ( @{$ra_attributes} ) {
376 1211 $self->_TYPE()->{$type}{$a} = 1;
377 }
378 }
379 444 ▶ if ( $type eq 'single' || $type eq 'multiple' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq "single" or $type eq "multiple") 121 323 444
Condition100%3/3
$type eq "single" or $type eq "multiple"
l!l&&r!l&&!r
5863323
MC/DC100%2/2
$type eq "single" or $type eq "multiple"
$type eq "single" $type eq "multiple"
Truth table100%3/3
A or B
A= $type eq "single"B= $type eq "multiple"
ABresult
1X1
011
000
380 121 my $symbol_table = do {
381 33 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
382 121 \%{ $self . '::' };
383 };
384  
385 121 for my $a ( @{$ra_attributes} ) {
386 588 ▶ unless ( exists $symbol_table->{$a} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $symbol_table->{$a}) 581 7 588
387 581 ▶ my $accessor = $type eq 'single' ? sub { _single_attribute_setget( $_[0], $a, $_[1] ) } : sub { _multiple_attribute_setget( $_[0], $a, $_[1] ) };
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
$type eq 'single' ? : 190 391 581
388 33 ▶ no strict 'refs';
Subroutine BEGIN: called CC=1 SCAR=0.0
389 581 *{"${self}::$a"} = $accessor;
390 }
391 }
392 }
393 444 return sort keys %{ $self->_TYPE()->{$type} };
394 }
395  
396 =head2 B<class ( )>
397  
398 This method return the RIPE class associated to the current object.
399  
400 =cut
401  
402 sub class {
403 91 ▶ my ( $self, $value ) = @_;
Subroutine class: called CC=1 SCAR=0.0
Pod documented
404  
405 91 return $self->_single_attribute_setget( 'class', $value );
406 }
407  
408 =head2 B<attribute_is ( $attribute, $type )>
409  
410 This method return true if C<$attribute> is of type C<$type>
411  
412 =cut
413  
414 sub attribute_is {
415 3705 ▶ my ( $self, $attribute, $type ) = @_;
Subroutine attribute_is: called CC=2 SCAR=6.9
Pod documented
416  
417 3705 ▶ return defined $self->_TYPE()->{$type}{$attribute} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $self->_TYPE->{$type}{$attribute} ? : 1924 1781 3705
418 }
419  
420 =head2 B<filtered_attributes( $attribute )>
421  
422 Accessor to the filtered_attributes attribute (attributes to be hidden)
423 Accepts an optional attribute to be added to the filtered_attributes array,
424 always return the current filtered_attributes array.
425  
426 =cut
427  
428 sub filtered_attributes {
429 0 ▶ my ( $self, $filtered_attributes ) = @_;
Subroutine filtered_attributes: not called CC=2 SCAR=17.9
Pod documented
430 0 ▶ push @{ $self->{filtered_attributes} }, $filtered_attributes if defined $filtered_attributes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $filtered_attributes 0 0 0
431 0 return @{ $self->{filtered_attributes} };
432 }
433  
434 =head2 B<displayed_attributes( $attribute )>
435  
436 Accessor to the displayed_attributes attribute which should be displayed.
437 Accepts an optional attribute to be added to the displayed_attributes array,
438 always return the current displayed_attributes array.
439  
440 =cut
441  
442 sub displayed_attributes {
443 0 ▶ my ( $self, $displayed_attributes ) = @_;
Subroutine displayed_attributes: not called CC=2 SCAR=17.9
Pod documented
444 0 ▶ push @{ $self->{displayed_attributes} }, $displayed_attributes if defined $displayed_attributes;
Branch: 1 branch
BranchTrueFalseTotal
if defined $displayed_attributes 0 0 0
445 0 return @{ $self->{displayed_attributes} };
446 }
447  
448 =head2 B<dump( [\%options] )>
449  
450 Simple naive way to display a text form of the class.
451 Try to be as close as possible as the submited text.
452  
453 Currently the only option available is 'align' which accept a C<$column> number as
454 parameter so that all C<< $self->dump >> produces values that are aligned
455 vertically on column C<$column>.
456  
457 =cut
458  
459 sub dump {
460 34 ▶ my ( $self, $options ) = @_;
Subroutine dump: called CC=7 SCAR=19.5
Pod documented
461  
462 34 my %current_index;
463 my $result;
464 34 my $align_to;
465  
466 34 for my $opt ( keys %$options ) {
467 2 ▶ if ( $opt =~ /^align$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^align$/i) { } 2 0 2
468 2 $align_to = $options->{$opt};
469  
470 } else {
471  
472 0 croak "Unknown option $opt for dump()";
473 }
474 }
475  
476 34 ▶ $align_to ||= 5 + max map length, $self->attributes('all');
Condition66%2/3
$align_to ||= 5 + &max(map(length($_), $self->attributes("all")))
l!l&&r!l&&!r
2320
MC/DC0%0/2
$align_to ||= 5 + &max(map(length($_), $self->attributes("all")))
$align_to 5 + &max(map(length($_), $self->attributes("all")))
Truth table66%2/3
A ||= B
A= $align_toB= 5 + &max(map(length($_), $self->attributes("all")))
ABresult
1X1
011
000
477  
478 34 for my $line ( @{ $self->{order} } ) {
479 728 my $attribute = $line;
480 728 $attribute =~ s/_/-/g;
481  
482 728 my $val = $self->$line();
483  
484 728 ▶ if ( ref $val eq 'ARRAY' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $val eq "ARRAY") 627 101 728
485  
486 # If multi value get the lines in order
487 627 $val = $val->[ $current_index{$line}++ ];
488 }
489  
490 728 ▶ $val = '' unless $val;
Branch: 1 branch
BranchTrueFalseTotal
unless $val 4 724 728
491  
492 728 my $alignment = ' ' x ( $align_to - length($attribute) - 1 );
493 728 my $output = "$attribute:$alignment$val\n";
494  
495 # Process the comment
496 728 $output =~ s/comment:\s*/\% /;
497  
498 728 $result .= $output;
499 }
500  
501 34 return $result;
502 }
503  
504 =head2 B<syncupdates_update([\%options] )>
505  
506 Update the RIPE database through the web syncupdates interface.
507 Use the password passed as parameter to authenticate.
508  
509 =cut
510  
511 sub syncupdates_update {
512 0 ▶ my ( $self, $options ) = @_;
Subroutine syncupdates_update: not called CC=4 SCAR=30.0
Pod documented
513  
514 0 my $dump_options;
515  
516 0 for my $opt ( keys %$options ) {
517 0 ▶ if ( $opt =~ /^align$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^align$/i) 0 0 0
518 0 $dump_options = { align => $options->{$opt} };
519 }
520 }
521  
522 0 my ($key) = $self->attributes('primary');
523 0 my $value = $self->_single_attribute_setget($key);
524  
525 0 my $html = $self->_syncupdates_submit( $self->dump($dump_options), $options );
526  
527 0 ▶ if ( $html =~ /Modify SUCCEEDED:.*$value/m ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($html =~ /Modify SUCCEEDED:.*$value/m) { } 0 0 0
528 0 return $value;
529 } else {
530 0 croak "Update not confirmed ($html)";
531 }
532 }
533  
534 =head2 B<syncupdates_delete( \%options )>
535  
536 Delete the object in the RIPE database through the web syncupdates interface.
537 Use the password passed as parameter to authenticate.
538 The optional parmeter reason is used to explain why the object is deleted.
539  
540 =cut
541  
542 sub syncupdates_delete {
543 0 ▶ my ( $self, $options ) = @_;
Subroutine syncupdates_delete: not called CC=3 SCAR=24.8
Pod documented
544  
545 0 my ($key) = $self->attributes('primary');
546 0 my $value = $self->_single_attribute_setget($key);
547  
548 0 my $text = $self->dump();
549 0 ▶ $options->{reason} = 'Not needed anymore' unless $options->{reason};
Branch: 1 branch
BranchTrueFalseTotal
unless $options->{"reason"} 0 0 0
550 0 $text .= "delete: " . $options->{reason} . "\n";
551  
552 0 my $html = $self->_syncupdates_submit( $text, $options );
553  
554 0 ▶ if ( $html =~ /Delete SUCCEEDED:.*$value/m ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($html =~ /Delete SUCCEEDED:.*$value/m) { } 0 0 0
555 0 return $value;
556 } else {
557 0 croak "Deletion not confirmed ($html)";
558 }
559 }
560  
561 =head2 B<syncupdates_create( \%options )>
562  
563 Create an object in the the RIPE database through the web syncupdates interface.
564 See L</Create> for more information on the authentication methods.
565  
566 The available options are 'pgpkey', 'password' and 'align'
567  
568 Return the primary key of the object created.
569  
570 =cut
571  
572 sub syncupdates_create {
573 0 ▶ my ( $self, $options ) = @_;
Subroutine syncupdates_create: not called CC=9 SCAR=45.0
Pod documented
574  
575 0 my $dump_options;
576  
577 0 for my $opt ( keys %$options ) {
578 0 ▶ if ( $opt =~ /^align$/i ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($opt =~ /^align$/i) 0 0 0
579 0 $dump_options = { align => $options->{$opt} };
580 }
581 }
582  
583 0 my $res = $self->_syncupdates_submit( $self->dump($dump_options), $options );
584  
585 0 ▶ if ( $res =~ /^Number of objects processed with errors:\s+(\d+)/m
Branch: 1 branch
BranchTrueFalseTotal
if ($res =~ /^Number of objects processed with errors:\s+(\d+)/m and $1 == 0 and $res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/m || $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m) { } 0 0 0
Condition0%0/9
$res =~ /^Number of objects processed with errors:\s+(\d+)/m and $1 == 0 and $res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/m || $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m
!ll&&!rl&&r
000
$res =~ /^Number of objects processed with errors:\s+(\d+)/m and $1 == 0
!ll&&!rl&&r
000
$res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/m or $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m
l!l&&r!l&&!r
000
MC/DC0%0/4
$res =~ /^Number of objects processed with errors:\s+(\d+)/m and $1 == 0 and $res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/m || $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m
$res =~ /^Number of objects processed with errors:\s+(\d+)/m $1 == 0 $res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/m $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m
Truth table0%0/5
A and B and C or D
A= $res =~ /^Number of objects processed with errors:\s+(\d+)/mB= $1 == 0C= $res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/mD= $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m
ABCDresult
0XXX0
10XX0
11000
111X1
11011
586 && $1 == 0
587 && ( $res =~ /\*\*\*Info:\s+Authorisation for\s+\[[^\]]+]\s+(.+)\s*$/m
588 || $res =~ /(?:Create SUCCEEDED|No operation): \[[^\]]+\]\s+(\S+)/m )
589 )
590 {
591 0 my $value = $1;
592 0 my ($key) = $self->attributes('primary');
593  
594 # some primary keys can contain spaces, in which case $value
595 # is not correct. So only use it for objects where the primary
596 # key can be generated by the RIPE DB, and where it never contains
597 # spaces. According to
598 # http://www.ripe.net/ripe/mail/archives/db-help/2013-January/000411.html
599 # this is the case for person, organization, role and key-cert
600 0 my %obj_types_with_autogen_key = ( KeyCert => 1,
601 Organisation => 1,
602 Person => 1,
603 Role => 1,
604 );
605 0 ▶ if ( $self->class && $obj_types_with_autogen_key{ $self->class } ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->class and $obj_types_with_autogen_key{$self->class}) { } 0 0 0
Condition0%0/3
$self->class and $obj_types_with_autogen_key{$self->class}
!ll&&!rl&&r
000
MC/DC0%0/2
$self->class and $obj_types_with_autogen_key{$self->class}
$self->class $obj_types_with_autogen_key{$self->class}
Truth table0%0/3
A and B
A= $self->classB= $obj_types_with_autogen_key{$self->class}
ABresult
0X0
100
111
606 0 $self->_single_attribute_setget( $key, $value );
607 0 return $value;
608 } else {
609 0 return $self->$key();
610 }
611 } else {
612 0 croak "Error while creating object through syncupdates API: $res";
613 }
614 }
615  
616 =head2 B<query( $query, [\%options] )>
617  
618 This method is deprecated since release 2.005 of Net::Whois::RIPE
619  
620 Please use Net::Whois::Generic->query() instead.
621  
622 =cut
623  
624 sub query {
625  
626 1 ▶ croak "This method is deprecated since release 2.005 of Net::Whois::RIPE\nPlease use Net::Whois::Generic->query() instead\n";
Subroutine query: called CC=1 SCAR=0.0
Pod documented
627  
628 }
629  
630 =begin UNDOCUMENTED
631  
632 =head2 B<_object_factory( $type => $value, $attributes_hashref )>
633  
634 Private method. Shouldn't be used from other modules.
635  
636 Simple factory, creating Net::Whois::Objet::XXXX from
637 the type passed as parameter.
638  
639 =cut
640  
641 sub _object_factory {
642 80 ▶ my $type = shift;
Subroutine _object_factory: called CC=12 SCAR=25.0
643 80 my $value = shift;
644 80 my $object = shift;
645 80 my $rir;
646  
647 my $object_returned;
648  
649 80 my %class = ( as_block => 'AsBlock',
650 as_set => 'AsSet',
651 aut_num => 'AutNum',
652 comment => 'Information',
653 domain => 'Domain',
654 filter_set => 'FilterSet',
655 inet6num => 'Inet6Num',
656 inetnum => 'InetNum',
657 inet_rtr => 'InetRtr',
658 irt => 'Irt',
659 key_cert => 'KeyCert',
660 limerick => 'Limerick',
661 mntner => 'Mntner',
662 organisation => 'Organisation',
663 peering_set => 'PeeringSet',
664 person => 'Person',
665 poem => 'Poem',
666 poetic_form => 'PoeticForm',
667 response => 'Response',
668 role => 'Role',
669 route6 => 'Route6',
670 route => 'Route',
671 route_set => 'RouteSet',
672 rtr_set => 'RtrSet',
673 );
674  
675 80 ▶ die "Unrecognized Object (first attribute: $type = $value)\n" . Dumper($object) unless defined $type and $class{$type};
Branch: 1 branch
BranchTrueFalseTotal
unless defined $type and $class{$type} 0 80 80
Condition33%1/3
defined $type and $class{$type}
!ll&&!rl&&r
0080
MC/DC0%0/2
defined $type and $class{$type}
defined $type $class{$type}
Truth table33%1/3
A and B
A= defined $typeB= $class{$type}
ABresult
0X0
100
111
676  
677 80 my $class = "Net::Whois::Object::" . $class{$type};
678  
679 80 for my $a ( @{ $object->{attributes} } ) {
680 4205 ▶ if ( $a->[0] =~ /source/ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($a->[0] =~ /source/) 38 4167 4205
681 38 $rir = $a->[1];
682 38 $rir =~ s/^(\S+)\s*#.*/$1/;
683 38 $rir = uc $rir;
684 38 ▶ $rir = undef if $rir =~ /^(RIPE|TEST)$/; # For historical/compatibility reason RIPE objects aren't derived
Branch: 1 branch
BranchTrueFalseTotal
if $rir =~ /^(RIPE|TEST)$/ 33 5 38
685 }
686 }
687  
688 80 ▶ $class .= "::$rir" if $rir;
Branch: 1 branch
BranchTrueFalseTotal
if $rir 5 75 80
689  
690 80 ▶ eval "require $class" or die "Can't require $class ($!)";
Branch: 1 branch
BranchTrueFalseTotal
eval "require $class" or die "Can't require $class ($!)" 0 80 80
691  
692 # my $object = $class->new( $type => $value );
693 80 $object_returned = $class->new( class => $class{$type} );
694  
695 # First attribute is always single valued, except for comments
696 80 ▶ if ( $type eq 'comment' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($type eq 'comment') { } 40 40 80
697 40 $object_returned->_multiple_attribute_setget( $type => $value );
698 } else {
699 40 $object_returned->_single_attribute_setget( $type => $value );
700 }
701  
702 80 ▶ if ( $object->{attributes} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($object->{"attributes"}) 80 0 80
703 80 for my $a ( @{ $object->{attributes} } ) {
704 4205 my $method = $a->[0];
705 4205 ▶ if( my $ref = eval { $object_returned->can( $method ) } ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $ref = eval { do { $object_returned->can($method) } }) { } 4204 1 4205
706 4204 $object_returned->$ref( $a->[1] );
707 } else {
708 1 carp "Unknown method '$method' for object $class (Did the Database schema changed ?)"
709 }
710 }
711 }
712  
713 # return $class->new( $type => $value );
714 80 return $object_returned;
715  
716 }
717  
718 =head2 B<_single_attribute_setget( $attribute )>
719  
720 Generic setter/getter for singlevalue attribute.
721  
722 =cut
723  
724 sub _single_attribute_setget {
725 628 ▶ my ( $self, $attribute, $value ) = @_;
Subroutine _single_attribute_setget: called CC=11 SCAR=24.8
726 628 my $mode = 'replace';
727  
728 628 ▶ if ( ref $value eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH") 1 627 628
729 1 my %options = %$value;
730  
731 1 ▶ if ( $options{mode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"mode"}) 1 0 1
732 1 $mode = $options{mode};
733 }
734  
735 1 ▶ if ( $options{value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'value'}) { } 1 0 1
736 1 $value = $options{value};
737 } else {
738 0 croak "Unable to determine attribute $attribute value";
739 }
740  
741 }
742  
743 628 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 357 271 628
744  
745 357 ▶ if ( $mode eq 'replace' ) {
Branch: 2 branches
BranchTrueFalseTotal
if ($mode eq 'replace') { } 356 1 357
elsif ($mode eq 'delete') { } 1 0 1
746  
747 # Store attribute order for dump, unless this attribute as already been set
748 356 ▶ push @{ $self->{order} }, $attribute unless $self->{$attribute} or $attribute eq 'class';
Branch: 1 branch
BranchTrueFalseTotal
unless $self->{$attribute} or $attribute eq "class" 158 198 356
Condition100%3/3
$self->{$attribute} or $attribute eq "class"
l!l&&r!l&&!r
11880158
MC/DC100%2/2
$self->{$attribute} or $attribute eq "class"
$self->{$attribute} $attribute eq "class"
Truth table100%3/3
A or B
A= $self->{$attribute}B= $attribute eq "class"
ABresult
1X1
011
000
749  
750 356 $self->{$attribute} = $value;
751 } elsif ( $mode eq 'delete' ) {
752 1 ▶ if ( ref $value ne 'HASH' or !$value->{old} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value ne 'HASH' or not $value->{'old'}) { } 0 1 1
Condition33%1/3
ref $value ne "HASH" or not $value->{"old"}
l!l&&r!l&&!r
001
MC/DC0%0/2
ref $value ne "HASH" or not $value->{"old"}
ref $value ne "HASH" not $value->{"old"}
Truth table33%1/3
A or not(B)
A= ref $value ne "HASH"B= not $value->{"old"}
ABresult
1X1
011
000
753 0 croak " {old=>...} expected as value for $attribute update in delete mode";
754 } else {
755 1 $self->_delete_attribute( $attribute, $value->{old} );
756 }
757 }
758 }
759 628 return $self->{$attribute};
760 }
761  
762 =head2 B<_multiple_attribute_setget( $attribute )>
763  
764 Generic setter/getter for multivalue attribute.
765  
766 =cut
767  
768 sub _multiple_attribute_setget {
769 5445 ▶ my ( $self, $attribute, $value ) = @_;
Subroutine _multiple_attribute_setget: called CC=18 SCAR=29.1
770 5445 my $mode = 'append';
771  
772 5445 ▶ if ( ref $value eq 'HASH' ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value eq "HASH") 10 5435 5445
773 10 my %options = %$value;
774  
775 10 ▶ if ( $options{mode} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{"mode"}) 8 2 10
776 8 $mode = $options{mode};
777 }
778  
779 10 ▶ if ( $options{value} ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($options{'value'}) { } 10 0 10
780 10 $value = $options{value};
781 } else {
782 0 croak "Unable to determine attribute $attribute value";
783 }
784  
785 }
786  
787 5445 ▶ if ( defined $value ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $value) 4343 1102 5445
788  
789 4343 ▶ if ( $mode eq 'append' ) {
Branch: 3 branches
BranchTrueFalseTotal
if ($mode eq 'append') { } 4335 8 4343
elsif ($mode eq 'replace') { } 3 5 8
elsif ($mode eq 'delete') { } 4 1 5
790 4335 ▶ if ( ref $value eq 'ARRAY' ) {
Branch: 2 branches
BranchTrueFalseTotal
if (ref $value eq 'ARRAY') { } 2 4333 4335
elsif (not ref $value) { } 4333 0 4333
791 2 push @{ $self->{$attribute} }, @$value;
792 2 push @{ $self->{order} }, map {$attribute} @$value;
793 } elsif ( !ref $value ) {
794 4333 push @{ $self->{$attribute} }, $value;
795 4333 push @{ $self->{order} }, $attribute;
796 } else {
797 0 croak "Trying to append weird data to $attribute: ", $value;
798 }
799 } elsif ( $mode eq 'replace' ) {
800 3 ▶ if ( ref $value ne 'HASH' or !$value->{old} or !$value->{new} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value ne 'HASH' or not $value->{'old'} or not $value->{'new'}) { } 2 1 3
Condition83%5/6
ref $value ne "HASH" or not $value->{"old"} or not $value->{"new"}
l!l&&r!l&&!r
111
ref $value ne "HASH" or not $value->{"old"}
l!l&&r!l&&!r
012
MC/DC66%2/3
ref $value ne "HASH" or not $value->{"old"} or not $value->{"new"}
ref $value ne "HASH" not $value->{"old"} not $value->{"new"}
Truth table75%3/4
A or not(B) or not(C)
A= ref $value ne "HASH"B= not $value->{"old"}C= not $value->{"new"}
ABCresult
1XX1
01X1
0011
0000
801 2 croak " {old=>..., new=>} expected as value for $attribute update in replace mode";
802 } else {
803 1 my $old = $value->{old};
804 1 for ( @{ $self->{$attribute} } ) {
805 4 ▶ $_ = $value->{new} if $_ =~ /$old/;
Branch: 1 branch
BranchTrueFalseTotal
if $_ =~ /$old/ 1 3 4
806 }
807 }
808 } elsif ( $mode eq 'delete' ) {
809 4 ▶ if ( ref $value ne 'HASH' or !$value->{old} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $value ne 'HASH' or not $value->{'old'}) { } 1 3 4
Condition66%2/3
ref $value ne "HASH" or not $value->{"old"}
l!l&&r!l&&!r
013
MC/DC50%1/2
ref $value ne "HASH" or not $value->{"old"}
ref $value ne "HASH" not $value->{"old"}
Truth table66%2/3
A or not(B)
A= ref $value ne "HASH"B= not $value->{"old"}
ABresult
1X1
011
000
810 1 croak " {old=>...} expected as value for $attribute update in delete mode";
811 } else {
812  
813 # $self->{$attribute} = [grep {!/$old/} @{$self->{$attribute}}];
814 3 $self->_delete_attribute( $attribute, $value->{old} );
815 }
816 } else {
817 1 croak "Unknown mode $mode for attribute $attribute";
818 }
819 }
820  
821 5441 ▶ croak "$attribute $self" unless ref $self;
Branch: 1 branch
BranchTrueFalseTotal
unless ref $self 0 5441 5441
822 5441 return $self->{$attribute};
823 }
824  
825 =head2 B<_delete_attribute( $attribute, $pattern )>
826  
827 Delete an attribute if its value match the pattern value
828  
829 =cut
830  
831 sub _delete_attribute {
832 4 ▶ my ( $self, $attribute, $pattern ) = @_;
Subroutine _delete_attribute: called CC=10 SCAR=23.0
833  
834 4 my @lines;
835  
836 4 for my $a ( @{ $self->{order} } ) {
837 36 ▶ my $val = ref $self->{$a} ? shift @{ $self->{$a} } : $self->{$a};
Branch: 1 branch
BranchTrueFalseTotal
ref $self->{$a} ? : 28 8 36
838 36 push @lines, [ $a, $val ];
839 }
840  
841 4 ▶ @lines = grep { $attribute ne $_->[0] or $_->[1] !~ /$pattern/ } @lines;
Branch: 1 branch
BranchTrueFalseTotal
$attribute ne $_->[0] or not $_->[1] =~ /$pattern/ 9 27 36
842 4 ▶ delete $self->{$attribute} if $self->attribute_is( $attribute, 'single' ) and $self->{$attribute} =~ /$pattern/;
Branch: 1 branch
BranchTrueFalseTotal
if $self->attribute_is($attribute, "single") and $self->{$attribute} =~ /$pattern/ 1 3 4
Condition66%2/3
$self->attribute_is($attribute, "single") and $self->{$attribute} =~ /$pattern/
!ll&&!rl&&r
301
MC/DC50%1/2
$self->attribute_is($attribute, "single") and $self->{$attribute} =~ /$pattern/
$self->attribute_is($attribute, "single") $self->{$attribute} =~ /$pattern/
Truth table66%2/3
A and B
A= $self->attribute_is($attribute, "single")B= $self->{$attribute} =~ /$pattern/
ABresult
0X0
100
111
843  
844 4 $self->{order} = [];
845 4 for my $l (@lines) {
846 30 ▶ $self->{ $l->[0] } = [] if ref( $self->{ $l->[0] } );
Branch: 1 branch
BranchTrueFalseTotal
if ref $$self{$l->[0]} 23 7 30
847 }
848  
849 4 for my $i ( 0 .. $#lines ) {
850 30 push @{ $self->{order} }, $lines[$i]->[0];
851 30 ▶ if ( $self->attribute_is( $lines[$i]->[0], 'multiple' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->attribute_is($lines[$i][0], 'multiple')) { } 23 7 30
852 23 push @{ $self->{ $lines[$i]->[0] } }, $lines[$i]->[1];
853 } else {
854 7 $self->{ $lines[$i]->[0] } = $lines[$i]->[1];
855  
856 }
857  
858 }
859  
860 }
861  
862 =head2 B<_init( @options )>
863  
864 Initialize self with C<@options>
865  
866 =cut
867  
868 sub _init {
869 81 ▶ my ( $self, @options ) = @_;
Subroutine _init: called CC=2 SCAR=6.9
870  
871 81 ▶ while ( my ( $key, $val ) = splice( @options, 0, 2 ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if (() = splice(@options, 0, 2)) 95 81 176
872 95 $self->$key($val);
873 }
874 }
875  
876 =head2 B<_syncupdates_submit( $text, \%options )>
877  
878 Interact with the RIPE database through the web syncupdates interface.
879 Submit the text passed as parameter.
880 Use the password passed as parameter to authenticate.
881 The database used is chosen based on the 'source' attribute.
882  
883 Return the HTML code of the returned page.
884 (This will change in a near future)
885  
886 =cut
887  
888 sub _syncupdates_submit {
889 0 ▶ my ( $self, $text, $options ) = @_;
Subroutine _syncupdates_submit: not called CC=7 SCAR=40.3
890  
891 0 ▶ if ( exists $options->{pgpkey} ) {
Branch: 2 branches
BranchTrueFalseTotal
if (exists $options->{'pgpkey'}) { } 0 0 0
elsif (exists $options->{'password'}) { } 0 0 0
892 0 $text = $self->_pgp_sign( $text, $options );
893 } elsif ( exists $options->{password} ) {
894 0 my $password = $options->{password};
895 0 chomp $password;
896 0 ▶ croak("Passwords containing newlines are not supported")
Branch: 1 branch
BranchTrueFalseTotal
if $password =~ /\n/ 0 0 0
897 if $password =~ /\n/;
898 0 $text .= "password: $password\n";
899 }
900  
901 0 ▶ croak "LWP::UserAgent required for updates" unless $LWP;
Branch: 1 branch
BranchTrueFalseTotal
unless $LWP 0 0 0
902  
903 0 ▶ my $url = $self->source eq 'RIPE' ? 'http://syncupdates.db.ripe.net/' : 'http://syncupdates-test.db.ripe.net';
Branch: 1 branch
BranchTrueFalseTotal
$self->source eq 'RIPE' ? : 0 0 0
904  
905 0 my $ua = LWP::UserAgent->new;
906  
907 0 my $response = $ua->post( $url, { DATA => $text } );
908 0 my $response_text = $response->decoded_content;
909  
910 0 ▶ unless ( $response->is_success ) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($response->is_success) 0 0 0
911 0 croak "Can't sync object with RIPE database: $response_text";
912 }
913  
914 0 return $response_text;
915 }
916  
917 =head2 B<_pgp_sign( $text, $auth )>
918  
919 Sign the C<$text> with the C<gpg> command and gpg information in C<$auth>
920 Returns the signed text.
921  
922 =cut
923  
924 sub _pgp_sign {
925 0 ▶ my ( $self, $text, $auth ) = @_;
Subroutine _pgp_sign: not called CC=4 SCAR=30.0
926  
927 0 ▶ my $binary = $auth->{pgpexec} || 'gpg';
Condition0%0/2
$auth->{'pgpexec'} || 'gpg'
l!l
00
MC/DC0%0/1
$auth->{'pgpexec'} || 'gpg'
$auth->{'pgpexec'}
Truth table0%0/2
A
A= $auth->{'pgpexec'}
Aresult
11
00
928 0 my $key_id = $auth->{pgpkey};
929 0 ▶ my @opts = @{ $auth->{pgpopts} || [] };
Branch: 1 branch
BranchTrueFalseTotal
$auth->{"pgpopts"} or [] 0 0 0
930  
931 0 $key_id =~ s/^0x//;
932 0 my $pid = open2( my $child_out, my $child_in, $binary, "--local-user=$key_id", '--clearsign', @opts );
933 0 print {$child_in} $text;
934 0 close $child_in;
935  
936 0 $text = do { local $/; <$child_out> };
937 0 close $child_out;
938  
939 0 waitpid( $pid, 0 );
940 0 my $child_exit_status = $? >> 8;
941 0 ▶ if ( $child_exit_status != 0 ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($child_exit_status != 0) 0 0 0
942 0 croak "Error while launching $binary for signing the message: child process exited with status $child_exit_status";
943 }
944  
945 0 return $text;
946 }
947  
948 =head2 B<_TYPE>
949  
950 Returns a hash ref that contains the attribute data for the class
951 of the object that the method was called on.
952  
953 =end UNDOCUMENTED
954  
955 =cut
956  
957 33 my %TYPES;
958  
959 sub _TYPE {
960 5360 ▶ $TYPES{ ref $_[0] || $_[0] } ||= {};
Subroutine _TYPE: called CC=3 SCAR=11.1
Condition80%4/5
$TYPES{ref $_[0] or $_[0]} ||= {}
l!l
532139
ref $_[0] || $_[0]
l!l&&r!l&&!r
396813920
MC/DC100%1/1
$TYPES{ref $_[0] or $_[0]} ||= {}
$TYPES{ref $_[0] or $_[0]}
MC/DC0%0/2
ref $_[0] || $_[0]
ref $_[0] $_[0]
Truth table100%2/2
A
A= $TYPES{ref $_[0] or $_[0]}
Aresult
11
00
Truth table66%2/3
A || B
A= ref $_[0]B= $_[0]
ABresult
1X1
011
000
961 }
962  
963 =head1 SEE ALSO
964  
965 Please take a look at L<Net::Whois::Generic> the more generic whois client built on top of Net::Whois::RIPE.
966  
967 =head1 TODO
968  
969 The update part (in RIPE database) still needs a lot of work.
970  
971 Enhance testing without network
972  
973 Enhance test coverage
974  
975 =head1 AUTHOR
976  
977 Arnaud "Arhuman" Assad, C<< <arhuman at gmail.com> >>
978  
979 =head1 ACKNOWLEDGEMENTS
980  
981 Thanks to Jaguar Network for allowing me to work on this during some of my office
982 hours.
983  
984 Thanks to Luis Motta Campos for his trust when allowing me to publish this
985 release.
986  
987 Thanks to Moritz Lenz for all his contributions
988 (Thanks also to 'Noris Network AG', his employer, for allowing him to contribute in the office hours)
989  
990 =cut
991  
992 33 1;
↑ Summary Generic.pm »