| 1 | package Debian::DEP12::ValidationWarning; | ||
| 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 | |||
| 6 | # ABSTRACT: validaton warning class | ||
| 7 | 5 | our $VERSION = '0.2.0'; # VERSION | |
| 8 | |||
| 9 | 5 | ▶ | use parent 'Text::BibTeX::Validate::Warning'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | =head1 NAME | ||
| 12 | |||
| 13 | Debian::DEP12::ValidationWarning - validaton warning class | ||
| 14 | |||
| 15 | =head1 SYNOPSIS | ||
| 16 | |||
| 17 | use Debian::DEP12::ValidationWarning; | ||
| 18 | |||
| 19 | my $warning = Debian::DEP12::ValidationWarning->new( | ||
| 20 | 'value \'%(value)s\' is better written as \'%(suggestion)s\'', | ||
| 21 | { | ||
| 22 | field => 'Bug-Submit', | ||
| 23 | value => 'merkys@cpan.org', | ||
| 24 | suggestion => 'mailto:merkys@cpan.org', | ||
| 25 | } | ||
| 26 | ); | ||
| 27 | print STDERR "$warning\n"; | ||
| 28 | |||
| 29 | =head1 DESCRIPTION | ||
| 30 | |||
| 31 | Debian::DEP12::ValidationWarning is used to store the content of | ||
| 32 | validation warning in a structured way. Currently the class is based on | ||
| 33 | L<Text::BibTeX::Validate::Warning|Text::BibTeX::Validate::Warning>, but | ||
| 34 | may be decoupled in the future. | ||
| 35 | |||
| 36 | =head1 METHODS | ||
| 37 | |||
| 38 | =head2 new( $message, $fields ) | ||
| 39 | |||
| 40 | Takes L<Text::sprintfn|Text::sprintfn>-compatible template and a hash | ||
| 41 | with the values for replacement in the template. Three field names are | ||
| 42 | reserved and used as prefixes for messages if defined: C<file> for the | ||
| 43 | name of a file, C<key> for the index inside list and C<field> for DEP12 | ||
| 44 | field name. Field C<suggestion> is also somewhat special, as | ||
| 45 | L<Debian::DEP12|Debian::DEP12> may use its value to replace the original | ||
| 46 | in an attempt to clean up the DEP12 entry. | ||
| 47 | |||
| 48 | =head2 fields() | ||
| 49 | |||
| 50 | Returns an array of fields defined in the instance in any order. | ||
| 51 | |||
| 52 | =head2 get( $field ) | ||
| 53 | |||
| 54 | Returns value of a field. | ||
| 55 | |||
| 56 | =head2 set( $field, $value ) | ||
| 57 | |||
| 58 | Sets a new value for a field. Returns the old value. | ||
| 59 | |||
| 60 | =head2 delete( $field ) | ||
| 61 | |||
| 62 | Unsets value for a field. Returns the old value. | ||
| 63 | |||
| 64 | =head1 AUTHORS | ||
| 65 | |||
| 66 | Andrius Merkys, E<lt>merkys@cpan.orgE<gt> | ||
| 67 | |||
| 68 | =cut | ||
| 69 | |||
| 70 | 5 | 1; | |