[libcatmandu-perl] 38/46: More elaborate examples how to create any_* , all-* conditionals

Jonas Smedegaard dr at jones.dk
Tue Oct 14 13:52:54 UTC 2014


This is an automated email from the git hooks/post-receive script.

js pushed a commit to tag 0.9205
in repository libcatmandu-perl.

commit 894daad174ad180ab319f8c7b7e45e4ea585d5fc
Author: Patrick Hochstenbach <patrick.hochstenbach at ugent.be>
Date:   Fri Oct 3 10:58:21 2014 +0200

    More elaborate examples how to create any_* , all-* conditionals
---
 lib/Catmandu/Fix/Condition/SimpleAllTest.pm | 45 +++++++++++++++++++++++++++++
 lib/Catmandu/Fix/Condition/SimpleAnyTest.pm | 43 +++++++++++++++++++++++++++
 2 files changed, 88 insertions(+)

diff --git a/lib/Catmandu/Fix/Condition/SimpleAllTest.pm b/lib/Catmandu/Fix/Condition/SimpleAllTest.pm
index fe77144..d8f238a 100644
--- a/lib/Catmandu/Fix/Condition/SimpleAllTest.pm
+++ b/lib/Catmandu/Fix/Condition/SimpleAllTest.pm
@@ -1,5 +1,50 @@
 package Catmandu::Fix::Condition::SimpleAllTest;
 
+=head1 NAME
+
+Catmandu::Fix::Condition::SimpleAllTest - Base class to ease the construction of all match conditionals
+
+=head1 SYNOPSIS
+
+   package Catmandu::Fix::Condition::is_even
+
+   use Catmandu::Sane;
+   use Moo;
+   use Catmandu::Fix::Has;
+
+   has path    => (fix_arg => 1);
+
+   with 'Catmandu::Fix::Condition::SimpleAllTest';
+ 
+   sub emit_test {
+       my ($self, $var) = @_;
+       my $value = $self->value;
+       "is_value(${var}) && ${var} % 2 == 0";
+   }
+
+   1;
+
+   # Now you can write in your fixes
+   is_even('my_field')    # True when my_field is 0,2,4,6,...
+   is_even('my_field.*')  # True when all my_field's are 0,2,4,6,...
+
+=head1 DESCRIPTION
+
+The is a base class to ease the construction of Catmandu::Fix::Conditional-s. An 'all' test matches
+when all node on a path match a condition. E.g.
+
+   all_match('title','abc')    # true when the title field contains 'abc'
+
+   all_match('title.*','abc')  # true when all title fields contain 'abc'
+
+=head1 SEE ALSO
+
+L<Catmandu::Fix::Condition::all_match>,
+L<Catmandu::Fix::Condition::greater_than>,
+L<Catmandu::Fix::Condition::less_than>
+
+=cut
+
 use Catmandu::Sane;
 use Moo::Role;
 
diff --git a/lib/Catmandu/Fix/Condition/SimpleAnyTest.pm b/lib/Catmandu/Fix/Condition/SimpleAnyTest.pm
index 1dc5788..3deaf65 100644
--- a/lib/Catmandu/Fix/Condition/SimpleAnyTest.pm
+++ b/lib/Catmandu/Fix/Condition/SimpleAnyTest.pm
@@ -1,5 +1,48 @@
 package Catmandu::Fix::Condition::SimpleAnyTest;
 
+=head1 NAME
+
+Catmandu::Fix::Condition::SimpleAllTest - Base class to ease the construction of any match conditionals
+
+=head1 SYNOPSIS
+
+   package Catmandu::Fix::Condition::has_even
+
+   use Catmandu::Sane;
+   use Moo;
+   use Catmandu::Fix::Has;
+
+   has path    => (fix_arg => 1);
+
+   with 'Catmandu::Fix::Condition::SimpleAnyTest';
+ 
+   sub emit_test {
+       my ($self, $var) = @_;
+       my $value = $self->value;
+       "is_value(${var}) && ${var} % 2 == 0";
+   }
+
+   1;
+
+   # Now you can write in your fixes
+   has_even('my_field')    # True when my_field is 0,2,4,6,...
+   has_even('my_field.*')  # True when at least one my_field is 0,2,4,6,...
+
+=head1 DESCRIPTION
+
+The is a base class to ease the construction of Catmandu::Fix::Conditional-s. An 'any' test matches
+when at least one node on a path match a condition. E.g.
+
+   any_match('title','abc')    # true when the title field contains 'abc'
+
+   any_match('title.*','abc')  # true when at least one title fields contain 'abc'
+
+=head1 SEE ALSO
+
+L<Catmandu::Fix::Condition::any_match>
+
+=cut
+
 use Catmandu::Sane;
 use Moo::Role;
 

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libcatmandu-perl.git



More information about the Pkg-perl-cvs-commits mailing list