File Coverage

blib/lib/Data/Validate/WithYAML/Plugin/NoSpam.pm
Criterion Covered Total %
statement 9 15 60.0
branch 0 6 0.0
condition n/a
subroutine 3 4 75.0
pod 1 1 100.0
total 13 26 50.0


line stmt bran cond sub pod time code
1             package Data::Validate::WithYAML::Plugin::NoSpam;
2              
3 2     2   2258833 use warnings;
  2         5  
  2         65  
4 2     2   12 use strict;
  2         5  
  2         64  
5              
6 2     2   48 use Carp;
  2         15  
  2         619  
7              
8             # ABSTRACT: Plugin to check that a given text is no spam.
9              
10             our $VERSION = '0.02';
11              
12              
13             sub check {
14 0     0 1   my ($class, $value) = @_;
15            
16 0 0         croak "no value to check" unless defined $value;
17            
18 0 0         if ( $value =~ /(?:\[url|<a href)/ ) {
    0          
19 0           return 0;
20             }
21             elsif ( $value =~ /viagra|cialis/i ) {
22 0           return 0;
23             }
24            
25 0           return 1;
26             }
27              
28              
29             1; # End of Data::Validate::WithYAML::Plugin::NoSpam
30              
31             __END__
32             =pod
33              
34             =head1 NAME
35              
36             Data::Validate::WithYAML::Plugin::NoSpam - Plugin to check that a given text is no spam.
37              
38             =head1 VERSION
39              
40             version 0.02
41              
42             =head1 SYNOPSIS
43              
44             The check is done with heuristics. It checks that there are no
45             <a href="..."> or [url=""] tags in the text...
46              
47             use Data::Validate::WithYAML::Plugin::NoSpam;
48              
49             my $foo = Data::Validate::WithYAML::Plugin::NoSpam->check(
50             'This is a <a href="anything">Spam-Link</a>',
51             );
52             ...
53            
54             # use the plugin via Data::Validate::WithYAML
55            
56             use Data::Validate::WithYAML;
57            
58             my $text = 'This is a <a href="anything">Spam-Link</a>';
59             my $validator = Data::Validate::WithYAML->new( 'test.yml' );
60             print "yes" if $validator->check( 'textfield', $text );
61              
62             test.yml
63              
64             ---
65             step1:
66             textfield:
67             plugin: NoSpam
68             type: required
69              
70             =head1 SUBROUTINES
71              
72             =head2 check
73              
74             =head1 AUTHOR
75              
76             Renee Baecker, C<< <module at renee-baecker.de> >>
77              
78             =head1 BUGS
79              
80             Please report any bugs or feature requests to
81             C<bug-data-validate-withyaml-plugin-NoSpam at rt.cpan.org>, or through the web interface at
82             L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Data-Validate-WithYAML-Plugin-NoSpam>.
83             I will be notified, and then you'll automatically be notified of progress on
84             your bug as I make changes.
85              
86             =head1 SUPPORT
87              
88             You can find documentation for this module with the perldoc command.
89              
90             perldoc Data::Validate::WithYAML::Plugin::NoSpam
91              
92             You can also look for information at:
93              
94             =over 4
95              
96             =item * AnnoCPAN: Annotated CPAN documentation
97              
98             L<http://annocpan.org/dist/Data::Validate::WithYAML::Plugin::NoSpam>
99              
100             =item * CPAN Ratings
101              
102             L<http://cpanratings.perl.org/d/Data::Validate::WithYAML::Plugin::NoSpam>
103              
104             =item * RT: CPAN's request tracker
105              
106             L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Data::Validate::WithYAML::Plugin::NoSpam>
107              
108             =item * Search CPAN
109              
110             L<http://search.cpan.org/dist/Data::Validate::WithYAML::Plugin::NoSpam>
111              
112             =back
113              
114             =head1 ACKNOWLEDGEMENTS
115              
116             =head1 COPYRIGHT & LICENSE
117              
118             Copyright 2007 Renee Baecker, all rights reserved.
119              
120             This program is free software; you can redistribute it and/or modify it
121             under the same terms as Perl itself.
122              
123             =head1 AUTHOR
124              
125             Renee Baecker <module@renee-baecker.de>
126              
127             =head1 COPYRIGHT AND LICENSE
128              
129             This software is Copyright (c) 2012 by Renee Baecker.
130              
131             This is free software, licensed under:
132              
133             The Artistic License 2.0 (GPL Compatible)
134              
135             =cut
136