r41249 - in /trunk/libcddb-perl: CHANGES META.yml Makefile.PL debian/changelog debian/compat debian/control debian/copyright debian/rules lib/CDDB.pm t/01_cddb.t

jawnsy-guest at users.alioth.debian.org jawnsy-guest at users.alioth.debian.org
Mon Aug 3 16:56:57 UTC 2009


Author: jawnsy-guest
Date: Mon Aug  3 16:56:48 2009
New Revision: 41249

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=41249
Log:
* New upstream release
  + Fix track offset calculations according to documented test input

Modified:
    trunk/libcddb-perl/CHANGES
    trunk/libcddb-perl/META.yml
    trunk/libcddb-perl/Makefile.PL
    trunk/libcddb-perl/debian/changelog
    trunk/libcddb-perl/debian/compat
    trunk/libcddb-perl/debian/control
    trunk/libcddb-perl/debian/copyright
    trunk/libcddb-perl/debian/rules
    trunk/libcddb-perl/lib/CDDB.pm
    trunk/libcddb-perl/t/01_cddb.t

Modified: trunk/libcddb-perl/CHANGES
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/CHANGES?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/CHANGES (original)
+++ trunk/libcddb-perl/CHANGES Mon Aug  3 16:56:48 2009
@@ -1,25 +1,30 @@
-=========================
-2006-03-26 01:08:42 v1_17
-=========================
+=================================
+2009-07-27T16:02:08.268109Z v1_21
+=================================
 
-  2006-03-26 01:08:12 (r3) by rcaputo; lib/CDDB.pm M; t/01_cddb.t M
+  2009-07-27 16:01:44 (r9) by rcaputo; lib/CDDB.pm M
 
-    Apply Jasper Lievisse Adriaanse's patch to fix the tests. We're
-    testing live data, and it sometimes changes. Also incremented the
-    version number for a new release. 
+    Reorganize documentation links.
 
-  2005-09-17 19:54:22 (r2) by rcaputo
-  t/01_cddb.t A; t/cddb.t D; MANIFEST M
+  2009-07-27 04:39:24 (r8) by rcaputo; lib/CDDB.pm M; Makefile.PL M
 
-    Remove META.yml from the MANIFEST. Doesn't seem necessary now. Moved
-    the test to a numbered file. 
+    Add machine-readable repository directory. Add BUG TRACKER,
+    REPOSITORY and OTHER RESOURCES to the documentation. 
 
-  2005-09-17 19:46:28 (r1) by rcaputo
-  README A; devel/cddb-command-response-state.dia A; lib/CDDB.pm A; devel
-  A; /trunk A; HISTORY A; t/cddb.t A; /branches A; devel/get-toc.c A; t
-  A; lib A; MANIFEST A; Makefile.PL A; /tags A
+=================================
+2009-07-26T03:54:46.902679Z v1_20
+=================================
 
-    Initial import. 
+  2009-07-26 03:54:11 (r6) by rcaputo
+  lib/CDDB.pm M; t/01_cddb.t M; Makefile.PL M
+
+    Upgrade tests to Test::More. Fix track offset calculations according
+    to documented test input. Fix test input to match FreeDB
+    documentation. Many thanks to Chuck Cranor for reporting the issue. 
+
+  2006-11-06 19:20:39 (r5) by rcaputo; Makefile.PL M
+
+    Set a LICENSE. Cheap kwalitee points!
 
 ==============
 End of Excerpt

Modified: trunk/libcddb-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/META.yml?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/META.yml (original)
+++ trunk/libcddb-perl/META.yml Mon Aug  3 16:56:48 2009
@@ -1,12 +1,25 @@
 --- #YAML:1.0
-name:                CDDB
-version:             1.17
-abstract:            High-level interface to CDDB and freedb servers.
-license:             unknown
-generated_by:        ExtUtils::MakeMaker version 6.30_01
-author:              Rocco Caputo <rcaputo at cpan.org>
-distribution_type:   module
-requires:     
+name:               CDDB
+version:            1.21
+abstract:           High-level interface to CDDB and freedb servers.
+author:
+    - Rocco Caputo <rcaputo at cpan.org>
+license:            perl
+distribution_type:  module
+configure_requires:
+    ExtUtils::MakeMaker:  0
+build_requires:
+    ExtUtils::MakeMaker:  0
+requires:
+    Test::More:  0
+resources:
+    license:     http://dev.perl.org/licenses/
+    repository:  http://thirdlobe.com/svn/cddb/trunk
+no_index:
+    directory:
+        - t
+        - inc
+generated_by:       ExtUtils::MakeMaker version 6.54
 meta-spec:
-    url: <http://module-build.sourceforge.net/META-spec-new.html>;
-    version: 1.1
+    url:      http://module-build.sourceforge.net/META-spec-v1.4.html
+    version:  1.4

Modified: trunk/libcddb-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/Makefile.PL?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/Makefile.PL (original)
+++ trunk/libcddb-perl/Makefile.PL Mon Aug  3 16:56:48 2009
@@ -1,5 +1,5 @@
 #!/usr/bin/perl
-# $Id: Makefile.PL 1 2005-09-17 19:46:28Z rcaputo $
+# $Id: Makefile.PL 8 2009-07-27 04:39:24Z rcaputo $
 
 use ExtUtils::MakeMaker;
 
@@ -10,7 +10,17 @@
 	NAME         => 'CDDB',
 	AUTHOR       => 'Rocco Caputo <rcaputo at cpan.org>',
 	ABSTRACT     => 'High-level interface to CDDB and freedb servers.',
+	LICENSE      => 'perl',
 	VERSION_FROM => 'lib/CDDB.pm',
+	PREREQ_PM    => {
+		'Test::More' => 0,
+	},
+	META_ADD     => {
+		resources  => {
+			license    => 'http://dev.perl.org/licenses/',
+			repository => 'http://thirdlobe.com/svn/cddb/trunk'
+		},
+	},
 	dist         => {
 		COMPRESS   => 'gzip -9',
 		SUFFIX     => 'gz',

Modified: trunk/libcddb-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/debian/changelog?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/debian/changelog (original)
+++ trunk/libcddb-perl/debian/changelog Mon Aug  3 16:56:48 2009
@@ -1,4 +1,8 @@
-libcddb-perl (1.17-2) UNRELEASED; urgency=low
+libcddb-perl (1.21-1) UNRELEASED; urgency=low
+
+  [ Jonathan Yu ]
+  * New upstream release
+    + Fix track offset calculations according to documented test input
 
   [ gregor herrmann ]
   * debian/control: Changed: Switched Vcs-Browser field to ViewSVN
@@ -7,7 +11,7 @@
   [ Nathan Handler ]
   * debian/watch: Update to ignore development releases.
 
- -- gregor herrmann <gregoa at debian.org>  Sun, 16 Nov 2008 20:40:15 +0100
+ -- Jonathan Yu <frequency at cpan.org>  Mon, 03 Aug 2009 08:45:31 -0400
 
 libcddb-perl (1.17-1) unstable; urgency=low
 

Modified: trunk/libcddb-perl/debian/compat
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/debian/compat?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/debian/compat (original)
+++ trunk/libcddb-perl/debian/compat Mon Aug  3 16:56:48 2009
@@ -1,1 +1,1 @@
-5
+7

Modified: trunk/libcddb-perl/debian/control
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/debian/control?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/debian/control (original)
+++ trunk/libcddb-perl/debian/control Mon Aug  3 16:56:48 2009
@@ -1,11 +1,11 @@
 Source: libcddb-perl
 Section: perl
 Priority: optional
-Build-Depends: debhelper (>= 5)
-Build-Depends-Indep: perl (>= 5.6.10-12)
+Build-Depends: debhelper (>= 7)
+Build-Depends-Indep: perl (>= 5.6.10-16)
 Maintainer: Debian Perl Group <pkg-perl-maintainers at lists.alioth.debian.org>
-Uploaders: Martín Ferrari <tincho at debian.org>
-Standards-Version: 3.7.3
+Uploaders: Martín Ferrari <tincho at debian.org>, Jonathan Yu <frequency at cpan.org>
+Standards-Version: 3.8.2
 Homepage: http://search.cpan.org/dist/CDDB/
 Vcs-Svn: svn://svn.debian.org/pkg-perl/trunk/libcddb-perl/
 Vcs-Browser: http://svn.debian.org/viewsvn/pkg-perl/trunk/libcddb-perl/
@@ -13,17 +13,12 @@
 Package: libcddb-perl
 Architecture: all
 Depends: ${perl:Depends}, ${misc:Depends}
-Description: high-level interface to CDDB and freedb servers
- CDDB protocol (cddbp) servers provide compact disc information for
- programs that need it.  This allows such programs to display disc and
- track titles automatically, and it provides extended information like
- liner notes and lyrics.
+Description: Perl interface to CDDB and freedb servers
+ CDDB protocol servers provide compact disc information for programs that need
+ it. This allows such programs to display disc and track titles automatically
+ and it provides extended information like liner notes and lyrics. With this
+ module, a Perl program can identify and possibly gather details about a disc
+ based on its "table of contents" (the disc's track times and offsets).
  .
- This module provides a high-level Perl interface to cddbp servers.
- With it, a Perl program can identify and possibly gather details about
- a CD based on its "table of contents" (the disc's track times and
- offsets).
- .
- Disc details have been useful for generating CD catalogs, naming mp3
- files, printing CD liners, or even just playing discs in an automated
- jukebox.
+ Disc details have been useful for generating CD catalogs, naming mp3 files,
+ printing CD liners, or even just playing discs in an automated jukebox.

Modified: trunk/libcddb-perl/debian/copyright
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/debian/copyright?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/debian/copyright (original)
+++ trunk/libcddb-perl/debian/copyright Mon Aug  3 16:56:48 2009
@@ -1,23 +1,29 @@
-Format-Specification: http://wiki.debian.org/Proposals/CopyrightFormat
-Upstream-Author: Rocco Caputo <rcaputo at cpan.org>
-Packaged-By: Martín Ferrari <tincho at debian.org>
-Packaged-Date: Fri, 23 May 2008 02:46:21 -0300
-Original-Source-Location: http://search.cpan.org/dist/CDDB/
-Original-Source-Command: uscan --force-download
-Original-Source-Depends: devscripts
+Format-Specification:
+    http://wiki.debian.org/Proposals/CopyrightFormat?action=recall&rev=196
+Upstream-Maintainer: Rocco Caputo <rcaputo at cpan.org>
+Upstream-Source: http://search.cpan.org/dist/CDDB/
+Upstream-Name: CDDB
 
 Files: *
-Copyright: © 1998-2005 Rocco Caputo. All rights reserved.
+Copyright: 1998-2009, Rocco Caputo <rcaputo at cpan.org>
+License-Alias: Perl
 License: Artistic | GPL-1+
- This program is free software; you can redistribute it and/or modify it under
- the same terms as Perl itself.
 
 Files: debian/*
-Copyright: © 2008 Debian Perl Group <debian-perl at lists.debian.org>
+Copyright: 2009, Jonathan Yu <frequency at cpan.org>
 License: Artistic | GPL-1+
 
-Perl is distributed under your choice of the GNU General Public License or
-the Artistic License.  On Debian GNU/Linux systems, the complete text of the
-GNU General Public License can be found in `/usr/share/common-licenses/GPL'
-and the Artistic Licence in `/usr/share/common-licenses/Artistic'.
+License: Artistic
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the Artistic License, which comes with Perl.
+    On Debian GNU/Linux systems, the complete text of the Artistic License
+    can be found in `/usr/share/common-licenses/Artistic'
 
+License: GPL-1+
+    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 1, or (at your option)
+    any later version.
+    On Debian GNU/Linux systems, the complete text of the GNU General
+    Public License can be found in `/usr/share/common-licenses/GPL'
+

Modified: trunk/libcddb-perl/debian/rules
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/debian/rules?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/debian/rules (original)
+++ trunk/libcddb-perl/debian/rules Mon Aug  3 16:56:48 2009
@@ -1,57 +1,4 @@
 #!/usr/bin/make -f
 
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
-
-# If set to a true value then MakeMaker's prompt function will
-# always return the default without waiting for user input.
-export PERL_MM_USE_DEFAULT=1
-
-PERL   ?= /usr/bin/perl
-PACKAGE = $(shell dh_listpackages)
-TMP     = $(CURDIR)/debian/$(PACKAGE)
-
-build: build-stamp
-build-stamp:
-	dh_testdir
-	$(PERL) Makefile.PL INSTALLDIRS=vendor
-	$(MAKE)
-	# Disable tests, as they require network access
-	#$(MAKE) test
-	touch $@
-
-clean:
-	dh_testdir
-	dh_testroot
-	dh_clean build-stamp install-stamp
-	[ ! -f Makefile ] || $(MAKE) realclean
-
-install: install-stamp
-install-stamp: build-stamp
-	dh_testdir
-	dh_testroot
-	dh_clean -k
-	$(MAKE) install DESTDIR=$(TMP) PREFIX=/usr
-	[ ! -d $(TMP)/usr/lib/perl5 ] || \
-		rmdir --ignore-fail-on-non-empty --parents --verbose \
-		$(TMP)/usr/lib/perl5
-	touch $@
-
-binary-arch:
-# We have nothing to do here for an architecture-independent package
-
-binary-indep: build install
-	dh_testdir
-	dh_testroot
-	dh_installdocs README
-	dh_installchangelogs CHANGES
-	dh_perl
-	dh_compress
-	dh_fixperms
-	dh_installdeb
-	dh_gencontrol
-	dh_md5sums
-	dh_builddeb
-
-binary: binary-indep binary-arch
-.PHONY: build clean binary-indep binary-arch binary install
+%:
+	dh $@

Modified: trunk/libcddb-perl/lib/CDDB.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/lib/CDDB.pm?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/lib/CDDB.pm (original)
+++ trunk/libcddb-perl/lib/CDDB.pm Mon Aug  3 16:56:48 2009
@@ -1,4 +1,4 @@
-# $Id: CDDB.pm 3 2006-03-26 01:08:12Z rcaputo $
+# $Id: CDDB.pm 9 2009-07-27 16:01:44Z rcaputo $
 # Documentation and Copyright exist after __END__
 
 package CDDB;
@@ -8,7 +8,7 @@
 use vars qw($VERSION);
 use Carp;
 
-$VERSION = '1.17';
+$VERSION = '1.21';
 
 BEGIN {
 	if ($^O eq 'MSWin32') {
@@ -516,7 +516,7 @@
 
 	foreach my $line (@toc) {
 		my ($track, $mm_begin, $ss_begin, $ff_begin) = split(/\s+/, $line, 4);
-		my $frame_offset = (($mm_begin * 60 + $ss_begin) * 75) + $ff_begin + 150;
+		my $frame_offset = (($mm_begin * 60 + $ss_begin) * 75) + $ff_begin;
 		my $seconds_begin = int($frame_offset / 75);
 
 		if (defined $seconds_previous) {
@@ -550,10 +550,10 @@
 
 	# Calculate the ID.  Whee!
 	my $id = sprintf(
-		"%08x",
-		(($cddbp_sum % 255) << 24)
-		| (($seconds_last - $seconds_first) << 8)
-		| scalar(@track_offsets)
+		"%02x%04x%02x",
+		($cddbp_sum % 255),
+		$seconds_last - $seconds_first,
+		 scalar(@track_offsets)
 	);
 
 	# In list context, we return several things.  Some of them are
@@ -1022,67 +1022,67 @@
 
 =head1 SYNOPSIS
 
-	use CDDB;
-
-	### Connect to the cddbp server.
-	my $cddbp = new CDDB(
-		Host  => 'freedb.freedb.org', # default
-		Port  => 8880,                # default
-		Login => $login_id,           # defaults to %ENV's
-	) or die $!;
-
-	### Retrieve known genres.
-	my @genres = $cddbp->get_genres();
-
-	### Calculate cddbp ID based on MSF info.
-	my @toc = (
-		'1    0  2 37',           # track, CD-i MSF (space-delimited)
-		'999  1 38 17',           # lead-out track MSF
-		'1000 0  0 Error!',       # error track (don't include if ok)
-	);
-	my (
-		$cddbp_id,      # used for further cddbp queries
-		$track_numbers, # padded with 0's (for convenience)
-		$track_lengths, # length of each track, in MM:SS format
-		$track_offsets, # absolute offsets (used for further cddbp queries)
-		$total_seconds  # total play time, in seconds (for cddbp queries)
-	 ) = $cddbp->calculate_id(@toc);
-
-	### Query discs based on cddbp ID and other information.
-	my @discs = $cddbp->get_discs($cddbp_id, $track_offsets, $total_seconds);
-	foreach my $disc (@discs) {
-		my ($genre, $cddbp_id, $title) = @$disc;
-	}
-
-	### Query disc details (usually done with get_discs() information).
-	my $disc_info     = $cddbp->get_disc_details($genre, $cddbp_id);
-	my $disc_time     = $disc_info->{'disc length'};
-	my $disc_id       = $disc_info->{discid};
-	my $disc_title    = $disc_info->{dtitle};
-	my @track_offsets = @{$disc_info->{offsets}};
-	my @track_seconds = @{$disc_info->{seconds}};
-	my @track_titles  = @{$disc_info->{ttitles}};
-	# other information may be returned... explore!
-
-	### Submit a disc via e-mail. (Requires MailTools)
-
-	die "can't submit a disc (no mail modules; see README)"
-		unless $cddbp->can_submit_disc();
-
-	# These are useful for prompting the user to fix defaults:
-	print "I will send mail through: ", $cddbp->get_mail_host(), "\n";
-	print "I assume your e-mail address is: ", $cddbp->get_mail_address(), "\n";
-
-	# Actually submit a disc record.
-	$cddbp->submit_disc(
-		Genre       => 'classical',
-		Id          => 'b811a20c',
-		Artist      => 'Various',
-		DiscTitle   => 'Cartoon Classics',
-		Offsets     => $disc_info->{offsets},   # array reference
-		TrackTitles => $disc_info->{ttitles},   # array reference
-		From        => 'login at host.domain.etc', # will try to determine
-	);
+  use CDDB;
+
+  ### Connect to the cddbp server.
+  my $cddbp = new CDDB(
+    Host  => 'freedb.freedb.org', # default
+    Port  => 8880,                # default
+    Login => $login_id,           # defaults to %ENV's
+  ) or die $!;
+
+  ### Retrieve known genres.
+  my @genres = $cddbp->get_genres();
+
+  ### Calculate cddbp ID based on MSF info.
+  my @toc = (
+    '1    0  2 37',           # track, CD-i MSF (space-delimited)
+    '999  1 38 17',           # lead-out track MSF
+    '1000 0  0 Error!',       # error track (don't include if ok)
+  );
+  my (
+    $cddbp_id,      # used for further cddbp queries
+    $track_numbers, # padded with 0's (for convenience)
+    $track_lengths, # length of each track, in MM:SS format
+    $track_offsets, # absolute offsets (used for further cddbp queries)
+    $total_seconds  # total play time, in seconds (for cddbp queries)
+   ) = $cddbp->calculate_id(@toc);
+
+  ### Query discs based on cddbp ID and other information.
+  my @discs = $cddbp->get_discs($cddbp_id, $track_offsets, $total_seconds);
+  foreach my $disc (@discs) {
+    my ($genre, $cddbp_id, $title) = @$disc;
+  }
+
+  ### Query disc details (usually done with get_discs() information).
+  my $disc_info     = $cddbp->get_disc_details($genre, $cddbp_id);
+  my $disc_time     = $disc_info->{'disc length'};
+  my $disc_id       = $disc_info->{discid};
+  my $disc_title    = $disc_info->{dtitle};
+  my @track_offsets = @{$disc_info->{offsets}};
+  my @track_seconds = @{$disc_info->{seconds}};
+  my @track_titles  = @{$disc_info->{ttitles}};
+  # other information may be returned... explore!
+
+  ### Submit a disc via e-mail. (Requires MailTools)
+
+  die "can't submit a disc (no mail modules; see README)"
+    unless $cddbp->can_submit_disc();
+
+  # These are useful for prompting the user to fix defaults:
+  print "I will send mail through: ", $cddbp->get_mail_host(), "\n";
+  print "I assume your e-mail address is: ", $cddbp->get_mail_address(), "\n";
+
+  # Actually submit a disc record.
+  $cddbp->submit_disc(
+    Genre       => 'classical',
+    Id          => 'b811a20c',
+    Artist      => 'Various',
+    DiscTitle   => 'Cartoon Classics',
+    Offsets     => $disc_info->{offsets},   # array reference
+    TrackTitles => $disc_info->{ttitles},   # array reference
+    From        => 'login at host.domain.etc', # will try to determine
+  );
 
 =head1 DESCRIPTION
 
@@ -1227,21 +1227,21 @@
 In scalar context, calculate_id() returns just the cddbp ID.  In a
 list context, it returns an array containing the following values:
 
-	(
-		$cddbp_id,
-		$track_numbers,
-		$track_lengths,
-		$track_offsets,
-		$total_seconds
-	) = $cddbp->calculate_id(@toc);
-
-	print(
-		"cddbp ID      = $cddbp_id\n",        # b811a20c
-		"track numbers = @$track_numbers\n",  # 001 002 003 ...
-		"track lengths = @$track_lengths\n",  # 01:36 10:19 04:29 ...
-		"track offsets = @$track_offsets\n",  # 187 7367 53805 ...
-		"total seconds = $total_seconds\n",   # 4514
-	);
+  (
+    $cddbp_id,
+    $track_numbers,
+    $track_lengths,
+    $track_offsets,
+    $total_seconds
+  ) = $cddbp->calculate_id(@toc);
+
+  print(
+    "cddbp ID      = $cddbp_id\n",        # b811a20c
+    "track numbers = @$track_numbers\n",  # 001 002 003 ...
+    "track lengths = @$track_lengths\n",  # 01:36 10:19 04:29 ...
+    "track offsets = @$track_offsets\n",  # 187 7367 53805 ...
+    "total seconds = $total_seconds\n",   # 4514
+  );
 
 CDDBP_ID
 
@@ -1279,24 +1279,24 @@
 matching a given cddbp ID, track offsets, and total playing time.
 These values can be retrieved from calculade_id().
 
-	my @id_info       = $cddbp->calculate_id(@toc);
-	my $cddbp_id      = $id_info->[0];
-	my $track_offsets = $id_info->[3];
-	my $total_seconds = $id_info->[4];
+  my @id_info       = $cddbp->calculate_id(@toc);
+  my $cddbp_id      = $id_info->[0];
+  my $track_offsets = $id_info->[3];
+  my $total_seconds = $id_info->[4];
 
 get_discs() returns an array of matching discs, each of which is
 represented by an array reference.  It returns an empty array if the
 query succeeded but did not match, and it returns undef on error.
 
-	my @discs = $cddbp->get_discs( $cddbp_id, $track_offsets, $total_seconds );
-	foreach my $disc (@discs) {
-		my ($disc_genre, $disc_id, $disc_title) = @$disc;
-		print(
-			"disc id    = $disc_id\n",
-			"disc genre = $disc_genre\n",
-			"disc title = $disc_title\n",
-		);
-	}
+  my @discs = $cddbp->get_discs( $cddbp_id, $track_offsets, $total_seconds );
+  foreach my $disc (@discs) {
+    my ($disc_genre, $disc_id, $disc_title) = @$disc;
+    print(
+      "disc id    = $disc_id\n",
+      "disc genre = $disc_genre\n",
+      "disc title = $disc_title\n",
+    );
+  }
 
 DISC_GENRE is the genre this disc falls into, as determined by whoever
 submitted or last edited the disc.  The genre is required when
@@ -1325,7 +1325,7 @@
 
 Cddb protocol query strings look like:
 
-	cddb query $cddbp_id $track_count @offsets $total_seconds
+  cddb query $cddbp_id $track_count @offsets $total_seconds
 
 =item get_disc_details DISC_GENRE, CDDBP_ID
 
@@ -1337,7 +1337,7 @@
 hash.  It includes information normally stored in comments.  The most
 common entries in this hash include:
 
-	$disc_details = get_disc_details( $disc_genre, $cddbp_id );
+  $disc_details = get_disc_details( $disc_genre, $cddbp_id );
 
 $disc_details->{"disc length"}
 
@@ -1416,18 +1416,18 @@
 last set to.  It was added to fetch the default e-mail address so
 users can see it and have an opportunity to correct it.
 
-	my $mail_from = $cddb->get_mail_address();
-	print "New e-mail address (or blank to keep <$mail_from>): ";
-	my $new_mail_from = <STDIN>;
-	$new_mail_from =~ s/^\s+//;
-	$new_mail_from =~ s/\s+$//;
-	$new_mail_from =~ s/\s+/ /g;
-	$mail_from = $new_mail_from if length $new_mail_from;
-
-	$cddbp->submit_disc(
-		...,
-		From => $mail_from,
-	);
+  my $mail_from = $cddb->get_mail_address();
+  print "New e-mail address (or blank to keep <$mail_from>): ";
+  my $new_mail_from = <STDIN>;
+  $new_mail_from =~ s/^\s+//;
+  $new_mail_from =~ s/\s+$//;
+  $new_mail_from =~ s/\s+/ /g;
+  $mail_from = $new_mail_from if length $new_mail_from;
+
+  $cddbp->submit_disc(
+    ...,
+    From => $mail_from,
+  );
 
 =item get_mail_host
 
@@ -1435,18 +1435,18 @@
 to.  It was added to fetch the default e-mail transfer host so users
 can see it and have an opportunity to correct it.
 
-	my $mail_host = $cddb->get_mail_host();
-	print "New e-mail host (or blank to keep <$mail_host>): ";
-	my $new_mail_host = <STDIN>;
-	$new_mail_host =~ s/^\s+//;
-	$new_mail_host =~ s/\s+$//;
-	$new_mail_host =~ s/\s+/ /g;
-	$mail_host = $new_mail_host if length $new_mail_host;
-
-	$cddbp->submit_disc(
-		...,
-		Host => $mail_host,
-	);
+  my $mail_host = $cddb->get_mail_host();
+  print "New e-mail host (or blank to keep <$mail_host>): ";
+  my $new_mail_host = <STDIN>;
+  $new_mail_host =~ s/^\s+//;
+  $new_mail_host =~ s/\s+$//;
+  $new_mail_host =~ s/\s+/ /g;
+  $mail_host = $new_mail_host if length $new_mail_host;
+
+  $cddbp->submit_disc(
+    ...,
+    Host => $mail_host,
+  );
 
 =item parse_cdinfo CDINFO_FILE
 
@@ -1454,8 +1454,8 @@
 output of a program called "cdinfo".  CDINFO_FILE may either be a text
 file, or it may be the cdinfo program itself.
 
-	my @toc = parse_cdinfo("cdinfo.txt"); # read cdinfo.txt
-	my @toc = parse_cdinfo("cdinfo|");    # run cdinfo directly
+  my @toc = parse_cdinfo("cdinfo.txt"); # read cdinfo.txt
+  my @toc = parse_cdinfo("cdinfo|");    # run cdinfo directly
 
 The table of contents can be passed directly to calculate_id().
 
@@ -1546,19 +1546,26 @@
 Please see the cddb.t program in the t (tests) directory.  It
 exercises every aspect of CDDB.pm, including submissions.
 
-=head1 BUGS
-
-There are no known bugs, but see the README for things that need to be
-done.
+=head1 LINKS
+
+=head2 BUG TRACKER
+
+https://rt.cpan.org/Dist/Display.html?Status=Active&Queue=CDDB
+
+=head2 REPOSITORY
+
+http://thirdlobe.com/svn/cddb/
+
+=head2 OTHER RESOURCES
+
+http://search.cpan.org/dist/CDDB/
 
 =head1 CONTACT AND COPYRIGHT
 
-Copyright 1998-2005 Rocco Caputo.  All rights reserved.  This program
+Copyright 1998-2009 Rocco Caputo.  All rights reserved.  This program
 is free software; you can redistribute it and/or modify it under the
 same terms as Perl itself.
 
-Rocco may be contacted at rcaputo at cpan.org.
-
 =cut
 
 # vim: sw=2 tw=70:

Modified: trunk/libcddb-perl/t/01_cddb.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libcddb-perl/t/01_cddb.t?rev=41249&op=diff
==============================================================================
--- trunk/libcddb-perl/t/01_cddb.t (original)
+++ trunk/libcddb-perl/t/01_cddb.t Mon Aug  3 16:56:48 2009
@@ -1,5 +1,5 @@
 #!perl -w
-# $Id: 01_cddb.t 3 2006-03-26 01:08:12Z rcaputo $
+# $Id: 01_cddb.t 6 2009-07-26 03:54:11Z rcaputo $
 # vim: filetype=perl
 # 
 # Copyright 1998-2005 Rocco Caputo <troc at netrus.net>.  All rights
@@ -8,10 +8,10 @@
 
 use strict;
 use CDDB;
+use Test::More tests => 25;
 
 BEGIN {
 	select(STDOUT); $|=1;
-	print "1..34\n";
 };
 
 my ($i, $result);
@@ -25,34 +25,18 @@
 	Debug          => 0,
 );
 
-defined($cddb) || print 'not '; print "ok 1\n";
+ok(defined($cddb), "cddb object built okay");
 
 ### test genres
 
-my @test_genres = qw(
+my @test_genres = sort qw(
 	blues classical country data folk jazz misc newage reggae rock
 	soundtrack
 );
-my @cddb_genres = $cddb->get_genres();
-
-if (@cddb_genres) {
-	print "ok 2\n";
-	if (@cddb_genres == @test_genres) {
-		print "ok 3\n";
-		@test_genres = sort @test_genres;
-		@cddb_genres = sort @cddb_genres;
-		$result = 'ok';
-		while (my $test = shift(@test_genres)) {
-			$result = 'not ok' if ($test ne shift(@cddb_genres));
-		}
-		print "$result 4\n";
-	}
-}
-else {
-	print "not ok 2\n";
-	print "not ok 3\n";
-	print "not ok 4\n";
-}
+
+my @cddb_genres = sort $cddb->get_genres();
+
+is_deeply(\@cddb_genres, \@test_genres, "got expected genres");
 
 ### helper sub: replace != tests with "not off by 5%"
 
@@ -81,8 +65,8 @@
 # Sample TOC information:
 
 my @toc = (
-	"1   0  1  71",  # track  1 starts at 00:01 and 71 frames
-	"999 5 42   4",  # leadout  starts at 05:42 and  4 frames
+	"1   0  3  71",  # track  1 starts at 00:03 and 71 frames
+	"999 5 44   4",  # leadout  starts at 05:44 and  4 frames
 );
 
 ### calculate CDDB ID
@@ -90,51 +74,16 @@
 my ($id, $track_numbers, $track_lengths, $track_offsets, $total_seconds) =
 	$cddb->calculate_id(@toc);
 
-($id ne '03015501') && print 'not '; print "ok 5\n";
-&not_near($total_seconds, 344) && print 'not '; print "ok 6\n";
+is($id, '03015501', 'calculated expected id');
+is($total_seconds, 344, 'total time matches');
 
 my @test_numbers = qw(001);
 my @test_lengths = qw(05:41);
 my @test_offsets = qw(296);
 
-if (@$track_numbers == @test_numbers) {
-	print "ok 7\n";
-	$i = 0; $result = 'ok';
-	foreach my $number (@test_numbers) {
-		$result = 'not ok' if ($number ne $track_numbers->[$i++]);
-	}
-	print "$result 8\n";
-}
-else {
-	print "not ok 7\n";
-	print "not ok 8\n";
-}
-
-if (@$track_lengths == @test_lengths) {
-	print "ok 9\n";
-	$i = 0; $result = 'ok';
-	foreach my $length (@test_lengths) {
-		$result = 'not ok' if ($length ne $track_lengths->[$i++]);
-	}
-	print "$result 10\n";
-}
-else {
-	print "not ok 9\n";
-	print "not ok 10\n";
-}
-
-if (@$track_offsets == @test_offsets) {
-	print "ok 11\n";
-	$i = 0; $result = 'ok';
-	foreach my $offset (@test_offsets) {
-		$result = 'not ok' if (&not_near($offset, $track_offsets->[$i++]));
-	}
-	print "$result 12\n";
-}
-else {
-	print "not ok 11\n";
-	print "not ok 12\n";
-}
+is_deeply($track_numbers, \@test_numbers, 'got expected track numbers');
+is_deeply($track_lengths, \@test_lengths, 'got expected track lengths');
+is_deeply($track_offsets, \@test_offsets, 'got expected track offsets');
 
 ### test looking up discs (one match)
 
@@ -142,33 +91,22 @@
 my $disc_count = @discs;
 
 my ($genre, $disc_id, $title) = @{$discs[0]};
-($disc_count == 2) || print 'not '; print "ok 13 # $disc_count\n";
-
-print "not " unless grep { $_->[0] eq "misc" } @discs;
-print "ok 14\n";
-
-($discs[0][1] eq '03015501')  || print 'not '; print "ok 15 # $discs[0][1]\n";
-
-print 'not ' unless $discs[0][2] =~ /freedb.*test/i;
-print "ok 16 # $discs[0][2]\n";
+is($disc_count, 2, 'got expected disc count');
+
+ok(scalar(grep { $_->[0] eq 'misc' } @discs), 'got expected disc genre');
+
+ok(scalar(grep { $_->[1] eq '03015501' } @discs), 'retrieved disc is expected id');
+
+#is($discs[0][1], '03015501', 'retrieved disc is expected id');
+
+like($discs[0][2], qr/freedb.*test/i, 'retrieved disc has expected title');
 
 ### test macro lookup
 
 $cddb->disconnect();
 my @other_discs = $cddb->get_discs_by_toc(@toc);
 
-if (@other_discs) {
-	my $other_count = @other_discs;
-	($other_count == 2) || print 'not '; print "ok 17 # $other_count\n";
-	($other_discs[0]->[0] eq $discs[0]->[0]) || print 'not '; print "ok 18\n";
-	($other_discs[0]->[1] eq $discs[0]->[1]) || print 'not '; print "ok 19\n";
-	($other_discs[0]->[2] eq $discs[0]->[2]) || print 'not '; print "ok 20\n";
-}
-else {
-	for (17..20) {
-		print "not ok $_ # no result\n";
-	}
-}
+is_deeply($other_discs[0], $discs[0], 'disc by toc matches disc by id');
 
 ### test gathering disc details
 
@@ -186,27 +124,10 @@
 #   }
 # }
 
-($disc_info->{'disc length'} eq '344 seconds') || print 'not ';
-print "ok 21 # $disc_info->{'disc length'}\n";
-
-($disc_info->{'discid'} eq $disc_id) || print 'not ';
-print "ok 22\n";
-
-($disc_info->{'dtitle'} eq $title) || print 'not ';
-print "ok 23\n";
-
-if (@{$disc_info->{'offsets'}} == @$track_offsets) {
-	print "ok 24\n";
-	$i = 0; $result = 'ok';
-	foreach my $offset (@{$disc_info->{'offsets'}}) {
-		$result = 'not ok' if &not_near($offset, $track_offsets->[$i++]);
-	}
-	print "$result 25\n";
-}
-else {
-	print "not ok 24\n";
-	print "not ok 25\n";
-}
+is($disc_info->{'disc length'}, '344 seconds', 'disc is expected length');
+is($disc_info->{'discid'}, $disc_id, 'disc id matches expectation');
+is($disc_info->{'dtitle'}, $title, 'disc title matches expectation');
+is_deeply($disc_info->{'offsets'}, $track_offsets, 'disc offsets match');
 
 my @test_titles = ( "01-test" );
 
@@ -219,8 +140,7 @@
 	$ok_tracks++;
 }
 
-print "not " unless $ok_tracks >= @test_titles / 2;
-print "ok 26 # $ok_tracks >= ", (@test_titles / 2), " ?\n";
+ok($ok_tracks >= @test_titles / 2, 'enough track titles match expectation');
 
 ### test fuzzy matches ("the freeside tests")
 
@@ -232,12 +152,12 @@
 );
 
 @discs = $cddb->get_discs($id, \@fuzzy_offsets, $total_seconds);
- at discs || print 'not '; print "ok 27\n";
+ok(scalar(@discs), 'retrieved at least one disc');
 
 ($genre, $disc_id, $title) = @{$discs[0]};
-(length $genre)         || print 'not '; print "ok 28\n";
-(length($disc_id) == 8) || print 'not '; print "ok 29\n";
-(length $title)         || print 'not '; print "ok 30\n";
+ok((length $genre), 'retrieved disc has a genre');
+ok((length($disc_id) == 8), 'retrieved disc id is proper length');
+ok((length $title), 'retrieved disc has a title');
 
 $id = 'c509b810';
 $total_seconds = 2488;
@@ -247,17 +167,20 @@
 );
 
 @discs = $cddb->get_discs($id, \@fuzzy_offsets, $total_seconds);
-
-if (@discs > 1) {
-	print "ok 31\n";
-}
-else {
-	print "not ok 31\n";
-}
+ok(@discs > 1, 'retrieved discs from fuzzy offset');
 
 ### test CDDB submission
-
-if ($cddb->can_submit_disc()) {
+# <bekj> dngor It's not Polite to have tests fail when things are OK,
+# Makes CPAN choke :(
+
+SKIP: {
+	unless ($cddb->can_submit_disc()) {
+		skip(
+			"Mail::Internet; Mail::Header; and MIME::QuotedPrint needed to submit",
+			1
+		);
+	}
+
 	eval {
 		$cddb->submit_disc(
 			Genre       => 'classical',
@@ -272,25 +195,15 @@
 			# odd revision for testing
 			Revision    => 123,
 		);
-		print "ok 32\n";
+
+		pass("submitted a test disc; check your e-mail for confirmation");
 	};
 
 	# skip if SMTPHOSTS and default are bad
-	if ($@ ne '') {
-		print "ok 32 # Skip - $@\n";
+	if ($@) {
+		skip($@, 1);
 	}
-}
-
-# <bekj> dngor It's not Polite to have tests fail when things are OK,
-# Makes CPAN choke :(
-
-																				# skip when needed modules are missing
-else {
-	print(
-		"ok 32 # Skip - Mail::Internet; Mail::Header; and MIME::QuotedPrint ",
-		"are needed to submit discs\n"
-	);
-}
+};
 
 ### Test fetch-by-query.
 
@@ -300,16 +213,8 @@
 );
 
 @discs = $cddb->get_discs_by_query($query);
-if (@discs) {
-	print "not " unless $discs[0][0] eq 'rock';
-	print "ok 33\n";
-	print "not " unless $discs[0][1] eq 'd30ffd0e';
-	print "ok 34\n";
-}
-else {
-	print "not ok 33\n";
-	print "not ok 34\n";
-}
+is($discs[0][0], 'rock', 'fetch-by-query retrieved expected genre');
+is($discs[0][1], 'd30ffd0e', 'fetch-by-query retrieved expected id');
 
 __END__
 




More information about the Pkg-perl-cvs-commits mailing list