| 1 | package Mail::Karmasphere::Query; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 5 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 5 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 5 | ▶ | use vars qw(@ISA @EXPORT_OK %EXPORT_TAGS $ID); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 5 | ▶ | use Carp; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 5 | ▶ | use Exporter; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | |||||||||||||||||||||||||||||
| 9 | 5 | ▶ | BEGIN { | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 5 | @ISA = qw(Exporter); | |||||||||||||||||||||||||||
| 11 | 5 | @EXPORT_OK = qw(guess_identity_type); | |||||||||||||||||||||||||||
| 12 | 5 | %EXPORT_TAGS = ( | |||||||||||||||||||||||||||
| 13 | 'all' => \@EXPORT_OK, | ||||||||||||||||||||||||||||
| 14 | ); | ||||||||||||||||||||||||||||
| 15 | } | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | 5 | ▶ | use Mail::Karmasphere::Client qw(:all); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 5 | $ID = 0; | |||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||
|
Subroutine
new: called CC=20 SCAR=47.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 22 | 2 | my $class = shift; | |||||||||||||||||||||||||||
| 23 | 0 | ▶ | my $args = ($#_ == 0) ? { %{ (shift) } } : { @_ }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | #use Data::Dumper; | ||||||||||||||||||||||||||||
| 26 | #print Dumper($args); | ||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | 2 | my $self = bless { }, $class; | |||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||
| 30 | 2 | ▶ | if (exists $args->{Id}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 31 | 0 | $self->id(delete $args->{Id}); | |||||||||||||||||||||||||||
| 32 | } | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | 2 | ▶ | if (exists $args->{Identities}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $identities = delete $args->{Identities}; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | die "Identities must be a listref, not " . ref($identities) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | unless ref($identities) eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 38 | 0 | for my $identity (@$identities) { | |||||||||||||||||||||||||||
| 39 | 0 | ▶ | if (ref($identity) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | $self->identity(@$identity); | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | else { | ||||||||||||||||||||||||||||
| 43 | 0 | $self->identity($identity); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | } | ||||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 2 | ▶ | if (exists $args->{Composites}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 49 | 0 | my $composites = delete $args->{Composites}; | |||||||||||||||||||||||||||
| 50 | 0 | ▶ | die "Composites must be a listref" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | unless ref($composites) eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 52 | 0 | $self->composite($_) for @$composites; | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 2 | ▶ | if (exists $args->{Composite}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 56 | 0 | $self->composite(delete $args->{Composite}); | |||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | 2 | ▶ | if (exists $args->{Feeds}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 60 | 0 | my $feeds = delete $args->{Feeds}; | |||||||||||||||||||||||||||
| 61 | 0 | ▶ | die "Feeds must be a listref" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 62 | unless ref($feeds) eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 63 | 0 | $self->feed($_) for @$feeds; | |||||||||||||||||||||||||||
| 64 | } | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 2 | ▶ | if (exists $args->{Combiners}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 67 | 0 | my $combiners = delete $args->{Combiners}; | |||||||||||||||||||||||||||
| 68 | 0 | ▶ | die "Combiners must be a listref" | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 69 | unless ref($combiners) eq 'ARRAY'; | ||||||||||||||||||||||||||||
| 70 | 0 | $self->combiner($_) for @$combiners; | |||||||||||||||||||||||||||
| 71 | } | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 2 | ▶ | if (exists $args->{Combiner}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 74 | 0 | $self->combiner(delete $args->{Combiner}); | |||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||
| 77 | 2 | ▶ | if (exists $args->{Flags}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 78 | 0 | $self->flags(delete $args->{Flags}); | |||||||||||||||||||||||||||
| 79 | } | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 2 | my @remain = keys %$args; | |||||||||||||||||||||||||||
| 82 | 2 | ▶ | if (@remain) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 83 | 0 | carp "Unrecognised arguments to constructor: @remain"; | |||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | 2 | return $self; | |||||||||||||||||||||||||||
| 87 | } | ||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||
| 89 | 0 | ▶ | sub guess_identity_type { | ||||||||||||||||||||||||||
|
Subroutine
guess_identity_type: not called CC=6 SCAR=37.4
Pod
undocumented
| |||||||||||||||||||||||||||||
| 90 | 0 | my $identity = shift; | |||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 0 | ▶ | if ($identity =~ /^[0-9\.]{7,15}$/) { | ||||||||||||||||||||||||||
|
Branch: 5 branches
| |||||||||||||||||||||||||||||
| 93 | 0 | return IDT_IP4; | |||||||||||||||||||||||||||
| 94 | } | ||||||||||||||||||||||||||||
| 95 | elsif ($identity =~ /^[0-9a-f:]{2,64}$/i) { | ||||||||||||||||||||||||||||
| 96 | 0 | return IDT_IP6; | |||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||
| 98 | elsif ($identity =~ /^https?:\/\//) { | ||||||||||||||||||||||||||||
| 99 | 0 | return IDT_URL; | |||||||||||||||||||||||||||
| 100 | } | ||||||||||||||||||||||||||||
| 101 | elsif ($identity =~ /@/) { | ||||||||||||||||||||||||||||
| 102 | 0 | return IDT_EMAIL; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | elsif ($identity =~ /\./) { | ||||||||||||||||||||||||||||
| 105 | 0 | return IDT_DOMAIN; | |||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | 0 | return undef; | |||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 1 | ▶ | sub id { | ||||||||||||||||||||||||||
|
Subroutine
id: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||||||||||
| 112 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 113 | 1 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 114 | 0 | $self->{Id} = shift; | |||||||||||||||||||||||||||
| 115 | } | ||||||||||||||||||||||||||||
| 116 | elsif (!defined $self->{Id}) { | ||||||||||||||||||||||||||||
| 117 | 1 | $self->{Id} = 'mkc' . $ID++ . "-" . time(); | |||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||
| 119 | 1 | return $self->{Id}; | |||||||||||||||||||||||||||
| 120 | } | ||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||
| 122 | 8 | ▶ | sub identity { | ||||||||||||||||||||||||||
|
Subroutine
identity: called CC=7 SCAR=20.0
Pod
documented
| |||||||||||||||||||||||||||||
| 123 | 8 | my ($self, $identity, @tags) = @_; | |||||||||||||||||||||||||||
| 124 | 8 | ▶ | unless (ref($identity) eq 'ARRAY') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 125 | 8 | my $type; | |||||||||||||||||||||||||||
| 126 | 8 | ▶ | if (@tags) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 127 | 8 | $type = shift @tags; | |||||||||||||||||||||||||||
| 128 | } | ||||||||||||||||||||||||||||
| 129 | else { | ||||||||||||||||||||||||||||
| 130 | 0 | warn "Guessing identity type for $identity"; | |||||||||||||||||||||||||||
| 131 | 0 | $type = guess_identity_type($identity); | |||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | 8 | $identity = [ $identity, $type ]; | |||||||||||||||||||||||||||
| 134 | } | ||||||||||||||||||||||||||||
| 135 | 8 | ▶ | push(@$identity, @tags) if @tags; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 136 | 8 | for (@{ $self->{Identities} }) { | |||||||||||||||||||||||||||
| 137 | # If the data and the type match | ||||||||||||||||||||||||||||
| 138 | 6 | ▶ | if (($_->[0] eq $identity->[0]) && | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$_->[0] eq $identity->[0] and $_->[1] eq $identity->[1]
MC/DC50%1/2
$_->[0] eq $identity->[0] and $_->[1] eq $identity->[1]
$_->[0] eq $identity->[0]
$_->[1] eq $identity->[1]
Truth table66%2/3
A and B
A= $_->[0] eq $identity->[0]B= $_->[1] eq $identity->[1]
| |||||||||||||||||||||||||||||
| 139 | ($_->[1] eq $identity->[1])) { | ||||||||||||||||||||||||||||
| 140 | # Combine the tags from the new identity; | ||||||||||||||||||||||||||||
| 141 | 5 | shift @$identity; shift @$identity; | |||||||||||||||||||||||||||
| 142 | 5 | push(@{ $_ }, @$identity); | |||||||||||||||||||||||||||
| 143 | 5 | return; | |||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||
| 146 | 3 | push(@{ $self->{Identities} }, $identity); | |||||||||||||||||||||||||||
| 147 | } | ||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||
| 149 | 1 | ▶ | sub identities { | ||||||||||||||||||||||||||
|
Subroutine
identities: called CC=3 SCAR=13.1
Pod
documented
| |||||||||||||||||||||||||||||
| 150 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 151 | 1 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | $self->{Identities} = [ ]; | |||||||||||||||||||||||||||
| 153 | 0 | $self->identity($_) for @_; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | 1 | return $self->{Identities}; | |||||||||||||||||||||||||||
| 156 | } | ||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||
| 158 | 0 | ▶ | sub has_identities { | ||||||||||||||||||||||||||
|
Subroutine
has_identities: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 159 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 160 | 0 | ▶ | return undef unless exists $self->{Identities}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 161 | 0 | ▶ | return undef unless @{ $self->{Identities} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 162 | 0 | return 1; | |||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 0 | ▶ | sub composite { | ||||||||||||||||||||||||||
|
Subroutine
composite: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 166 | 0 | my ($self, @composites) = @_; | |||||||||||||||||||||||||||
| 167 | 0 | for my $composite (@composites) { | |||||||||||||||||||||||||||
| 168 | # Validate | ||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if (ref($composite)) { | ||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||
| 170 | 0 | die "Composite may not be a reference"; | |||||||||||||||||||||||||||
| 171 | } | ||||||||||||||||||||||||||||
| 172 | elsif ($composite =~ /^[0-9]+$/) { | ||||||||||||||||||||||||||||
| 173 | 0 | warn "Using numeric ids for composites should be avoided."; | |||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||
| 175 | elsif ($composite =~ /\./) { | ||||||||||||||||||||||||||||
| 176 | } | ||||||||||||||||||||||||||||
| 177 | else { | ||||||||||||||||||||||||||||
| 178 | 0 | warn "Composite name does not contain a dot. Invalid?"; | |||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||
| 180 | 0 | push(@{ $self->{Composites} }, $composite); | |||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||
| 184 | 0 | ▶ | sub composites { | ||||||||||||||||||||||||||
|
Subroutine
composites: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 185 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 186 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 187 | 0 | $self->{Composites} = [ ]; | |||||||||||||||||||||||||||
| 188 | 0 | $self->composite(@_); | |||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||
| 190 | 0 | return $self->{Composites}; | |||||||||||||||||||||||||||
| 191 | } | ||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||
| 193 | 0 | ▶ | sub has_composites { | ||||||||||||||||||||||||||
|
Subroutine
has_composites: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 194 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 195 | 0 | ▶ | return undef unless exists $self->{Composites}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 196 | 0 | ▶ | return undef unless @{ $self->{Composites} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 197 | 0 | return 1; | |||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||
| 200 | 3 | ▶ | sub feed { | ||||||||||||||||||||||||||
|
Subroutine
feed: called CC=2 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 201 | 3 | my ($self, @feeds) = @_; | |||||||||||||||||||||||||||
| 202 | 3 | for my $feed (@feeds) { | |||||||||||||||||||||||||||
| 203 | # Validate. | ||||||||||||||||||||||||||||
| 204 | # if ($feed =~ /^[0-9]+$/) { | ||||||||||||||||||||||||||||
| 205 | # warn "Numeric feed ids are deprecated."; | ||||||||||||||||||||||||||||
| 206 | # } | ||||||||||||||||||||||||||||
| 207 | 3 | push(@{ $self->{Feeds} }, $feed); | |||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||
| 211 | 0 | ▶ | sub feeds { | ||||||||||||||||||||||||||
|
Subroutine
feeds: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 212 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 213 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 214 | 0 | $self->{Feeds} = [ ]; | |||||||||||||||||||||||||||
| 215 | 0 | $self->feed(@_); | |||||||||||||||||||||||||||
| 216 | } | ||||||||||||||||||||||||||||
| 217 | 0 | return $self->{Feeds}; | |||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||
| 220 | 0 | ▶ | sub has_feeds { | ||||||||||||||||||||||||||
|
Subroutine
has_feeds: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 221 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 222 | 0 | ▶ | return undef unless exists $self->{Feeds}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 223 | 0 | ▶ | return undef unless @{ $self->{Feeds} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 224 | 0 | return 1; | |||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||
| 227 | 3 | ▶ | sub combiner { | ||||||||||||||||||||||||||
|
Subroutine
combiner: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||
| 228 | 3 | my ($self, @combiners) = @_; | |||||||||||||||||||||||||||
| 229 | 3 | for my $combiner (@combiners) { | |||||||||||||||||||||||||||
| 230 | # Validate. | ||||||||||||||||||||||||||||
| 231 | 3 | push(@{ $self->{Combiners} }, $combiner); | |||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||
| 235 | 0 | ▶ | sub combiners { | ||||||||||||||||||||||||||
|
Subroutine
combiners: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||
| 236 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 237 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 238 | 0 | $self->{Combiners} = [ ]; | |||||||||||||||||||||||||||
| 239 | 0 | $self->combiner(@_); | |||||||||||||||||||||||||||
| 240 | } | ||||||||||||||||||||||||||||
| 241 | 0 | return $self->{Combiners}; | |||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||
| 244 | 0 | ▶ | sub has_combiners { | ||||||||||||||||||||||||||
|
Subroutine
has_combiners: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 245 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 246 | 0 | ▶ | return undef unless exists $self->{Combiners}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 247 | 0 | ▶ | return undef unless @{ $self->{Combiners} }; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 248 | 0 | return 1; | |||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||
| 251 | 0 | ▶ | sub flags { | ||||||||||||||||||||||||||
|
Subroutine
flags: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||
| 252 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 253 | 0 | ▶ | if (@_) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 254 | 0 | my $flags = shift; | |||||||||||||||||||||||||||
| 255 | 0 | ▶ | die "Flags must be an integer" unless $flags =~ /^[0-9]+$/; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 256 | 0 | $self->{Flags} = $flags; | |||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||
| 258 | 0 | return $self->{Flags}; | |||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||
| 260 | |||||||||||||||||||||||||||||
| 261 | 0 | ▶ | sub has_flags { | ||||||||||||||||||||||||||
|
Subroutine
has_flags: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 262 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 263 | 0 | ▶ | return undef unless exists $self->{Flags}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 264 | 0 | ▶ | return undef unless defined $self->{Flags}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 265 | 0 | return 1; | |||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||
| 268 | 0 | ▶ | sub identities_as_humanreadable_string { | ||||||||||||||||||||||||||
|
Subroutine
identities_as_humanreadable_string: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 269 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 270 | 0 | ▶ | my @identities = @{ $self->{Identities} || [] }; | ||||||||||||||||||||||||||
|
Condition0%0/2
$self->{'Identities'} || []
MC/DC0%0/1
$self->{'Identities'} || []
$self->{'Identities'}
Truth table0%0/2
A
A= $self->{'Identities'}
| |||||||||||||||||||||||||||||
| 271 | 0 | ▶ | return join ",", (map { join "=", ($_->[1], $_->[0], ($_->[2] || ())) } @identities); | ||||||||||||||||||||||||||
|
Condition0%0/3
$_->[2] || ()
MC/DC0%0/2
$_->[2] || ()
$_->[2]
()
Truth table0%0/3
A || B
A= $_->[2]B= ()
| |||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||
| 273 | |||||||||||||||||||||||||||||
| 274 | 4 | ▶ | sub _as_string_sizeof { | ||||||||||||||||||||||||||
|
Subroutine
_as_string_sizeof: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||
| 275 | 4 | my $ref = shift; | |||||||||||||||||||||||||||
| 276 | 4 | ▶ | return "0" unless defined $ref; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 277 | 3 | return scalar(@$ref); | |||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||
| 280 | 1 | ▶ | sub as_string { | ||||||||||||||||||||||||||
|
Subroutine
as_string: called CC=7 SCAR=20.1
Pod
undocumented
| |||||||||||||||||||||||||||||
| 281 | 1 | my ($self) = @_; | |||||||||||||||||||||||||||
| 282 | 1 | my $out = "Query id '" . $self->id . "': "; | |||||||||||||||||||||||||||
| 283 | 1 | $out .= _as_string_sizeof($self->{Identities}) . ' identities, '; | |||||||||||||||||||||||||||
| 284 | 1 | $out .= _as_string_sizeof($self->{Feeds}) . ' feeds, '; | |||||||||||||||||||||||||||
| 285 | 1 | $out .= _as_string_sizeof($self->{Composites}) . " composites, "; | |||||||||||||||||||||||||||
| 286 | 1 | $out .= _as_string_sizeof($self->{Combiners}) . " combiners\n"; | |||||||||||||||||||||||||||
| 287 | 1 | ▶ | if ($self->{Identities}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 288 | 1 | for (@{ $self->{Identities} }) { | |||||||||||||||||||||||||||
| 289 | 1 | my ($id, $t, @t) = @$_; | |||||||||||||||||||||||||||
| 290 | 1 | $out .= "Identity: $id ($t)"; | |||||||||||||||||||||||||||
| 291 | 1 | ▶ | $out .= " (= @t)" if @t; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 292 | 1 | $out .= "\n"; | |||||||||||||||||||||||||||
| 293 | } | ||||||||||||||||||||||||||||
| 294 | } | ||||||||||||||||||||||||||||
| 295 | 1 | ▶ | if ($self->{Composites}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 296 | $out .= "Composites: " . | ||||||||||||||||||||||||||||
| 297 | 0 | join(' ', sort @{ $self->{Composites} } ) . | |||||||||||||||||||||||||||
| 298 | "\n"; | ||||||||||||||||||||||||||||
| 299 | } | ||||||||||||||||||||||||||||
| 300 | 1 | ▶ | if ($self->{Feeds}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 301 | $out .= "Feeds: " . | ||||||||||||||||||||||||||||
| 302 | 1 | join(' ', sort @{ $self->{Feeds} } ) . | |||||||||||||||||||||||||||
| 303 | "\n"; | ||||||||||||||||||||||||||||
| 304 | } | ||||||||||||||||||||||||||||
| 305 | 1 | ▶ | if ($self->{Combiners}) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 306 | $out .= "Combiners: " . | ||||||||||||||||||||||||||||
| 307 | 1 | join(' ', sort @{ $self->{Combiners} } ) . | |||||||||||||||||||||||||||
| 308 | "\n"; | ||||||||||||||||||||||||||||
| 309 | } | ||||||||||||||||||||||||||||
| 310 | 1 | return $out; | |||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||
| 313 | =head1 NAME | ||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||
| 315 | Mail::Karmasphere::Query - Karmasphere Query Object | ||||||||||||||||||||||||||||
| 316 | |||||||||||||||||||||||||||||
| 317 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||
| 319 | my $query = new Mail::Karmasphere::Query(...); | ||||||||||||||||||||||||||||
| 320 | |||||||||||||||||||||||||||||
| 321 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 322 | |||||||||||||||||||||||||||||
| 323 | The Perl Karma Client API consists of three objects: The Query, the | ||||||||||||||||||||||||||||
| 324 | Response and the Client. The user constructs a Query and passes it to | ||||||||||||||||||||||||||||
| 325 | a Client, which returns a Response. See L<Mail::Karmasphere::Client> | ||||||||||||||||||||||||||||
| 326 | for more information. | ||||||||||||||||||||||||||||
| 327 | |||||||||||||||||||||||||||||
| 328 | =head1 CONSTRUCTOR | ||||||||||||||||||||||||||||
| 329 | |||||||||||||||||||||||||||||
| 330 | The class method new(...) constructs a new Query object. All arguments | ||||||||||||||||||||||||||||
| 331 | are optional. The following parameters are recognised as arguments | ||||||||||||||||||||||||||||
| 332 | to new(): | ||||||||||||||||||||||||||||
| 333 | |||||||||||||||||||||||||||||
| 334 | =over 4 | ||||||||||||||||||||||||||||
| 335 | |||||||||||||||||||||||||||||
| 336 | =item Identities | ||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||
| 338 | A listref of identities, each of which is an [ identity, type ] pair. | ||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||
| 340 | =item Composites | ||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||
| 342 | A listref of composite keynames. | ||||||||||||||||||||||||||||
| 343 | |||||||||||||||||||||||||||||
| 344 | =item Composite | ||||||||||||||||||||||||||||
| 345 | |||||||||||||||||||||||||||||
| 346 | A single composite keyname. | ||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||
| 348 | =item Flags | ||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||
| 350 | The query flags. | ||||||||||||||||||||||||||||
| 351 | |||||||||||||||||||||||||||||
| 352 | =item Id | ||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||
| 354 | The id of this query, returned in the response. The id is autogenerated | ||||||||||||||||||||||||||||
| 355 | in a new query if not provided, and may be retrieved using $query->id. | ||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||
| 357 | =item Feeds | ||||||||||||||||||||||||||||
| 358 | |||||||||||||||||||||||||||||
| 359 | A listref of feed ids. | ||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||
| 361 | =item Combiners | ||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||
| 363 | A listref of combiner names. | ||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||
| 365 | =item Combiner | ||||||||||||||||||||||||||||
| 366 | |||||||||||||||||||||||||||||
| 367 | A single combiner name. | ||||||||||||||||||||||||||||
| 368 | |||||||||||||||||||||||||||||
| 369 | =back | ||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||
| 371 | =head1 METHODS | ||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||
| 373 | =head2 PRIMARY METHODS | ||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||
| 375 | These methods are the ones you must understand in order to use | ||||||||||||||||||||||||||||
| 376 | Mail::Karmashere::Client. | ||||||||||||||||||||||||||||
| 377 | |||||||||||||||||||||||||||||
| 378 | =over 4 | ||||||||||||||||||||||||||||
| 379 | |||||||||||||||||||||||||||||
| 380 | =item $query->identity($data, $type, @tags) | ||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||
| 382 | Adds an identity to this query. | ||||||||||||||||||||||||||||
| 383 | |||||||||||||||||||||||||||||
| 384 | =item $query->composite(@composites) | ||||||||||||||||||||||||||||
| 385 | |||||||||||||||||||||||||||||
| 386 | Adds one or more composites to this query. | ||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||
| 388 | =item $query->flags($flags) | ||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||
| 390 | Sets or returns the flags of this query. | ||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||
| 392 | =back | ||||||||||||||||||||||||||||
| 393 | |||||||||||||||||||||||||||||
| 394 | =head2 OTHER METHODS | ||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||
| 396 | These methods permit more flexibility and access to more features. | ||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||
| 398 | =over 4 | ||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||
| 400 | =item $query->id([$id]) | ||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||
| 402 | Sets or returns the id of this query. If the query has no id, an id | ||||||||||||||||||||||||||||
| 403 | will be generated by the client and will appear in the response. | ||||||||||||||||||||||||||||
| 404 | |||||||||||||||||||||||||||||
| 405 | =item $query->identities(@identities) | ||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||
| 407 | Sets or returns the identities of this query. | ||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||
| 409 | =item $query->composites(@composites) | ||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||
| 411 | Sets or returns the composites of this query. | ||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||
| 413 | =item $query->feeds(@feeds) | ||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||
| 415 | Sets or returns the feeds of this query. | ||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||
| 417 | =item $query->feeds(@feeds) | ||||||||||||||||||||||||||||
| 418 | |||||||||||||||||||||||||||||
| 419 | Adds a feed to this query. | ||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||
| 421 | =item $query->combiners(@combiners) | ||||||||||||||||||||||||||||
| 422 | |||||||||||||||||||||||||||||
| 423 | Sets or returns the combiners of this query. | ||||||||||||||||||||||||||||
| 424 | |||||||||||||||||||||||||||||
| 425 | =item $query->combiner(@combiners) | ||||||||||||||||||||||||||||
| 426 | |||||||||||||||||||||||||||||
| 427 | Adds combiners to this query. | ||||||||||||||||||||||||||||
| 428 | |||||||||||||||||||||||||||||
| 429 | =back | ||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||
| 431 | =head1 BUGS | ||||||||||||||||||||||||||||
| 432 | |||||||||||||||||||||||||||||
| 433 | This document is incomplete. | ||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||
| 435 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 436 | |||||||||||||||||||||||||||||
| 437 | L<Mail::Karmasphere::Client> | ||||||||||||||||||||||||||||
| 438 | L<Mail::Karmasphere::Response> | ||||||||||||||||||||||||||||
| 439 | http://www.karmasphere.com/ | ||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||
| 441 | =head1 COPYRIGHT | ||||||||||||||||||||||||||||
| 442 | |||||||||||||||||||||||||||||
| 443 | Copyright (c) 2005 Shevek, Karmasphere. All rights reserved. | ||||||||||||||||||||||||||||
| 444 | |||||||||||||||||||||||||||||
| 445 | This program is free software; you can redistribute it and/or modify | ||||||||||||||||||||||||||||
| 446 | it under the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 447 | |||||||||||||||||||||||||||||
| 448 | =cut | ||||||||||||||||||||||||||||
| 449 | |||||||||||||||||||||||||||||
| 450 | 5 | 1; | |||||||||||||||||||||||||||