| 1 | ## Domain Registry Interface, Encapsulating raw data | ||||||||||||
| 2 | ## | ||||||||||||
| 3 | ## Copyright (c) 2005-2010,2013 Patrick Mevzek <netdri@dotandco.com>. All rights reserved. | ||||||||||||
| 4 | ## | ||||||||||||
| 5 | ## This file is part of Net::DRI | ||||||||||||
| 6 | ## | ||||||||||||
| 7 | ## Net::DRI is free software; you can redistribute it and/or modify | ||||||||||||
| 8 | ## it under the terms of the GNU General Public License as published by | ||||||||||||
| 9 | ## the Free Software Foundation; either version 2 of the License, or | ||||||||||||
| 10 | ## (at your option) any later version. | ||||||||||||
| 11 | ## | ||||||||||||
| 12 | ## See the LICENSE file that comes with this distribution for more details. | ||||||||||||
| 13 | ######################################################################################### | ||||||||||||
| 14 | |||||||||||||
| 15 | package Net::DRI::Data::Raw; | ||||||||||||
| 16 | |||||||||||||
| 17 | 85 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 18 | 85 | ▶ | use warnings; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 19 | |||||||||||||
| 20 | 85 | ▶ | use Data::Dumper (); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 21 | 85 | ▶ | use Net::DRI::Exception; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 22 | |||||||||||||
| 23 | 85 | ▶ | use base qw(Class::Accessor::Fast); | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 24 | 85 | __PACKAGE__->mk_ro_accessors(qw(type data hint)); | |||||||||||
| 25 | |||||||||||||
| 26 | =pod | ||||||||||||
| 27 | |||||||||||||
| 28 | =head1 NAME | ||||||||||||
| 29 | |||||||||||||
| 30 | Net::DRI::Data::Raw - Encapsulating raw data for Net::DRI | ||||||||||||
| 31 | |||||||||||||
| 32 | =head1 DESCRIPTION | ||||||||||||
| 33 | |||||||||||||
| 34 | Please see the README file for details. | ||||||||||||
| 35 | |||||||||||||
| 36 | =head1 SUPPORT | ||||||||||||
| 37 | |||||||||||||
| 38 | For now, support questions should be sent to: | ||||||||||||
| 39 | |||||||||||||
| 40 | E<lt>netdri@dotandco.comE<gt> | ||||||||||||
| 41 | |||||||||||||
| 42 | Please also see the SUPPORT file in the distribution. | ||||||||||||
| 43 | |||||||||||||
| 44 | =head1 SEE ALSO | ||||||||||||
| 45 | |||||||||||||
| 46 | E<lt>http://www.dotandco.com/services/software/Net-DRI/E<gt> | ||||||||||||
| 47 | |||||||||||||
| 48 | =head1 AUTHOR | ||||||||||||
| 49 | |||||||||||||
| 50 | Patrick Mevzek, E<lt>netdri@dotandco.comE<gt> | ||||||||||||
| 51 | |||||||||||||
| 52 | =head1 COPYRIGHT | ||||||||||||
| 53 | |||||||||||||
| 54 | Copyright (c) 2005-2010,2013 Patrick Mevzek <netdri@dotandco.com>. | ||||||||||||
| 55 | All rights reserved. | ||||||||||||
| 56 | |||||||||||||
| 57 | This program is free software; you can redistribute it and/or modify | ||||||||||||
| 58 | it under the terms of the GNU General Public License as published by | ||||||||||||
| 59 | the Free Software Foundation; either version 2 of the License, or | ||||||||||||
| 60 | (at your option) any later version. | ||||||||||||
| 61 | |||||||||||||
| 62 | See the LICENSE file that comes with this distribution for more details. | ||||||||||||
| 63 | |||||||||||||
| 64 | =cut | ||||||||||||
| 65 | |||||||||||||
| 66 | #################################################################################################### | ||||||||||||
| 67 | |||||||||||||
| 68 | sub new | ||||||||||||
| 69 | { | ||||||||||||
| 70 | 6 | ▶ | my ($class,$type,$data,$hint)=@_; | ||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||
| 71 | |||||||||||||
| 72 | ## type=1, data=ref to array | ||||||||||||
| 73 | ## type=2, data=string | ||||||||||||
| 74 | ## type=3, data=ref to string NOTIMPL | ||||||||||||
| 75 | ## type=4, data=path to local file NOTIMPL | ||||||||||||
| 76 | ## type=5, data=object with a as_string method | ||||||||||||
| 77 | ## type=6, data=complex object in a ref array | ||||||||||||
| 78 | |||||||||||||
| 79 | 6 | ▶ | my $self={type => $type, | ||||||||||
|
Condition50%1/2
$hint || ''
MC/DC0%0/1
$hint || ''
$hint
Truth table50%1/2
A
A= $hint
| |||||||||||||
| 80 | data => $data, | ||||||||||||
| 81 | hint => $hint || '', | ||||||||||||
| 82 | }; | ||||||||||||
| 83 | |||||||||||||
| 84 | 6 | bless($self,$class); | |||||||||||
| 85 | 6 | return $self; | |||||||||||
| 86 | } | ||||||||||||
| 87 | |||||||||||||
| 88 | |||||||||||||
| 89 | sub new_from_array | ||||||||||||
| 90 | { | ||||||||||||
| 91 | 0 | ▶ | my ($class,@args)=@_; | ||||||||||
|
Subroutine
new_from_array: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||
| 92 | 0 | ▶ | my @a=map { my $f=$_; $f=~s/[\r\n\s]+$//; $f; } (ref $args[0] ? @{$args[0]} : @args); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 93 | 0 | return $class->new(1,\@a); | |||||||||||
| 94 | } | ||||||||||||
| 95 | |||||||||||||
| 96 | 6 | ▶ | sub new_from_string { return shift->new(2,@_); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||
|
Subroutine
new_from_string: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||
| 97 | 0 | ▶ | sub new_from_xmlstring { return shift->new(2,$_[0],'xml'); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||
|
Subroutine
new_from_xmlstring: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 98 | 0 | ▶ | sub new_from_object { return shift->new(5,@_); } ## no critic (Subroutines::RequireArgUnpacking) | ||||||||||
|
Subroutine
new_from_object: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||
| 99 | |||||||||||||
| 100 | #################################################################################################### | ||||||||||||
| 101 | |||||||||||||
| 102 | sub as_string | ||||||||||||
| 103 | { | ||||||||||||
| 104 | 4 | ▶ | my $self=shift; | ||||||||||
|
Subroutine
as_string: called CC=6 SCAR=27.3
Pod
undocumented
| |||||||||||||
| 105 | 4 | my $data=$self->data(); | |||||||||||
| 106 | |||||||||||||
| 107 | 4 | ▶ | if ($self->type()==1) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 108 | { | ||||||||||||
| 109 | 0 | return join("\n",@$data)."\n"; | |||||||||||
| 110 | } | ||||||||||||
| 111 | 4 | ▶ | if ($self->type()==2) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 112 | { | ||||||||||||
| 113 | 4 | $data=~s/\r\n/\n/g; | |||||||||||
| 114 | 4 | return $data; | |||||||||||
| 115 | } | ||||||||||||
| 116 | 0 | ▶ | if ($self->type()==5) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 117 | { | ||||||||||||
| 118 | 0 | ▶ | Net::DRI::Exception::method_not_implemented('as_string',ref $data) unless $data->can('as_string'); | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 119 | 0 | return $data->as_string(); | |||||||||||
| 120 | } | ||||||||||||
| 121 | 0 | ▶ | if ($self->type()==6) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 122 | { | ||||||||||||
| 123 | 0 | return Data::Dumper->new($data)->Indent(2)->Varname('')->Quotekeys(0)->Sortkeys(1)->Dump(); | |||||||||||
| 124 | } | ||||||||||||
| 125 | } | ||||||||||||
| 126 | |||||||||||||
| 127 | sub last_line | ||||||||||||
| 128 | { | ||||||||||||
| 129 | 0 | ▶ | my $self=shift; | ||||||||||
|
Subroutine
last_line: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||
| 130 | |||||||||||||
| 131 | 0 | ▶ | if ($self->type()==1) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 132 | { | ||||||||||||
| 133 | 0 | my $data=$self->data(); | |||||||||||
| 134 | 0 | return $data->[-1]; ## see above | |||||||||||
| 135 | } | ||||||||||||
| 136 | 0 | ▶ | if ($self->type()==2) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 137 | { | ||||||||||||
| 138 | 0 | my @a=$self->as_array(); | |||||||||||
| 139 | 0 | return $a[-1]; | |||||||||||
| 140 | } | ||||||||||||
| 141 | } | ||||||||||||
| 142 | |||||||||||||
| 143 | sub as_array | ||||||||||||
| 144 | { | ||||||||||||
| 145 | 2 | ▶ | my $self=shift; | ||||||||||
|
Subroutine
as_array: called CC=3 SCAR=12.7
Pod
undocumented
| |||||||||||||
| 146 | |||||||||||||
| 147 | 2 | ▶ | if ($self->type()==1) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 148 | { | ||||||||||||
| 149 | 0 | return @{$self->data()}; | |||||||||||
| 150 | } | ||||||||||||
| 151 | |||||||||||||
| 152 | 2 | ▶ | if ($self->type()==2) | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 153 | { | ||||||||||||
| 154 | 2 | return split(/\r?\n/,$self->data()); | |||||||||||
| 155 | } | ||||||||||||
| 156 | } | ||||||||||||
| 157 | |||||||||||||
| 158 | #################################################################################################### | ||||||||||||
| 159 | 85 | 1; | |||||||||||