| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Document::Transform::Role::Transformer; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
2
|
|
|
2
|
|
1983
|
$Document::Transform::Role::Transformer::VERSION = '1.110530'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
#ABSTRACT: Provides an interface role for Transformers implementations |
|
7
|
|
|
|
|
|
|
|
|
8
|
2
|
|
|
2
|
|
871
|
use Moose::Role; |
|
|
2
|
|
|
|
|
5328
|
|
|
|
2
|
|
|
|
|
20
|
|
|
9
|
2
|
|
|
2
|
|
11851
|
use namespace::autoclean; |
|
|
2
|
|
|
|
|
7
|
|
|
|
2
|
|
|
|
|
26
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
requires qw/ transform document_constraint transform_constraint /; |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
1; |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=pod |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head1 NAME |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
Document::Transform::Role::Transformer - Provides an interface role for Transformers implementations |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 VERSION |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
version 1.110530 |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
package MyTransformer; |
|
32
|
|
|
|
|
|
|
use Moose; |
|
33
|
|
|
|
|
|
|
use MooseX::Params::Validate; |
|
34
|
|
|
|
|
|
|
use MooseX::Types::Moose(':all'); |
|
35
|
|
|
|
|
|
|
use MyTypeLib(':all'); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
sub document_constraint |
|
38
|
|
|
|
|
|
|
{ |
|
39
|
|
|
|
|
|
|
return Document; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub transform_constraint |
|
43
|
|
|
|
|
|
|
{ |
|
44
|
|
|
|
|
|
|
return Transform; |
|
45
|
|
|
|
|
|
|
} |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub transform |
|
48
|
|
|
|
|
|
|
{ |
|
49
|
|
|
|
|
|
|
my $self = shift; |
|
50
|
|
|
|
|
|
|
my ($doc, $transforms) = validated_list |
|
51
|
|
|
|
|
|
|
( |
|
52
|
|
|
|
|
|
|
\@_, |
|
53
|
|
|
|
|
|
|
{isa => $self->document_constraint}, |
|
54
|
|
|
|
|
|
|
{isa => ArrayRef[$self->transform_constraint]}, |
|
55
|
|
|
|
|
|
|
); |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
#Do transforms here and return document |
|
58
|
|
|
|
|
|
|
} |
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
with 'Document::Transform::Role::Transformer'; |
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
Want to implement your own transformer and feed it directly to |
|
66
|
|
|
|
|
|
|
L<Document::Transform>? Then this is your role. |
|
67
|
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
Simply implement a suitable transform method along with the constraint methods |
|
69
|
|
|
|
|
|
|
or attributes and consume the role. |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 ROLE_REQUIRES |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
=head2 transform |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This role requires that you provide the transform method. If merely |
|
76
|
|
|
|
|
|
|
substituting your own Transformer implementation, transform will need to take |
|
77
|
|
|
|
|
|
|
two arguments, a Document structure and an arrayref of Transform structures |
|
78
|
|
|
|
|
|
|
with the expectation that the operations contained with in each Transform are |
|
79
|
|
|
|
|
|
|
executed against the Document, and the result returned. The type constraints |
|
80
|
|
|
|
|
|
|
for Document and Transform are provided in the L</document_constraint> and |
|
81
|
|
|
|
|
|
|
L</transform_constrant> attributes or methods |
|
82
|
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
=head2 document_constraint |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
In order to constrain the Document appropriately, this attribute or method must |
|
86
|
|
|
|
|
|
|
be implemented and must return a L<Moose::Meta::TypeConstraint>. |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head2 transform_constraint |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
In order to constrain the Transform appropriately, this attribute or method |
|
91
|
|
|
|
|
|
|
must be implemented and must return a L<Moose::Meta::TypeConstraint>. |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Nicholas R. Perez <nperez@cpan.org> |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
This software is copyright (c) 2010 by Infinity Interactive. |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
102
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
103
|
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=cut |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
__END__ |
|
108
|
|
|
|
|
|
|
|