From 9a43eb033d5bae0d96b31803a7ee560c0205cc6b Mon Sep 17 00:00:00 2001 From: jq Date: Sat, 17 Mar 2007 13:06:20 +0000 Subject: [PATCH] [project @ 5628] new module Audio::MPD::Collection --- MANIFEST | 1 + lib/Audio/MPD/Collection.pm | 124 ++++++++++++++++++++++++++++++++++++++++++++ t/00-use.t | 3 +- 3 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 lib/Audio/MPD/Collection.pm diff --git a/MANIFEST b/MANIFEST index 2a90d29..e8ef5af 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3,6 +3,7 @@ Build.PL Changelog COPYING lib/Audio/MPD.pm +lib/Audio/MPD/Collection.pm lib/Audio/MPD/Item.pm lib/Audio/MPD/Item/Directory.pm lib/Audio/MPD/Item/Song.pm diff --git a/lib/Audio/MPD/Collection.pm b/lib/Audio/MPD/Collection.pm new file mode 100644 index 0000000..9e10f4f --- /dev/null +++ b/lib/Audio/MPD/Collection.pm @@ -0,0 +1,124 @@ +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +# +# + +package Audio::MPD::Collection; + +use strict; +use warnings; +use Audio::MPD::Item::Directory; +use Audio::MPD::Item::Song; +use Scalar::Util qw[ weaken ]; + +use base qw[ Class::Accessor::Fast ]; +__PACKAGE__->mk_accessors( qw[ _mpd ] ); + + +our $VERSION = '$Revision$'; + +# +# constructor. +# +sub new { + my ($pkg, $mpd) = @_; + + my $self = { _mpd => $mpd }; + weaken( $self->{_mpd} ); + return $self; +} + +1; + +__END__ + + +=head1 NAME + +Audio::MPD::Collection - an object to query MPD's collection + + +=head1 SYNOPSIS + + my $song = $mpd->collection->random_song; + + +=head1 DESCRIPTION + +C is a class meant to access & query MPD's +collection. You will be able to use those high-level methods instead +of using the low-level methods provided by mpd itself. + + +=head1 PUBLIC METHODS + +=head2 Constructor + +=over 4 + +=item new( $mpd ) + +This will create the object, holding a back-reference to the C +object itself (for communication purposes). But in order to play safe and +to free the memory in time, this reference is weakened. + +Note that you're not supposed to call this constructor yourself, an +C is automatically created for you during the creation +of an C object. + +=back + + +=head2 + +=over 4 + +=back + + +=head1 SEE ALSO + +You can find more information on the mpd project on its homepage at +L, or its wiki L. + +Regarding this Perl module, you can report bugs on CPAN via +L. + +Audio::MPD development takes place on : feel free +to join us. (use L to sign in). Our +subversion repository is located at L. + + +=head1 AUTHORS + +Jerome Quelin + + +=head1 COPYRIGHT AND LICENSE + +Copyright (c) 2007 Jerome Quelin + + +This program is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 2 of the License, or +(at your option) any later version. + +This program is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +=cut diff --git a/t/00-use.t b/t/00-use.t index 075b983..00d5c46 100644 --- a/t/00-use.t +++ b/t/00-use.t @@ -22,7 +22,7 @@ use strict; use warnings; -use Test::More tests => 5; +use Test::More tests => 6; BEGIN { use_ok( 'Audio::MPD' ); } diag( "Testing Audio::MPD $Audio::MPD::VERSION, Perl $], $^X" ); @@ -31,3 +31,4 @@ use_ok( 'Audio::MPD::Status' ); use_ok( 'Audio::MPD::Item::Directory' ); use_ok( 'Audio::MPD::Item::Song' ); use_ok( 'Audio::MPD::Item' ); +use_ok( 'Audio::MPD::Collection' ); -- 2.11.4.GIT