File Coverage

blib/lib/HTML/FillInForm/Lite/Compat.pm
Criterion Covered Total %
statement 33 33 100.0
branch 14 14 100.0
condition 21 21 100.0
subroutine 6 6 100.0
pod 2 2 100.0
total 76 76 100.0


line stmt bran cond sub pod time code
1             package HTML::FillInForm::Lite::Compat;
2              
3 1     1   25219 use strict;
  1         2  
  1         40  
4 1     1   6 use warnings;
  1         1  
  1         42  
5              
6             our $VERSION = '1.13';
7              
8 1     1   541 use HTML::FillInForm::Lite;
  1         2  
  1         174  
9             our @ISA = qw(HTML::FillInForm::Lite);
10              
11             $INC{'HTML/FillInForm.pm'} ||= __FILE__;
12             push @HTML::FillInForm::ISA, __PACKAGE__
13             unless HTML::FillInForm->isa(__PACKAGE__);
14              
15             my %known_keys = (
16             scalarref => 1,
17             arrayref => 1,
18             fdat => 1,
19             fobject => 1,
20             file => 1,
21             target => 1,
22             fill_password => 1,
23             ignore_fields => 1,
24             disable_fields => 1,
25             );
26              
27             my %extended_keys = (
28             escape => 1,
29             decode_entity => 1,
30             layer => 1,
31             );
32              
33             @known_keys{keys %extended_keys} = ();
34              
35             BEGIN{
36 1     1   3 *fill_file = \&fill;
37 1         2 *fill_arrayref = \&fill;
38 1         302 *fill_scalarref = \&fill;
39             }
40              
41             sub new{
42 13     13 1 14731 my $class = shift;
43              
44 13 100       55 if(@_){
45 1         355 warnings::warnif(portable =>
46             qq{$class->new() accepts no options, }
47             . q{use HTML::FillInForm::Lite->new(...) instead});
48             }
49              
50 12         65 return $class->SUPER::new();
51             }
52              
53             sub fill{
54 29     29 1 13715 my $self = shift;
55              
56 29         51 my $source;
57             my $data;
58              
59 29 100 100     200 if (defined $_[0] and not exists $known_keys{ $_[0] }){
60 15         23 $source = shift;
61             }
62              
63 29 100 100     152 if (defined $_[0] and not exists $known_keys{ $_[0] }){
64 10         25 $data = shift;
65             }
66              
67 29         81 my %option = @_;
68              
69 29         84 foreach my $key(keys %option){
70 32 100       102 if(exists $extended_keys{$key}){
71 2         405 warnings::warnif(portable => qq{HTML::FillInForm::Lite-specific option "$key" supplied});
72             }
73             }
74              
75 28   100     171 $source ||= $option{file} || $option{scalarref} || $option{arrayref};
      100        
76 28   100     118 $data ||= $option{fdat} || $option{fobject};
      100        
77              
78             # ensure to delete all sources and data
79 28         79 delete @option{qw(scalarref arrayref file fdat fobject)};
80              
81 28 100       105 $option{fill_password} = 1
82             unless defined $option{fill_password};
83 28 100       81 $option{decode_entity} = 1
84             unless defined $option{decode_entity};
85              
86 28 100 100     85 $option{ignore_fields} = [ $option{ignore_fields} ]
87             if defined $option{ignore_fields}
88             and ref $option{ignore_fields} ne 'ARRAY';
89              
90 28         151 return $self->SUPER::fill($source, $data, %option);
91             }
92              
93             1;
94              
95             __END__