Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37470928
en ru br
Репозитории ALT

Группа :: Разработка/Perl
Пакет: perl-Business-ISMN

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

pax_global_header00006660000000000000000000000064121002052140014475gustar00rootroot0000000000000052 comment=f452bbf1bb3d6bd7cc7485f99ad47fb6dc82296b
Business-ISMN-1.11/000075500000000000000000000000001210020521400137545ustar00rootroot00000000000000Business-ISMN-1.11/.gear/000075500000000000000000000000001210020521400147505ustar00rootroot00000000000000Business-ISMN-1.11/.gear/rules000064400000000000000000000000441210020521400160230ustar00rootroot00000000000000tar: . name=Business-ISMN-@version@
Business-ISMN-1.11/Changes000064400000000000000000000014161210020521400152510ustar00rootroot00000000000000# $Id: Changes,v 1.14 2007/10/26 03:02:14 comdog Exp $

1.11 - Thu Oct 25 22:01:29 2007
* distro adjustments. no big whoop.

1.10 - Tue Jan 9 23:17:19 2007
* updated copyright and license info
* no code changes, so no need to upgrade

1.08 - Mon Jun 5 00:10:55 2006
* fix-ups to dist. No need to upgrade.

1.07 - Thu May 18 18:05:18 2006
* cleanups for distro and kwalitee. no need to upgrade.

1.6 - Tue Mar 8 17:18:49 2005
* Added a POD coverage test and fixed up the problems it found

1.5 - Thu Sep 16 11:10:52 2004
* distro cleanups: no need to upgrade

1.2 - Wed Oct 9 01:16:03 CDT 2002
+ cleaned up distribution---no code changes

1.2 - Mon Sep 9 14:55:31 CDT 2002
+ fixed checksum routine

1.1 - Mon Sep 9 11:41:43 CDT 2002
+ first version of Business::ISMN
Business-ISMN-1.11/LICENSE000064400000000000000000000000771210020521400147650ustar00rootroot00000000000000You can use Business::ISMN under the same terms as Perl itself.Business-ISMN-1.11/MANIFEST000064400000000000000000000003021210020521400151000ustar00rootroot00000000000000Changes
examples/README
ismns.txt
lib/Data.pm
lib/ISMN.pm
LICENSE
Makefile.PL
MANIFEST This list of files
META.yml
README
t/ismn.t
t/load.t
t/pod.t
t/pod_coverage.t
t/prereq.t
t/test_manifest
Business-ISMN-1.11/META.yml000064400000000000000000000010051210020521400152210ustar00rootroot00000000000000--- #YAML:1.0
name: Business-ISMN
version: 1.11
abstract: Work with International Standard Music Numbers
license: perl
generated_by: ExtUtils::MakeMaker version 6.36
distribution_type: module
requires:
List::Util: 0
Test::More: 0
Tie::Cycle: 0
meta-spec:
url: http://module-build.sourceforge.net/META-spec-v1.3.html
version: 1.3
author:
- brian d foy <bdfoy@cpan.org>
Business-ISMN-1.11/Makefile.PL000064400000000000000000000014561210020521400157340ustar00rootroot00000000000000# $Id: Makefile.PL,v 1.8 2007/10/26 02:53:51 comdog Exp $
use ExtUtils::MakeMaker;

eval "use Test::Manifest 1.14";

WriteMakefile(
'NAME' => 'Business::ISMN',
'VERSION_FROM' => 'lib/ISMN.pm',
'LICENSE' => 'perl',
'AUTHOR' => 'brian d foy <bdfoy@cpan.org>',
'ABSTRACT' => 'Work with International Standard Music Numbers',

'PREREQ_PM' => {
'List::Util' => '0',
'Test::More' => '0',
'Tie::Cycle' => '0',
},
'PM' => { 'lib/ISMN.pm' => '$(INST_LIBDIR)/ISMN.pm',
'lib/Data.pm' => '$(INST_LIBDIR)/ISMN/Data.pm',

},
'MAN3PODS' => {
'lib/ISMN.pm' => '$(INST_MAN3DIR)/Business::ISMN.3',
},

clean => { FILES => 'Business-ISMN-*' },
);
Business-ISMN-1.11/README000064400000000000000000000010211210020521400146260ustar00rootroot00000000000000$Id: README,v 1.1 2004/09/16 15:58:26 comdog Exp $

You can install this using in the usual Perl fashion

perl Makefile.PL
make
make test
make install

The documentation is in the module file. Once you install
the file, you can read it with perldoc.

perldoc Business::ISMN

If you want to read it before you install it, you can use
perldoc directly on the module file.

perldoc lib/ISMN.pm

This module is also in CVS on SourceForge

http://sourceforge.net/projects/brian-d-foy/


Enjoy,

brian d foy, bdfoy@cpan.orgBusiness-ISMN-1.11/examples/000075500000000000000000000000001210020521400155725ustar00rootroot00000000000000Business-ISMN-1.11/examples/README000064400000000000000000000001051210020521400164460ustar00rootroot00000000000000See the tests in the t/ directory for examples until I add some more.Business-ISMN-1.11/ismns.txt000064400000000000000000000014411210020521400156460ustar00rootroot00000000000000M-706208-05-3
M-706208-01-5
M-706208-02-2
M-706208-05-3
M-706208-06-0
M-706208-09-1
M-706208-10-7
M-706208-11-4
M-706208-12-1
M-706217-00-0
M-706217-01-7
M-706217-02-4
M-706228-01-3
M-706228-02-0
M-50093-001-3
M-2020-0651-1
M-2020-0291-9
M-2019-7401-9
M-50093-001-3
M-50093-002-0
M-50093-005-1
M-50093-007-5
M-50093-008-2
M-50093-010-5
M-50093-011-2
M-50093-012-9
M-50093-015-0
M-50093-016-7
M-50093-017-4
M-50093-018-1
M-50093-020-4
M-50093-021-1
M-50093-022-8
M-50093-023-5
M-50093-024-2
M-50093-025-9
M-50093-026-6
M-50093-027-3
M-50093-029-7
M-50093-030-3
M-50093-031-0
M-50093-032-7
M-50093-026-6
M-50093-028-0
M-50093-033-4
M-50093-029-7
M-50093-034-1
M-50093-035-8
M-50093-035-8
M-50093-032-7
M-50093-036-5
M-50093-024-2
M-50093-009-9
M-50093-038-9
M-50093-039-6
M-50093-016-7
M-50093-041-9

Business-ISMN-1.11/lib/000075500000000000000000000000001210020521400145225ustar00rootroot00000000000000Business-ISMN-1.11/lib/Data.pm000064400000000000000000000052731210020521400157400ustar00rootroot00000000000000package Business::ISBM::Data;
use strict;
# $Revision: 1.3 $
# $Id: Data.pm,v 1.3 2007/01/10 03:47:51 comdog Exp $

=head1 NAME

Business::ISMN::Data - data pack for Business::ISMN

=head1 SYNOPSIS

see Business::ISMN

=head1 DESCRIPTION

See L<Business::ISMN>.

=head1 AUTHOR

brian d foy, C<< <bdfoy@cpan.org> >>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2005-2007 brian d foy. All rights reserved.

This program is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

package Business::ISMN;
use strict;

use vars qw( %publisher_data @publisher_tuples );

%publisher_data = (
'AU' => [ ['075', undef], [2700, 2701], [67300, 67310], [720000, 720200], [9009500, 9009799] ],
'CA' => [ [53001, 53010], [706001, 706050], [9001301, 9001600] ],
'CY' => [ [720300, 720320], [9009800, 9009850] ],
'CZ' => [ [2600, 2605], [66050, 66100], [706500, 706600], [9004000, 9005000] ],
'DE' => [ ['000', '025'], [2000, 2150], [50000, 52000], [700000, 705000], [9000000, 9001000] ],
'DK' => [ [66130, 66140], [706750, 706800], [9001801, 9001900] ],
'ES' => [ [3500, 3507], [69200, 69224], [801200, 801219], [9013100, 9013119] ],
'FI' => [ ['042', undef], [55001, 55020], [706300, 706349], [9001601, 9001700] ],
'FR' => [ ['043', '048'], [2301, 2400], [56000, 56500] ],
'GB' => [ ['050', '060'], [2201, 2300], [57000, 57999], [708001, 709000], [9002000, 9002999] ],
'GH' => [ [9008000, 9008100] ],
'GR' => [ [69150, 69159], [801150, 801179], [9013030, 9013079] ],
'HR' => [ [706700, 706710], [9005201, 9005250] ],
'HU' => [ [55030, undef], [706251, 706260], [9005251, 9005260], ['080', undef] ],
'IT' => [ ['039', '041'], [2151, 2200], [52001, 53000], [705001, 706000], [9001001, 9001300] ],
'JP' => [ [65001, undef] ],
'LK' => [ [710000, 710100], [9006400, 9006500] ],
'LT' => [ [59995, 59999], [706201, 706250] ],
'LV' => [ [706650, 706660], [9005001, 9005100] ],
'NO' => [ ['065', undef], [2610, 2617], [66101, 66115], [706680, 706690], [9005101, 9005200] ],
'PT' => [ [3000, undef], [707700, 707750], [9007500, 9007600] ],
'RU' => [ [66000, 66055] ],
'SE' => [ ['070', undef], [66150, 66170], [706850, 706900], [9006000, 9006200] ],
'SI' => [ [709001, 709100], [9009000, 9009100] ],
'SK' => [ [68500, 68520], [9010001, 9010050] ],
'TR' => [ ['036', '037'], [3440, 3445], [69080, 69095], [801100, 801120], [9013000, 9013010] ],
'UA' => [ [707500, 707600], [9007000, 9007200] ],
'US' => [ ['081', '099'], [3005, 3205], [58000, 58199], [60001, 60002], [800000, 800199], [9012000, 9012099] ],
);

foreach my $key ( keys %publisher_data )
{
my @pairs = map { [ $key, @$_ ] } @{ $publisher_data{$key} };
push @publisher_tuples, @pairs;
}

@publisher_tuples = sort { $a->[1] <=> $b->[1] } @publisher_tuples;

1;
Business-ISMN-1.11/lib/ISMN.pm000064400000000000000000000332211210020521400156270ustar00rootroot00000000000000# $Id: ISMN.pm,v 1.11 2007/10/26 03:01:06 comdog Exp $
package Business::ISMN;
use strict;

use base qw(Exporter);
use subs qw(
_common_format _checksum is_valid_checksum
INVALID_PUBLISHER_CODE
BAD_CHECKSUM
GOOD_ISMN
BAD_ISMN
);
use vars qw( $VERSION @ISA @EXPORT_OK $debug %country_data
$MAX_COUNTRY_CODE_LENGTH );

use Carp qw(carp);
use Exporter;
use List::Util qw(sum);
use Tie::Cycle;
use Business::ISMN::Data;

my $debug = 0;

@EXPORT_OK = qw(is_valid_checksum ean_to_ismn ismn_to_ean
INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISMN BAD_ISMN);

($VERSION) = q$Revision: 1.11 $ =~ m/(\d+\.\d+)\s*$/;

sub INVALID_PUBLISHER_CODE { -3 };
sub BAD_CHECKSUM { -1 };
sub GOOD_ISMN { 1 };
sub BAD_ISMN { 0 };

my %Lengths = qw(
0 3
1 4
2 4
3 4
4 5
5 5
6 5
7 6
8 6
9 7
);

sub new
{
my $class = shift;
my $common_data = _common_format shift;

return unless defined $common_data;

my $self = {};
bless $self, $class;

$self->{'ismn'} = $common_data;
$self->{'positions'} = [1,undef,9];

# we don't know if we have a valid publisher code,
# so let's assume we don't
$self->{'valid'} = INVALID_PUBLISHER_CODE;

# let's check the publisher code.
my $code_length = $Lengths{ substr( $self->{'ismn'}, 1, 1 ) };
$self->{publisher_code} = substr(
$self->{'ismn'},
1,
$code_length
);

my $code_end = $code_length + 1;

$self->{'positions'}[1] = $code_end;

return $self unless $self->is_valid_publisher_code;

# we have a good publisher code, so
# assume we have a bad checksum until we check
$self->{'valid'} = BAD_CHECKSUM;

$self->{'article_code'} = substr( $self->{'ismn'}, $code_end, 9 - $code_end );
$self->{'checksum'} = substr( $self->{'ismn'}, -1, 1 );

$self->{'valid'} = is_valid_checksum( $self->{'ismn'} );

return $self;
}


#it's your fault if you muck with the internals yourself
# none of these take arguments
sub ismn () { my $self = shift; return $self->{'ismn'} }
sub is_valid () { my $self = shift; return $self->{'valid'} }
sub publisher () { my $self = shift; return $self->{'publisher'} }
sub publisher_code () { my $self = shift; return $self->{'publisher_code'} }
sub article_code () { my $self = shift; return $self->{'article_code'} }
sub checksum () { my $self = shift; return $self->{'checksum'} }
sub hyphen_positions () { my $self = shift; return @{$self->{'positions'}} }


sub fix_checksum
{
my $self = shift;

my $last_char = substr($self->{'ismn'}, 9, 1);
my $checksum = _checksum $self->ismn;

substr($self->{'ismn'}, 9, 1) = $checksum;

$self->_check_validity;

return 0 if $last_char eq $checksum;
return 1;
}

sub as_string
{
my $self = shift;
my $array_ref = shift;

#this allows one to override the positions settings from the
#constructor
$array_ref = $self->{'positions'} unless ref $array_ref eq 'ARRAY';

return unless $self->is_valid eq GOOD_ISMN;
my $ismn = $self->ismn;

foreach my $position ( sort { $b <=> $a } @$array_ref )
{
next if $position > 9 or $position < 1;
substr($ismn, $position, 0) = '-';
}

return $ismn;
}

sub as_ean
{
my $self = shift;

my $ismn = ref $self ? $self->as_string([]) : _common_format $self;

return unless ( defined $ismn and length $ismn == 10 );

# the M becomes a zero in bookland
substr( $ismn, 0, 1 ) = '0';

my $ean = '979' . substr($ismn, 0, 9);

my $sum = 0;
foreach my $index ( 0, 2, 4, 6, 8, 10 )
{
$sum += substr($ean, $index, 1);
$sum += 3 * substr($ean, $index + 1, 1);
}

#take the next higher multiple of 10 and subtract the sum.
#if $sum is 37, the next highest multiple of ten is 40. the
#check digit would be 40 - 37 => 3.
$ean .= ( 10 * ( int( $sum / 10 ) + 1 ) - $sum ) % 10;

return $ean;
}

sub is_valid_publisher_code
{
my $self = shift;
my $code = $self->publisher_code;

my $success = 0;

foreach my $tuple ( @publisher_tuples )
{
no warnings;
next if( defined $tuple->[2] and $code > $tuple->[2] );
last if $code < $tuple->[1];
if( $code >= $tuple->[1] and $code <= $tuple->[2] )
{
$success = 1;
$self->{'publisher'} = $tuple->[0];
last;
}
}

return $success;
}

sub is_valid_checksum
{
my $data = _common_format shift;

return BAD_ISMN unless defined $data;

return GOOD_ISMN if substr($data, 9, 1) eq _checksum $data;

return BAD_CHECKSUM;
}

sub ean_to_ismn
{
my $ean = shift;

$ean =~ s/[^0-9]//g;

return unless length $ean == 13;
return unless substr($ean, 0, 3) eq 979;

#XXX: fix to change leading 0 back to M
my $ismn = Business::ISMN->new( substr($ean, 3, 9) . '1' );

$ismn->fix_checksum;

return $ismn->as_string([]) if $ismn->is_valid;

return;
}


sub ismn_to_ean
{
my $ismn = _common_format shift;

return unless (defined $ismn and is_valid_checksum($ismn) eq GOOD_ISMN);

return as_ean($ismn);
}

sub png_barcode
{
my $self = shift;

my $ean = ismn_to_ean( $self->as_string([]) );

eval "use GD::Barcode::EAN13";
if( $@ )
{
carp "GD::Barcode::EAN13 required to make PNG barcodes";
return;
}

my $image = GD::Barcode::EAN13->new($ean)->plot->png;

return $image;
}

#internal function. you don't get to use this one.
sub _check_validity
{
my $self = shift;

if( is_valid_checksum $self->{'ismn'} eq GOOD_ISMN
and defined $self->{'publisher_code'} )
{
$self->{'valid'} = GOOD_ISMN;
}
else
{
$self->{'valid'} = INVALID_PUBLISHER_CODE
unless defined $self->{'publisher_code'};
$self->{'valid'} = GOOD_ISMN
unless is_valid_checksum $self->{'ismn'} ne GOOD_ISMN;
}
}

#internal function. you don't get to use this one.
sub _checksum
{
my $data = _common_format shift;

tie my $factor, 'Tie::Cycle', [ 1, 3 ];
return unless defined $data;

my $sum = 9;

foreach my $digit ( split //, substr( $data, 1, 8 ) )
{
my $mult = $factor;
$sum += $digit * $mult;
}


#return what the check digit should be
# the extra mod 10 turns 10 into 0.
my $checksum = ( 10 - ($sum % 10) ) % 10;

return $checksum;
}

#internal function. you don't get to use this one.
sub _common_format
{
#we want uppercase X's
my $data = uc shift;

# get rid of everything except decimal digits and X
# and leading M
$data =~ s/[^0-9M]//g;

return $1 if $data =~ m/
^
(
M
\d{9}
)
$
/x;

return;
}

1;

__END__

=head1 NAME

Business::ISMN - work with International Standard Music Numbers

=head1 SYNOPSIS

use Business::ISMN;

$ismn_object = new Business::ISMN('M021765430');
$ismn_object = new Business::ISMN('M-021-76543-0');

#print the ISMN with hyphens at positions specified
#by constructor
print $ismn_object->as_string;

#print the ISMN with hyphens at specified positions.
#this not does affect the default positions
print $ismn_object->as_string([]);

#print the publisher or publisher code
print $ismn->publisher;
print $ismn->publisher_code;

#check to see if the ISMN is valid
$ismn_object->is_valid;

#fix the ISMN checksum. BEWARE: the error might not be
#in the checksum!
$ismn_object->fix_checksum;

# create an EAN13 barcode in PNG format
$ismn_object->png_barcode;

#EXPORTABLE FUNCTIONS

use Business::ISMN qw( is_valid_checksum
ismn_to_ean ean_to_ismn );

#verify the checksum
if( is_valid_checksum('0123456789')
eq Business::ISMN::GOOD_ISMN )
{ ... }

#convert to EAN (European Article Number)
$ean = ismn_to_ean('1565921496');

#convert from EAN (European Article Number)
$ismn = ean_to_ismn('9781565921498');

=head1 DESCRIPTION

=head2 Methods

=over 4

=item new($ismn)

The constructor accepts a scalar representing the ISMN.

The string representing the ISMN may contain characters
other than C<[0-9mM]>, although these will be removed in the
internal representation. The resulting string must look
like an ISMN - the first character is an 'M' and the
following nine characters must be digits.

The constructor attempts to determine the country
code and the publisher code. If these data cannot
be determined, the constructor sets C<$obj-E<gt>is_valid>
to something other than C<GOOD_ISMN>.
An object is still returned and it is up to the program
to check C<$obj-E<gt>is_valid> for one of five values (which
may be exported on demand). The actual values of these
symbolic versions are the same as those from previous
versions of this module which used literal values.

Business::ISMN::INVALID_PUBLISHER_CODE
Business::ISMN::BAD_CHECKSUM
Business::ISMN::GOOD_ISMN
Business::ISMN::BAD_ISMN

The string passed as the ISMN need not be a valid ISMN as
long as it superficially looks like one. This allows one to
use the C<fix_checksum()> method. Despite the disclaimer in
the discussion of that method, the author has found it
extremely useful. One should check the validity of the ISMN
with C<is_valid()> rather than relying on the return value
of the constructor. If all one wants to do is check the
validity of an ISMN, one can skip the object-oriented
interface and use the C<is_valid_checksum()> function
which is exportable on demand.

If the constructor decides it cannot create an object, it
returns C<undef>. It may do this if the string passed as the
ISMN cannot be munged to the internal format meaning that it
does not even come close to looking like an ISMN.

=item ismn

Returns the ISMN as a string

=item publisher

Returns the country associated with the publisher code.

=item publisher_code

Returns the publisher code or C<undef> if no publisher
code was found.

=item article_code

Returns the article code or C<undef> if no article
code was found.

=item checksum

Returns the checksum or C<undef> if no publisher
code was found.

=item hyphen_positions

Returns the list of hyphen positions as determined from the
country and publisher codes. the C<as_string> method provides
a way to temporarily override these positions and to even
forego them altogether.

=item as_string(), as_string([])

Return the ISMN as a string. This function takes an
optional anonymous array (or array reference) that specifies
the placement of hyphens in the string. An empty anonymous array
produces a string with no hyphens. An empty argument list
automatically hyphenates the ISMN based on the discovered
publisher code. An ISMN that is not valid may
produce strange results.

The positions specified in the passed anonymous array
are only used for one method use and do not replace
the values specified by the constructor. The method
assumes that you know what you are doing and will attempt
to use the least three positions specified. If you pass
an anonymous array of several positions, the list will
be sorted and the lowest three positions will be used.
Positions less than 1 and greater than 9 are silently
ignored.

=item is_valid

Returns C<Business::ISMN::GOOD_ISMN> if the checksum is valid and the
country and publisher codes are defined.

Returns C<Business::ISMN::BAD_CHECKSUM> if the ISMN does not pass
the checksum test. The constructor accepts invalid ISMN's so that
they might be fixed with C<fix_checksum>.

Returns C<Business::ISMN::INVALID_PUBLISHER_CODE> if a publisher code
could not be determined.

Returns C<Business::ISMN::BAD_ISMN> if the string has no hope of ever
looking like a valid ISMN. This might include strings such as C<"abc">,
C<"123456">, and so on.

=item is_valid_publisher_code

Returns true if the publisher code is valid, and false otherwise.

=item fix_checksum()

Replace the tenth character with the checksum the
corresponds to the previous nine digits. This does not
guarantee that the ISMN corresponds to the product one
thinks it does, or that the ISMN corresponds to any product
at all. It only produces a string that passes the checksum
routine. If the ISMN passed to the constructor was invalid,
the error might have been in any of the other nine positions.

=item $obj-E<gt>as_ean()

Converts the ISMN to the equivalent EAN (European Article Number).
No pricing extension is added. Returns the EAN as a string. This
method can also be used as an exportable function since it checks
its argument list to determine what to do.

=item png_barcode()

Creates a PNG image of the EAN13 barcode which corresponds to the
ISMN. Returns the image as a string.

=back

=head2 EXPORTABLE FUNCTIONS

Some functions can be used without the object interface. These
do not use object technology behind the scenes.

=over 4

=item is_valid_checksum('M021765430')

Takes the ISMN string and runs it through the checksum
comparison routine. Returns C<Business::ISMN::GOOD_ISMN>
if the ISMN is valid, C<Business::ISMN::BAD_CHECKSUM> if the
string looks like an ISMN but has an invalid checksum, and
C<Business::ISMN::BAD_ISMN> if the string does not look like
an ISMN.

=item ismn_to_ean('M021765430')

Takes the ISMN string and converts it to the equivalent
EAN string. This function checks for a valid ISMN and will return
undef for invalid ISMNs, otherwise it returns the EAN as a string.
Uses as_ean internally, which checks its arguments to determine
what to do.

=item ean_to_ismn('9790021765439')

Takes the EAN string and converts it to the equivalent
ISMN string. This function checks for a valid ISMN and will return
undef for invalid ISMNs, otherwise it returns the EAN as a string.
Uses as_ean internally, which checks its arguments to determine
what to do.

=back

=head1 TO DO

* i need more ISMN numbers for tests

=head1 SOURCE AVAILABILITY

This source is part of a SourceForge project which always has the
latest sources in CVS, as well as all of the previous releases.

http://sourceforge.net/projects/brian-d-foy/

If, for some reason, I disappear from the world, one of the other
members of the project can shepherd this module appropriately.

=head1 AUTHOR

brian d foy, C<< <bdfoy@cpan.org> >>

=head1 COPYRIGHT AND LICENSE

Copyright (c) 2001-2007, brian d foy, All Rights Reserved.

You may redistribute this under the same terms as Perl itself.

=cut
Business-ISMN-1.11/perl-Business-ISMN.spec000064400000000000000000000020341210020521400201260ustar00rootroot00000000000000#
# - Business::ISMN -
# This spec file was automatically generated by cpan2rpm [ver: 2.028]
# (ALT Linux revision)
# The following arguments were used:
# Business::ISMN
# For more information on cpan2rpm please visit: http://perl.arix.com/
#

%define module Business-ISMN
%define m_distro Business-ISMN
%define m_name Business::ISMN
%define m_author_id unknown
%define _enable_test 1

Name: perl-Business-ISMN
Version: 1.11
Release: alt1

Summary: Work with International Standard Music Numbers

License: Artistic
Group: Development/Perl
Url: http://www.cpan.org

Packager: Kirill Maslinsky <kirill@altlinux.org>

BuildArch: noarch
Source: http://search.cpan.org//CPAN/authors/id/B/BD/BDFOY/%m_distro-%version.tar

BuildRequires: perl-Module-Build perl-Tie-Cycle

%description
None.

%prep
%setup -n %m_distro-%version
%build
%perl_vendor_build

%install
%perl_vendor_install

%files
%perl_vendor_privlib/Business/*

%changelog
* Thu Jan 24 2013 Kirill Maslinsky <kirill@altlinux.org> 1.11-alt1
- initial build for ALT Linux Sisyphus

Business-ISMN-1.11/t/000075500000000000000000000000001210020521400142175ustar00rootroot00000000000000Business-ISMN-1.11/t/ismn.t000064400000000000000000000055301210020521400153550ustar00rootroot00000000000000# $Revision: 1.3 $

use Test::More tests => 18;

use Business::ISMN;

my $GOOD_ISMN = "M706208053";
my $GOOD_ISMN_STRING = "M-706208-05-3";
my $GOOD_EAN = "9790706208053";
my $PUBLISHER = "706208";
my $BAD_CHECKSUM_ISMN = "M706208057";
my $BAD_PUBLISHER_ISMN = "M456922572";
my $NULL_ISMN = undef;
my $NO_GOOD_CHAR_ISMN = "abcdefghij";
my $SHORT_ISMN = "M156592";

# test to see if we can construct an object?
my $ismn = Business::ISMN->new( $GOOD_ISMN );
isa_ok( $ismn, 'Business::ISMN' );
is( $ismn->is_valid, Business::ISMN::GOOD_ISMN, "$GOOD_ISMN is valid" );
is( $ismn->publisher_code, $PUBLISHER, "$GOOD_ISMN has right publisher");
is( $ismn->as_string, $GOOD_ISMN_STRING, "$GOOD_ISMN stringifies correctly");
is( $ismn->as_string([]), $GOOD_ISMN, "$GOOD_ISMN stringifies correctly");

# and bad checksums?
$ismn = Business::ISMN->new( $BAD_CHECKSUM_ISMN );
isa_ok( $ismn, 'Business::ISMN' );
is( $ismn->is_valid, Business::ISMN::BAD_CHECKSUM,
"$BAD_CHECKSUM_ISMN is invalid" );

#after this we should have a good ISMN
$ismn->fix_checksum;
is( $ismn->is_valid, Business::ISMN::GOOD_ISMN,
"$BAD_CHECKSUM_ISMN had checksum fixed" );

# bad publisher code?
$ismn = Business::ISMN->new( $BAD_PUBLISHER_ISMN );
isa_ok( $ismn, 'Business::ISMN' );
is( $ismn->is_valid, Business::ISMN::INVALID_PUBLISHER_CODE,
"$BAD_PUBLISHER_ISMN is invalid" );

# convert to EAN?
$ismn = Business::ISMN->new( $GOOD_ISMN );
is( $ismn->as_ean, $GOOD_EAN, "$GOOD_ISMN converted to EAN" );

# do exportable functions do the right thing?
{
my $SHORT_ISMN = $GOOD_ISMN;
chop $SHORT_ISMN;

my $valid = Business::ISMN::is_valid_checksum( $SHORT_ISMN );
is( $valid, Business::ISMN::BAD_ISMN, "Catch short ISMN string" );
}

is( Business::ISMN::is_valid_checksum( $GOOD_ISMN ),
Business::ISMN::GOOD_ISMN, 'is_valid_checksum with good ISMN' );
is( Business::ISMN::is_valid_checksum( $BAD_CHECKSUM_ISMN ),
Business::ISMN::BAD_CHECKSUM, 'is_valid_checksum with bad checksum ISMN' );
is( Business::ISMN::is_valid_checksum( $NULL_ISMN ),
Business::ISMN::BAD_ISMN, 'is_valid_checksum with bad ISMN' );
is( Business::ISMN::is_valid_checksum( $NO_GOOD_CHAR_ISMN ),
Business::ISMN::BAD_ISMN, 'is_valid_checksum with no good char ISMN' );
is( Business::ISMN::is_valid_checksum( $SHORT_ISMN ),
Business::ISMN::BAD_ISMN, 'is_valid_checksum with short ISMN' );


SKIP:
{
my $file = "ismns.txt";
open FILE, $file or
skip( "Could not read $file: $!", 1, 'Need $file');

print STDERR "\nChecking ISMNs... (this may take a bit)\n";

my $bad = 0;
while( <FILE> )
{
chomp;
next unless /\S+/;
my $ismn = Business::ISMN->new( $_ );

my $result = $ismn->is_valid;
$bad++ unless $result eq Business::ISMN::GOOD_ISMN;
print STDERR "$_ is not valid? [$result]\n"
unless $result eq Business::ISMN::GOOD_ISMN;
}

close FILE;

ok( $bad == 0, "Match ISMNs" );
}
Business-ISMN-1.11/t/load.t000064400000000000000000000004151210020521400153230ustar00rootroot00000000000000# $Id: load.t,v 1.3 2004/09/16 16:02:59 comdog Exp $
BEGIN {
@classes = qw(Business::ISMN Business::ISMN::Data);
}

use Test::More tests => scalar @classes;

foreach my $class ( @classes )
{
print "bail out! Could not compile $class\n" unless use_ok( $class );
}
Business-ISMN-1.11/t/pod.t000064400000000000000000000002641210020521400151700ustar00rootroot00000000000000#$Id: pod.t,v 1.2 2004/09/01 20:42:05 comdog Exp $
use Test::More;
eval "use Test::Pod 1.00";
plan skip_all => "Test::Pod 1.00 required for testing POD" if $@;
all_pod_files_ok();
Business-ISMN-1.11/t/pod_coverage.t000064400000000000000000000004631210020521400170440ustar00rootroot00000000000000# : pod_coverage.t,v 1.1 2005/03/04 13:08:26 comdog Exp

use Test::More;
eval "use Test::Pod::Coverage";

if( $@ )
{
plan skip_all => "Test::Pod::Coverage required for testing POD";
}
else
{
plan tests => 1;

pod_coverage_ok( "Business::ISMN",
{
trustme => [ qr/^[A-Z_]+$/ ],
}
);
}
Business-ISMN-1.11/t/prereq.t000064400000000000000000000002611210020521400157010ustar00rootroot00000000000000#$Id: prereq.t,v 1.2 2004/09/01 20:42:45 comdog Exp $
use Test::More;
eval "use Test::Prereq";
plan skip_all => "Test::Prereq required to test dependencies" if $@;
prereq_ok();
Business-ISMN-1.11/t/test_manifest000064400000000000000000000001501210020521400170030ustar00rootroot00000000000000# $Id: test_manifest,v 1.4 2005/03/08 22:18:22 comdog Exp $
load.t
pod.t
pod_coverage.t
prereq.t
ismn.t
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin