line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: create App::Rssfilter objects from YAML configuration |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
19837
|
use strict; |
|
7
|
|
|
|
|
15
|
|
|
7
|
|
|
|
|
207
|
|
4
|
7
|
|
|
7
|
|
111
|
use warnings; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
355
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
package App::Rssfilter::FromYaml; |
8
|
|
|
|
|
|
|
$App::Rssfilter::FromYaml::VERSION = '0.08'; # TRIAL |
9
|
7
|
|
|
7
|
|
714
|
use Moo::Role; |
|
7
|
|
|
|
|
19710
|
|
|
7
|
|
|
|
|
47
|
|
10
|
7
|
|
|
7
|
|
20259
|
use Method::Signatures; |
|
7
|
|
|
|
|
60150
|
|
|
7
|
|
|
|
|
55
|
|
11
|
7
|
|
|
7
|
|
8566
|
use YAML::XS; |
|
7
|
|
|
|
|
20530
|
|
|
7
|
|
|
|
|
423
|
|
12
|
|
|
|
|
|
|
requires 'from_hash'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
15
|
7
|
50
|
|
7
|
|
149020
|
method from_yaml( $config ) { |
|
1
|
50
|
|
1
|
|
66254
|
|
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
4
|
|
16
|
1
|
|
|
|
|
98
|
$self->from_hash( Load( $config ) ); |
17
|
|
|
|
|
|
|
} |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
1; |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
__END__ |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=pod |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=encoding UTF-8 |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head1 NAME |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
App::Rssfilter::FromYaml - create App::Rssfilter objects from YAML configuration |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 VERSION |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
version 0.08 |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
{ |
38
|
|
|
|
|
|
|
package Cool::Name; |
39
|
|
|
|
|
|
|
use Role::Tiny::With; |
40
|
|
|
|
|
|
|
with 'App::Rssfilter::FromYaml'; |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
sub new { ... } |
43
|
|
|
|
|
|
|
sub add_group { ... } |
44
|
|
|
|
|
|
|
sub add_feed { ... } |
45
|
|
|
|
|
|
|
sub add_rule { ... } |
46
|
|
|
|
|
|
|
}; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
my $cool_name = Cool::Name->from_yaml(<<"End_Of_Yaml"); |
50
|
|
|
|
|
|
|
name: some group |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
rules: |
53
|
|
|
|
|
|
|
# add_rule will be called with ... |
54
|
|
|
|
|
|
|
- keyvalue_pair: some value |
55
|
|
|
|
|
|
|
# then ... |
56
|
|
|
|
|
|
|
- this_hashref: of options |
57
|
|
|
|
|
|
|
with_multiple: keys and values |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
feeds: |
60
|
|
|
|
|
|
|
# same as rules above |
61
|
|
|
|
|
|
|
# mix elements as you please |
62
|
|
|
|
|
|
|
- keyword_pair_for_first_feed: and value |
63
|
|
|
|
|
|
|
- keyword_pair_for_second_feed: with different value |
64
|
|
|
|
|
|
|
- feed_option1: more key-value pairs |
65
|
|
|
|
|
|
|
feed_option2: which will be passed as arguments |
66
|
|
|
|
|
|
|
feed_option3: for the third call to add_feed |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
groups: |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
- name: a subgroup |
71
|
|
|
|
|
|
|
- # subgroups can have their own feeds, rules, and subgroups |
72
|
|
|
|
|
|
|
- feeds: |
73
|
|
|
|
|
|
|
- ... |
74
|
|
|
|
|
|
|
- rules: |
75
|
|
|
|
|
|
|
- ... |
76
|
|
|
|
|
|
|
- groups: |
77
|
|
|
|
|
|
|
- ... |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
- name: 'another subgroup', |
80
|
|
|
|
|
|
|
- feeds: |
81
|
|
|
|
|
|
|
- ... |
82
|
|
|
|
|
|
|
- rules: |
83
|
|
|
|
|
|
|
- ... |
84
|
|
|
|
|
|
|
- groups: |
85
|
|
|
|
|
|
|
- ... |
86
|
|
|
|
|
|
|
End_Of_Yaml |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
=head1 DESCRIPTION |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
This role will extend its receiving class with a L</from_yaml> method. It requires that the receiver has C<add_group>, C<add_feed>, and C<add_rule> methods, and accepts a C<name> attribute to its constructor. |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head1 METHODS |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
=head2 from_yaml |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
my $receiver_instance = Receiver::Class->from_yaml( $config ); |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
Create a new instance of the receiving class (using the top-level C<name> in C<$config> as its name), then create subgroups and add feeds or rules to it (or its subgroups). |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
C<$config> may have four keys: |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=over 4 |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=item * |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
C<name> - name of this group |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
=item * |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
C<groups> - list of associative arrays for subgroups, same schema as the original config |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
=item * |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
C<feeds> - list of feeds to fetch |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
=item * |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
C<rules> - list of rules to apply |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
=back |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHOR |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Daniel Holz <dgholz@gmail.com> |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
This software is copyright (c) 2015 by Daniel Holz. |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
131
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
132
|
|
|
|
|
|
|
|
133
|
|
|
|
|
|
|
=cut |