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