Changeset 1828
- Timestamp:
- 11/10/06 19:12:02
- Files:
-
- trunk/plagger/lib/Plagger/Plugin/CustomFeed/Debug.pm (modified) (1 diff)
- trunk/plagger/t/plugins/CustomFeed-Debug/test.t (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/plagger/lib/Plagger/Plugin/CustomFeed/Debug.pm
r1473 r1828 27 27 $feed->type('debug'); 28 28 for (keys %{$self->conf}) { 29 next if $_ eq 'entry' ;29 next if $_ eq 'entry' || $_ eq 'entries'; 30 30 $feed->$_($self->conf->{$_}); 31 31 } 32 32 33 for my $entry_conf (@{ $self->conf->{entry}}) {33 for my $entry_conf (@{ $self->conf->{entry} || $self->conf->{entries} || [] }) { 34 34 my $entry = Plagger::Entry->new; 35 $entry->$_($entry_conf->{$_}) for keys %$entry_conf; 35 for my $method (keys %$entry_conf) { 36 next if $method eq 'enclosure'; 37 $entry->$method($entry_conf->{$method}); 38 } 36 39 $feed->add_entry($entry); 37 40 38 41 # enclosure 39 for my $enclosure_conf ( @{ $entry_conf->{enclosure} } ){ 42 my $encls = $entry_conf->{enclosure} || []; 43 $encls = [ $encls ] if ref $encls && ref $encls ne 'ARRAY'; 44 45 for my $enclosure_conf ( @$encls ) { 40 46 my $enclosure = Plagger::Enclosure->new; 41 47 $enclosure->$_($enclosure_conf->{$_}) for keys %$enclosure_conf; 48 $enclosure->auto_set_type unless defined $enclosure->type; 42 49 $entry->add_enclosure($enclosure); 43 50 } trunk/plagger/t/plugins/CustomFeed-Debug/test.t
r1434 r1828 33 33 ok $context->update->feeds->[0]->entries->[1]->link; 34 34 ok $context->update->feeds->[0]->entries->[1]->body; 35 36 === Enclosures 37 --- input config 38 plugins: 39 - module: CustomFeed::Debug 40 config: 41 title: 'My Feed' 42 link: 'http://localhost/' 43 entry: 44 - title: 'First Entry' 45 link: 'http://localhost/1' 46 body: 'Hello World! :)' 47 enclosure: 48 url: http://example.com/foo.mp3 49 length: 123 50 type: audio/mp3 51 52 - title: 'First Entry' 53 link: 'http://localhost/1' 54 body: 'Hello World! :)' 55 enclosure: 56 - url: http://example.com/foo.mp3 57 length: 123 58 - url: http://example.com/foo.m4a 59 length: 456 60 --- expected 61 is $context->update->feeds->[0]->link, 'http://localhost/'; 62 is $context->update->feeds->[0]->title, 'My Feed'; 63 { 64 my @e = $context->update->feeds->[0]->entries->[0]->enclosures; 65 is @e, 1; 66 isa_ok $e[0]->url, 'URI'; 67 is $e[0]->url, 'http://example.com/foo.mp3'; 68 is $e[0]->type, 'audio/mp3'; 69 is $e[0]->length, 123; 70 } 71 { 72 my @e = $context->update->feeds->[0]->entries->[1]->enclosures; 73 is @e, 2; 74 isa_ok $e[0]->url, 'URI'; 75 is $e[0]->url, 'http://example.com/foo.mp3'; 76 is $e[0]->type, 'audio/mpeg'; 77 is $e[0]->length, 123; 78 is $e[1]->url, 'http://example.com/foo.m4a'; 79 is $e[1]->type, 'audio/aac'; 80 is $e[1]->length, 456; 81 } 82 83
