From 75d7592fbd9a25df92df9ce4824f8b0cd0866121 Mon Sep 17 00:00:00 2001 From: jq Date: Wed, 4 Apr 2007 16:50:04 +0000 Subject: [PATCH] [project @ 5831] am::pl_changes() migrated to am::playlist::items_changed_since(), with tests associated moved accordingly --- lib/Audio/MPD.pm | 19 ------------------- lib/Audio/MPD/Playlist.pm | 18 ++++++++++++++++++ t/24-info.t | 10 +--------- t/40-playlist.t | 14 +++++++++++--- 4 files changed, 30 insertions(+), 31 deletions(-) diff --git a/lib/Audio/MPD.pm b/lib/Audio/MPD.pm index 66b3b18..c38ef91 100644 --- a/lib/Audio/MPD.pm +++ b/lib/Audio/MPD.pm @@ -346,19 +346,6 @@ sub status { # -# my $list = $mpd->pl_changes( $plversion ); -# -# Return a list with all the songs (as API::Song objects) added to -# the playlist since playlist $plversion. -# -sub pl_changes { - my ($self, $plid) = @_; - - return $self->_cooked_command_as_items("plchanges $plid\n"); -} - - -# # my $song = $mpd->current; # # Return an C representing the song currently playing. @@ -745,12 +732,6 @@ MPD server settings. Check the embedded pod for more information on the available accessors. -=item $mpd->pl_changes( $plversion ) - -Return a list with all the songs (as API::Song objects) added to -the playlist since playlist $plversion. - - =item $mpd->current( ) Return an C representing the song currently playing. diff --git a/lib/Audio/MPD/Playlist.pm b/lib/Audio/MPD/Playlist.pm index 97f50f5..a11bbde 100644 --- a/lib/Audio/MPD/Playlist.pm +++ b/lib/Audio/MPD/Playlist.pm @@ -71,6 +71,18 @@ sub as_items { } +# +# my @items = $pl->items_changed_since( $plversion ); +# +# Return a list with all the songs (as API::Song objects) added to +# the playlist since playlist $plversion. +# +sub items_changed_since { + my ($self, $plid) = @_; + return $self->_mpd->_cooked_command_as_items("plchanges $plid\n"); +} + + # -- Playlist: adding / removing songs @@ -266,6 +278,12 @@ Return an array of Cs, one for each of the songs in the current playlist. +=item $pl->items_changed_since( $plversion ) + +Return a list with all the songs (as API::Song objects) added to +the playlist since playlist $plversion. + + =back diff --git a/t/24-info.t b/t/24-info.t index 4c97f3b..35c15d6 100644 --- a/t/24-info.t +++ b/t/24-info.t @@ -29,7 +29,7 @@ use Test::More; eval 'use Audio::MPD::Test'; plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s; -plan tests => 19; +plan tests => 15; my $mpd = Audio::MPD->new; my $song; @@ -64,14 +64,6 @@ isa_ok( $song, 'Audio::MPD::Item::Song', 'current return an Audio::MPD::Item::So # -# testing playlist changes retrieval. -my @list = $mpd->pl_changes(0); -isa_ok( $_, 'Audio::MPD::Item::Song', 'pl_changes() returns Audio::MPD::Item::Song objects' ) - for @list; -is( $list[0]->title, 'ok-title', 'first song reported first' ); - - -# # testing song. $song = $mpd->song(1); isa_ok( $song, 'Audio::MPD::Item::Song', 'song() returns an Audio::MPD::Item::Song object' ); diff --git a/t/40-playlist.t b/t/40-playlist.t index 9b80df1..dba4992 100644 --- a/t/40-playlist.t +++ b/t/40-playlist.t @@ -29,9 +29,9 @@ use Test::More; eval 'use Audio::MPD::Test'; plan skip_all => $@ if $@ =~ s/\n+Compilation failed.*//s; -plan tests => 11; +plan tests => 15; my $mpd = Audio::MPD->new; -my $nb; +my ($nb, @items); # @@ -46,12 +46,20 @@ isa_ok( $pl, 'Audio::MPD::Playlist', $pl->add( 'title.ogg' ); $pl->add( 'dir1/title-artist-album.ogg' ); $pl->add( 'dir1/title-artist.ogg' ); -my @items = $pl->as_items; +@items = $pl->as_items; isa_ok( $_, 'Audio::MPD::Item::Song', 'as_items() returns Audio::MPD::Item::Song objects' ) for @items; is( $items[0]->title, 'ok-title', 'first song reported first' ); +# +# testing playlist changes retrieval. +@items = $pl->items_changed_since(0); +isa_ok( $_, 'Audio::MPD::Item::Song', + 'items_changed_since() returns Audio::MPD::Item::Song objects' ) + for @items; +is( $items[0]->title, 'ok-title', 'first song reported first' ); + # # testing song insertion. -- 2.11.4.GIT