Business-ISMN-1.13/000755 000765 000024 00000000000 12436005612 014232 5ustar00brianstaff000000 000000 Business-ISMN-1.13/Changes000644 000765 000024 00000001700 12436005610 015521 0ustar00brianstaff000000 000000 # Changes for Business::ISMN 1.13 - Fri Nov 28 00:42:54 2014 * Reqire a recent Tie::Cycle. Some CPAN testers picked up a ghost version somehow. 1.12 - Fri Nov 21 23:06:24 2014 * RT #100506 : Fix package name * Modernize distro 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.13/examples/000755 000765 000024 00000000000 12436005611 016047 5ustar00brianstaff000000 000000 Business-ISMN-1.13/ismns.txt000644 000765 000024 00000001441 12436005610 016122 0ustar00brianstaff000000 000000 M-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.13/lib/000755 000765 000024 00000000000 12436005611 014777 5ustar00brianstaff000000 000000 Business-ISMN-1.13/LICENSE000644 000765 000024 00000000077 12436005610 015241 0ustar00brianstaff000000 000000 You can use Business::ISMN under the same terms as Perl itself.Business-ISMN-1.13/Makefile.PL000644 000765 000024 00000001431 12436005610 016201 0ustar00brianstaff000000 000000 require 5.008; use ExtUtils::MakeMaker 6.65; eval "use Test::Manifest 1.21"; WriteMakefile( 'NAME' => 'Business::ISMN', 'VERSION_FROM' => 'lib/Business/ISMN.pm', 'LICENSE' => 'perl', 'AUTHOR' => 'brian d foy ', 'ABSTRACT' => 'Work with International Standard Music Numbers', 'PREREQ_PM' => { 'List::Util' => '0', 'Tie::Cycle' => '1.21', }, 'TEST_REQUIRES' => { 'Test::More' => '0.95', }, 'META_MERGE' => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => 'https://github.com/briandfoy/business--isbn.git', web => 'https://github.com/briandfoy/business--isbn', }, }, }, clean => { FILES => 'Business-ISMN-*' }, ); Business-ISMN-1.13/MANIFEST000644 000765 000024 00000000473 12436005612 015367 0ustar00brianstaff000000 000000 Changes examples/README ismns.txt lib/Business/ISMN.pm lib/Business/ISMN/Data.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP META.yml README t/ismn.t t/load.t t/pod.t t/pod_coverage.t t/prereq.t t/test_manifest META.json Module JSON meta-data (added by MakeMaker) Business-ISMN-1.13/MANIFEST.SKIP000644 000765 000024 00000002022 12436005610 016122 0ustar00brianstaff000000 000000 #!start included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP # Avoid version control files. \bRCS\b \bCVS\b \bSCCS\b ,v$ \B\.svn\b \B\.git\b \B\.gitignore\b \b_darcs\b \B\.cvsignore$ # Avoid VMS specific MakeMaker generated files \bDescrip.MMS$ \bDESCRIP.MMS$ \bdescrip.mms$ # Avoid Makemaker generated and utility files. \bMANIFEST\.bak \bMakefile$ \bblib/ \bMakeMaker-\d \bpm_to_blib\.ts$ \bpm_to_blib$ \bblibdirs\.ts$ # 6.18 through 6.25 generated this # Avoid Module::Build generated and utility files. \bBuild$ \b_build/ \bBuild.bat$ \bBuild.COM$ \bBUILD.COM$ \bbuild.com$ # Avoid temp and backup files. ~$ \.old$ \#$ \b\.# \.bak$ \.tmp$ \.# \.rej$ # Avoid OS-specific files/dirs # Mac OSX metadata \B\.DS_Store # Mac OSX SMB mount metadata files \B\._ # Avoid Devel::Cover and Devel::CoverX::Covered files. \bcover_db\b \bcovered\b # Avoid MYMETA files ^MYMETA\. #!end included /usr/local/perls/perl-5.18.1/lib/5.18.1/ExtUtils/MANIFEST.SKIP \.travis\.yml \.releaserc \.lwpcookies Business-.* hacks/ Business-ISMN-1.13/META.json000664 000765 000024 00000001412 12436005612 015653 0ustar00brianstaff000000 000000 { "abstract" : "Work with International Standard Music Numbers", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.132830", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : "2" }, "name" : "Business-ISMN", "no_index" : { "directory" : [ "t", "inc" ] }, "release_status" : "stable", "resources" : { "repository" : { "type" : "git", "url" : "https://github.com/briandfoy/business--isbn.git", "web" : "https://github.com/briandfoy/business--isbn" } }, "version" : "1.13" } Business-ISMN-1.13/META.yml000664 000765 000024 00000000743 12436005612 015511 0ustar00brianstaff000000 000000 --- abstract: 'Work with International Standard Music Numbers' author: - 'brian d foy ' build_requires: {} dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 6.66, CPAN::Meta::Converter version 2.132830' license: perl meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 name: Business-ISMN no_index: directory: - t - inc resources: repository: https://github.com/briandfoy/business--isbn.git version: 1.13 Business-ISMN-1.13/README000644 000765 000024 00000001021 12436005610 015102 0ustar00brianstaff000000 000000 $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.13/t/000755 000765 000024 00000000000 12436005611 014474 5ustar00brianstaff000000 000000 Business-ISMN-1.13/t/ismn.t000644 000765 000024 00000005504 12436005610 015632 0ustar00brianstaff000000 000000 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( ) { 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.13/t/load.t000644 000765 000024 00000000243 12436005610 015576 0ustar00brianstaff000000 000000 use Test::More 0.95; my @classes = qw(Business::ISMN Business::ISMN::Data); foreach my $class ( @classes ) { use_ok( $class ) or BAILOUT(); } done_testing(); Business-ISMN-1.13/t/pod.t000644 000765 000024 00000000201 12436005610 015433 0ustar00brianstaff000000 000000 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.13/t/pod_coverage.t000644 000765 000024 00000000370 12436005610 017315 0ustar00brianstaff000000 000000 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.13/t/prereq.t000644 000765 000024 00000000173 12436005610 016157 0ustar00brianstaff000000 000000 use Test::More; eval "use Test::Prereq"; plan skip_all => "Test::Prereq required to test dependencies" if $@; prereq_ok(); Business-ISMN-1.13/t/test_manifest000644 000765 000024 00000000054 12436005610 017262 0ustar00brianstaff000000 000000 load.t pod.t pod_coverage.t prereq.t ismn.t Business-ISMN-1.13/lib/Business/000755 000765 000024 00000000000 12436005611 016572 5ustar00brianstaff000000 000000 Business-ISMN-1.13/lib/Business/ISMN/000755 000765 000024 00000000000 12436005611 017340 5ustar00brianstaff000000 000000 Business-ISMN-1.13/lib/Business/ISMN.pm000644 000765 000024 00000032573 12436005610 017707 0ustar00brianstaff000000 000000 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) = '1.13'; 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 { no warnings qw(uninitialized); #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-Eis_valid> to something other than C. An object is still returned and it is up to the program to check C<$obj-Eis_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 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 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 function which is exportable on demand. If the constructor decides it cannot create an object, it returns C. 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 if no publisher code was found. =item article_code Returns the article code or C if no article code was found. =item checksum Returns the checksum or C 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 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 if the checksum is valid and the country and publisher codes are defined. Returns C if the ISMN does not pass the checksum test. The constructor accepts invalid ISMN's so that they might be fixed with C. Returns C if a publisher code could not be determined. Returns C 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-Eas_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 if the ISMN is valid, C if the string looks like an ISMN but has an invalid checksum, and C 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 in Github: http://github.com/briandfoy/business--isbn/tree/master =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright (c) 2001-2014, brian d foy, All Rights Reserved. You may redistribute this under the same terms as Perl itself. =cut Business-ISMN-1.13/lib/Business/ISMN/Data.pm000644 000765 000024 00000005213 12436005610 020547 0ustar00brianstaff000000 000000 package Business::ISMN::Data; use strict; our $VERSION = '1.13'; =head1 NAME Business::ISMN::Data - data pack for Business::ISMN =head1 SYNOPSIS see Business::ISMN =head1 DESCRIPTION See L. =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright (c) 2005-2014 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.13/examples/README000644 000765 000024 00000000105 12436005610 016722 0ustar00brianstaff000000 000000 See the tests in the t/ directory for examples until I add some more.