1 package WWW
::Mechanize
::Script
::Plugin
;
6 # ABSTRACT: plugin base class for check plugins
8 our $VERSION = '0.001_003';
14 Instantiates new WWW
::Mechanize
::Script
::Plugin
. This is an abstract
class.
22 my $self = bless( {}, $class );
27 =method get_check_value
(\
%check,$value_name)
29 Retrieves the value
for I
<$value_name> from the hash I
<%check>.
35 my ( $self, $check, $value_name ) = @_;
37 $value_name or return;
39 return $check->{check
}->{$value_name};
42 =method get_check_value_as_bool
(\
%check,$value_name)
44 Retrieves the value
for I
<$value_name> from the hash I
<%check> and returns
45 true
when it can be interpreted as a boolean value with true content
46 (any object is always returned as it is
, (?
:(?i
)true
|on
|yes
) evaluates to
47 I
<true
>, anything
else to I
<false
>).
51 sub get_check_value_as_bool
53 my ( $self, $check, $value_name ) = @_;
55 $value_name or return;
57 my $val = $check->{check
}->{$value_name};
59 defined($val) or return;
60 ref($val) and return $val;
63 $val =~ m/(?:true|on|yes)/i and return 1;
69 =method can_check
(\
%check)
71 Proves whether this instance can check anything on the current run test
.
72 Looks
if any of the required L
</check_value_names
> are specified
in the
73 check parameters of the current test
.
79 my ( $self, $check ) = @_;
82 my @value_names = $self->check_value_names();
83 foreach my $value_name (@value_names)
85 my $cv = $self->get_check_value( $check, $value_name );
86 $cv and $ok = 1 and last;
93 =method check_value_names
()
95 Returns list of check
values which are used to check the response
.
97 Each I
<value
> has a I
<value
>C
<_code
> counterpart which is used to modify
98 the
return value of L
</check_response
> when the check upon that value
103 sub check_value_names
{ ... }
105 =method check_response
(\
%check,$mech)
107 Checks the response based on test specifications
. See individual plugins
108 for specific test information
.
110 Returns the accumulated code
for each failing check along with optional
111 messages containing details about
each failure
.
116 return ($code,@messages);
117 # some error but no details
122 sub check_response
{ ... }