Changeset 8023 for lang/perl/App-MadEye
- Timestamp:
- 03/17/08 13:18:20 (8 months ago)
- Location:
- lang/perl/App-MadEye/trunk/lib/App/MadEye
- Files:
-
- 3 modified
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Base.pm
r8011 r8023 3 3 use warnings; 4 4 use base qw/Class::Component::Plugin/; 5 use App::MadEye::Util qw/get_schema_from_pod/; 5 6 use Kwalify (); 6 use Pod::POM ();7 use List::Util qw/first/;8 use YAML ();9 7 10 8 sub new { … … 12 10 my $self = $class->SUPER::new(@_); 13 11 14 my $parser = Pod::POM->new; 15 my $pom = $parser->parse(Class::Inspector->resolved_filename($class)); 16 if (my $schema_node = first { $_->title eq 'SCHEMA' } $pom->head1) { 17 my $schema_content = $schema_node->content; 18 $schema_content =~ s/^ //gm; 19 my $schema = YAML::Load($schema_content); 20 12 if (my $schema = get_schema_from_pod($self)) { 21 13 Kwalify::validate($schema, $self->config->{config}); 22 14 } -
lang/perl/App-MadEye/trunk/lib/App/MadEye/Rule.pm
r7563 r8023 2 2 use strict; 3 3 use warnings; 4 use App::MadEye::Util qw/get_schema_from_pod/; 5 use Kwalify (); 4 6 5 7 sub new { 6 8 my ($class, $config) = @_; 7 9 $config ||= {}; 10 if (my $schema = get_schema_from_pod($class)) { 11 Kwalify::validate($schema, $config); 12 } 8 13 bless {config => $config}, $class; 9 14 } -
lang/perl/App-MadEye/trunk/lib/App/MadEye/Util.pm
r8015 r8023 4 4 use base qw/Exporter/; 5 5 6 our @EXPORT = qw/timeout log_stopwatch /;6 our @EXPORT = qw/timeout log_stopwatch get_schema_from_pod/; 7 7 8 8 use Sys::Syslog qw/:DEFAULT/; 9 use Pod::POM (); 10 use List::Util qw/first/; 11 use YAML (); 9 12 10 13 sub timeout($$&) { ## no critic. … … 37 40 } 38 41 42 sub get_schema_from_pod { 43 my $target = shift; 44 my $proto = ref $target || $target; 45 46 my $parser = Pod::POM->new; 47 my $pom = $parser->parse(Class::Inspector->resolved_filename($proto)); 48 if (my $schema_node = first { $_->title eq 'SCHEMA' } $pom->head1) { 49 my $schema_content = $schema_node->content; 50 $schema_content =~ s/^ //gm; 51 my $schema = YAML::Load($schema_content); 52 return $schema; 53 } else { 54 return; # 404 schema not found. 55 } 56 } 57 39 58 1;
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)