From b56b3fd87df609f926b086fcbde14f62dbc9c2eb Mon Sep 17 00:00:00 2001 From: jq Date: Sun, 8 Apr 2007 13:23:36 +0000 Subject: [PATCH] [project @ 5880] using am::stats instead of a plain hash ref --- lib/Audio/MPD.pm | 12 +++++------- t/24-info.t | 19 ++++++++++--------- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/lib/Audio/MPD.pm b/lib/Audio/MPD.pm index 57f3ec2..198a194 100644 --- a/lib/Audio/MPD.pm +++ b/lib/Audio/MPD.pm @@ -23,6 +23,7 @@ use strict; use Audio::MPD::Collection; use Audio::MPD::Item; use Audio::MPD::Playlist; +use Audio::MPD::Stats; use Audio::MPD::Status; use Encode; use IO::Socket; @@ -333,14 +334,12 @@ sub output_disable { # # $mpd->stats; # -# Return a hashref with the number of artists, albums, songs in the database, -# as well as mpd uptime, the playtime of the playlist / the database and the -# last update of the database. +# Return an Audio::MPD::Stats object with the current statistics of MPD. # sub stats { my ($self) = @_; my %kv = $self->_cooked_command_as_kv( "stats\n" ); - return \%kv; + return Audio::MPD::Stats->new(%kv); } @@ -665,9 +664,8 @@ Disable the specified audio output. $output is the ID of the audio output. =item $mpd->stats() -Return a hashref with the number of artists, albums, songs in the database, -as well as mpd uptime, the playtime of the playlist / the database and the -last update of the database +Return an C object with the current statistics of MPD. +See the associated pod for more information. =item $mpd->status() diff --git a/t/24-info.t b/t/24-info.t index 35c15d6..101f28f 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 => 15; +plan tests => 16; my $mpd = Audio::MPD->new; my $song; @@ -40,13 +40,14 @@ $mpd->playlist->add( 'title.ogg' ); $mpd->playlist->add( 'dir1/title-artist-album.ogg' ); $mpd->playlist->add( 'dir1/title-artist.ogg' ); my $stats = $mpd->stats; -is( $stats->{artists}, 1, 'one artist in the database' ); -is( $stats->{albums}, 1, 'one album in the database' ); -is( $stats->{songs}, 4, '4 songs in the database' ); -is( $stats->{playtime}, 0, 'already played 0 seconds' ); -is( $stats->{db_playtime}, 8, '8 seconds worth of music in the db' ); -isnt( $stats->{uptime}, undef, 'uptime is defined' ); -isnt( $stats->{db_update}, 0, 'database has been updated' ); +isa_ok( $stats, 'Audio::MPD::Stats', 'stats() returns an am::stats object' ); +is( $stats->artists, 1, 'one artist in the database' ); +is( $stats->albums, 1, 'one album in the database' ); +is( $stats->songs, 4, '4 songs in the database' ); +is( $stats->playtime, 0, 'already played 0 seconds' ); +is( $stats->db_playtime, 8, '8 seconds worth of music in the db' ); +isnt( $stats->uptime, undef, 'uptime is defined' ); +isnt( $stats->db_update, 0, 'database has been updated' ); # @@ -54,7 +55,7 @@ isnt( $stats->{db_update}, 0, 'database has been updated' ); $mpd->play; $mpd->pause; my $status = $mpd->status; -isa_ok( $status, 'Audio::MPD::Status', 'status return an Audio::MPD::Status object' ); +isa_ok( $status, 'Audio::MPD::Status', 'status return an am::status object' ); # -- 2.11.4.GIT