| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Net::Gnats::Command::INPUTDEFAULT; | 
| 2 | 40 |  |  | 40 |  | 204 | use parent 'Net::Gnats::Command'; | 
|  | 40 |  |  |  |  | 77 |  | 
|  | 40 |  |  |  |  | 212 |  | 
| 3 | 40 |  |  | 40 |  | 2276 | use strictures; | 
|  | 40 |  |  |  |  | 77 |  | 
|  | 40 |  |  |  |  | 227 |  | 
| 4 |  |  |  |  |  |  | BEGIN { | 
| 5 | 40 |  |  | 40 |  | 9012 | $Net::Gnats::Command::INPUTDEFAULT::VERSION = '0.22'; | 
| 6 |  |  |  |  |  |  | } | 
| 7 | 40 |  |  | 40 |  | 220 | use vars qw($VERSION); | 
|  | 40 |  |  |  |  | 80 |  | 
|  | 40 |  |  |  |  | 1688 |  | 
| 8 |  |  |  |  |  |  |  | 
| 9 | 40 |  |  | 40 |  | 214 | use Net::Gnats::Constants qw(CODE_INFORMATION CODE_INVALID_FIELD_NAME); | 
|  | 40 |  |  |  |  | 83 |  | 
|  | 40 |  |  |  |  | 13242 |  | 
| 10 |  |  |  |  |  |  |  | 
| 11 |  |  |  |  |  |  | =head1 NAME | 
| 12 |  |  |  |  |  |  |  | 
| 13 |  |  |  |  |  |  | Net::Gnats::Command::INPUTDEFAULT | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | Like the FDSC and FTYP commands, multiple field names may be listed | 
| 18 |  |  |  |  |  |  | with the command, and a response line will be returned for each one | 
| 19 |  |  |  |  |  |  | in the order that the fields appear on the command line. | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | =head1 PROTOCOL | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | INPUTDEFAULT [fields...] | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | =head1 RESPONSES | 
| 26 |  |  |  |  |  |  |  | 
| 27 |  |  |  |  |  |  | Returns the suggested default value for a field when a PR is | 
| 28 |  |  |  |  |  |  | initially created. The possible responses are either 410 | 
| 29 |  |  |  |  |  |  | (CODE_INVALID_FIELD_NAME), meaning that the specified field is | 
| 30 |  |  |  |  |  |  | invalid or nonexistent, or 350 (CODE_INFORMATION) which contains the | 
| 31 |  |  |  |  |  |  | default value for the field. | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | =cut | 
| 34 |  |  |  |  |  |  |  | 
| 35 |  |  |  |  |  |  | my $c = 'INPUTDEFAULT'; | 
| 36 |  |  |  |  |  |  |  | 
| 37 |  |  |  |  |  |  | sub new { | 
| 38 | 41 |  |  | 41 | 1 | 154 | my ( $class, %options ) = @_; | 
| 39 |  |  |  |  |  |  |  | 
| 40 | 41 |  |  |  |  | 108 | my $self = bless \%options, $class; | 
| 41 | 41 |  |  |  |  | 213 | $self->{requests_multi} = 0; | 
| 42 | 41 | 100 |  |  |  | 199 | return $self if not defined $self->{fields}; | 
| 43 |  |  |  |  |  |  |  | 
| 44 | 40 | 50 |  |  |  | 207 | if (ref $self->{fields} eq 'ARRAY') { | 
| 45 | 40 | 100 |  |  |  | 80 | $self->{requests_multi} = 1 if scalar @{ $self->{fields} } > 1; | 
|  | 40 |  |  |  |  | 232 |  | 
| 46 |  |  |  |  |  |  | } | 
| 47 |  |  |  |  |  |  | else { | 
| 48 | 0 |  |  |  |  | 0 | $self->{fields} = [ $self->{fields} ]; | 
| 49 |  |  |  |  |  |  | } | 
| 50 | 40 |  |  |  |  | 146 | return $self; | 
| 51 |  |  |  |  |  |  | } | 
| 52 |  |  |  |  |  |  |  | 
| 53 |  |  |  |  |  |  | sub as_string { | 
| 54 | 85 |  |  | 85 | 1 | 169 | my ($self) = @_; | 
| 55 | 85 | 100 |  |  |  | 306 | return undef if not defined $self->{fields}; | 
| 56 | 84 |  |  |  |  | 192 | return $c . ' ' . join ( ' ', @{$self->{fields}} ); | 
|  | 84 |  |  |  |  | 601 |  | 
| 57 |  |  |  |  |  |  | } | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | # this command can take multiple fields, each getting their own response. | 
| 60 |  |  |  |  |  |  | # so, we check that 'everything' is okay by looking at the parent response. | 
| 61 |  |  |  |  |  |  | sub is_ok { | 
| 62 | 3 |  |  | 3 | 0 | 7 | my $self = shift; | 
| 63 | 3 | 100 |  |  |  | 8 | return 0 if not defined $self->response; | 
| 64 | 2 | 100 | 66 |  |  | 10 | if ( $self->{requests_multi} == 0 and | 
| 65 |  |  |  |  |  |  | $self->response->code == CODE_INFORMATION) { | 
| 66 | 1 |  |  |  |  | 4 | return 1; | 
| 67 |  |  |  |  |  |  | } | 
| 68 | 1 | 50 |  |  |  | 4 | return 1 if $self->response->code == CODE_INFORMATION; | 
| 69 | 0 |  |  |  |  |  | return 0; | 
| 70 |  |  |  |  |  |  | } | 
| 71 |  |  |  |  |  |  |  | 
| 72 |  |  |  |  |  |  | 1; |