Business-ISMN-1.205/0000755000076500000240000000000014777040441013046 5ustar brianstaffBusiness-ISMN-1.205/LICENSE0000644000076500000240000002173514777040440014062 0ustar brianstaffThe Business::ISMN module is licensed under the same terms as perl itself, under the Artistic License 2.0. Artistic License 2.0 Copyright (c) 2000-2006, The Perl Foundation. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble ******** This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. Definitions *********** "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. "You" and "your" means any person who would like to copy, distribute, or modify the Package. "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. "Source" form means the source code, documentation source, and configuration files for the Package. "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. Permission for Use and Modification Without Distribution ******************************************************** (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. Permissions for Redistribution of the Standard Version ****************************************************** (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. Distribution of Modified Versions of the Package as Source ********************************************************** (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under (i) the Original License or (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. Distribution of Compiled Forms of the Standard Version or Modified ****************************************************************** Versions without the Source *************************** (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. Aggregating or Linking the Package ********************************** (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. Items That are Not Considered Part of a Modified Version ******************************************************** (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. General Provisions ****************** (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. (14) Disclaimer of Warranty: THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS' AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. Business-ISMN-1.205/Changes0000644000076500000240000000264514777040440014347 0ustar brianstaffRevision history for Perl module Business::ISMN 1.205 2025-04-13T22:56:31Z * require a newer version.pm for v5.10.1 tests 1.204 2024-02-11T06:50:27Z * refresh distro, update email address, move to BRIANDFOY 1.203 2023-03-16T11:10:05Z * Fix ean_to_ismn, which was not adding the M to the start. 1.202 2021-02-16T12:43:17Z * Freshen distro, add Github Actions 1.201 2018-10-18T15:27:35Z * Change publisher() to country() (because that's what it is). The old method names are still there but carp. 1.132 2018-07-14T00:59:12Z * Clarify that it's the Artistic License 2.0 1.131 2016-12-05T19:16:19Z * Remove the prereq test, which I'll do locally instead of everywhere. 1.13 - 2014-11-28 * Reqire a recent Tie::Cycle. Some CPAN testers picked up a ghost version somehow. 1.12 - 2014-11-21 * RT #100506 : Fix package name * Modernize distro 1.11 - 2007-10-25 * distro adjustments. no big whoop. 1.10 - 2007-01-09 * updated copyright and license info * no code changes, so no need to upgrade 1.08 - 2006-06-05 * fix-ups to dist. No need to upgrade. 1.07 - 2006-05-18 * cleanups for distro and kwalitee. no need to upgrade. 1.6 - 2005-03-08 * Added a POD coverage test and fixed up the problems it found 1.5 - 2004-09-16 * distro cleanups: no need to upgrade 1.2 - 2002-10-09 * cleaned up distribution---no code changes 1.2 - 2002-09-09 * fixed checksum routine 1.1 - 2002-09-09 * first version of Business::ISMN Business-ISMN-1.205/MANIFEST0000644000076500000240000000064514777040441014204 0ustar brianstaffChanges examples/README INSTALL.SKIP ismns.txt lib/Business/ISMN.pm lib/Business/ISMN/Data.pm LICENSE Makefile.PL MANIFEST This list of files MANIFEST.SKIP README.pod SECURITY.md t/ismn.t t/load.t t/pod.t t/pod_coverage.t t/test_manifest xt/changes.t META.yml Module YAML meta-data (added by MakeMaker) META.json Module JSON meta-data (added by MakeMaker) Business-ISMN-1.205/t/0000755000076500000240000000000014777040440013310 5ustar brianstaffBusiness-ISMN-1.205/t/pod.t0000644000076500000240000000020114777040440014250 0ustar brianstaffuse 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.205/t/load.t0000644000076500000240000000024314777040440014413 0ustar brianstaffuse 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.205/t/ismn.t0000644000076500000240000000570414777040440014451 0ustar brianstaffuse Test::More tests => 19; use Business::ISMN; my $GOOD_ISMN = 'M706208053'; my $GOOD_ISMN_STRING = 'M-706208-05-3'; my $GOOD_EAN = '9790706208053'; my $COUNTRY_STRING = 'LT'; my $PUBLISHER_CODE = '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->country, $COUNTRY_STRING, "$GOOD_ISMN has publisher string"); is( $ismn->publisher_code, $PUBLISHER_CODE, "$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.205/t/test_manifest0000644000076500000240000000004314777040440016075 0ustar brianstaffload.t pod.t pod_coverage.t ismn.t Business-ISMN-1.205/t/pod_coverage.t0000644000076500000240000000037014777040440016132 0ustar brianstaffuse 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.205/xt/0000755000076500000240000000000014777040440013500 5ustar brianstaffBusiness-ISMN-1.205/xt/changes.t0000644000076500000240000000020314777040440015270 0ustar brianstaffuse Test::More; eval 'use Test::CPAN::Changes'; plan skip_all => 'Test::CPAN::Changes required for this test' if $@; changes_ok(); Business-ISMN-1.205/README.pod0000644000076500000240000001135714777040440014515 0ustar brianstaff=pod =encoding utf8 =for HTML =for HTML =for HTML =for HTML =for HTML Coverage Status =for HTML =for HTML =head1 The Business::ISMN module This is the I for the L Perl module. You're probably looking at this because you don't know where else to find what you're looking for. Read this once and you might never have to read one again for any Perl module. =head2 Documentation To read about L, look at the embedded documentation in the module itself. Inside the distribution, you can format it with L: % perldoc lib/Business/ISMN.pm If you have already installed the module, you can specify the module name instead of the file location: % perldoc Business::ISMN You can read the documentation and inspect the meta data at L. The standard module documentation has example uses in the SYNOPSIS section, but you can also look in the I directory (if it's there), or look at the test files in I. =head2 Installation You can install this module with a CPAN client, which will resolve and install the dependencies: % cpan Business::ISMN % cpanm Business::ISMN You can also install directly from the distribution directory, which will also install the dependencies: % cpan . % cpanm . You could install just this module manually: % perl Makefile.PL % make % make test % make install You probably don't want to do that unless you're fiddling with the module and only want to run the tests without installing anything. =head2 Source location The meta data, such as the source repository and bug tracker, is in I or the I files it creates. You can find that on those CPAN web interfaces, but you can also look at files directly in the source repository: L If you find a problem, file a ticket in the L. There are also backup repositories hosted on other services. These reflect the state of the main repo and exist only for redundancy: =over 4 =item * L =item * L =item * L =back =head2 GitHub Attestations This distribution now uses L, which allow you to verify that the archive file you have was made from the official repo. You need a GitHub account and the L. # download the distro file from GitHub, MetaCPAN, or a CPAN mirror $ gh auth login ...follow instructions... $ gh attestation verify Business-ISMN-1.23.tar.gz --owner briandfoy =head2 Getting help Although I'm happy to hear from module users in private email, that's the best way for me to forget to do something. Besides the issue trackers, you can find help at L or L, both of which have many competent Perlers who can answer your question, almost in real time. They might not know the particulars of this module, but they can help you diagnose your problem. You might like to read L. =head2 Copyright and License You should have received a I file, but the license is also noted in the module files. About the only thing you can't do is pretend that you wrote code that you didn't. =head2 Good luck! Enjoy, brian d foy, briandfoy@pobox.com =cut Business-ISMN-1.205/MANIFEST.SKIP0000644000076500000240000000213414777040440014743 0ustar brianstaff #!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 \.?appveyor.yml \.releaserc \.lwpcookies Business-.* hacks/ \bMANIFEST\s\d \bChanges\s\d \.icloud$ \A\.github\b \.gitattributes\b Business-ISMN-1.205/examples/0000755000076500000240000000000014777040440014663 5ustar brianstaffBusiness-ISMN-1.205/examples/README0000644000076500000240000000010514777040440015537 0ustar brianstaffSee the tests in the t/ directory for examples until I add some more.Business-ISMN-1.205/META.yml0000664000076500000240000000152014777040441014317 0ustar brianstaff--- abstract: 'work with International Standard Music Numbers' author: - 'brian d foy ' build_requires: Test::More: '1' version: '0.86' configure_requires: ExtUtils::MakeMaker: '6.64' File::Spec::Functions: '0' dynamic_config: 1 generated_by: 'ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010' license: artistic_2 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: '1.4' name: Business-ISMN no_index: directory: - t - inc requires: List::Util: '0' Tie::Cycle: '1.21' perl: '5.008' resources: bugtracker: https://github.com/briandfoy/business-ismn/issues homepage: https://github.com/briandfoy/business-ismn repository: https://github.com/briandfoy/business-ismn version: '1.205' x_serialization_backend: 'CPAN::Meta::YAML version 0.018' Business-ISMN-1.205/ismns.txt0000644000076500000240000000144114777040440014737 0ustar brianstaffM-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.205/lib/0000755000076500000240000000000014777040440013613 5ustar brianstaffBusiness-ISMN-1.205/lib/Business/0000755000076500000240000000000014777040440015406 5ustar brianstaffBusiness-ISMN-1.205/lib/Business/ISMN/0000755000076500000240000000000014777040440016154 5ustar brianstaffBusiness-ISMN-1.205/lib/Business/ISMN/Data.pm0000644000076500000240000000531114777040440017363 0ustar brianstaffuse 5.008; package Business::ISMN::Data; use strict; our $VERSION = '1.205'; =encoding utf8 =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 © 2005-2025, brian d foy . All rights reserved. This program is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. =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.205/lib/Business/ISMN.pm0000755000076500000240000003363514777040440016527 0ustar brianstaffuse 5.008; package Business::ISMN; use strict; use subs qw( _common_format _checksum is_valid_checksum INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISMN BAD_ISMN ); use vars qw( $debug %country_data $MAX_COUNTRY_CODE_LENGTH ); use Carp qw(carp); use Exporter qw(import); use List::Util qw(sum); use Tie::Cycle; use Business::ISMN::Data; my $debug = 0; our @EXPORT_OK = qw(is_valid_checksum ean_to_ismn ismn_to_ean INVALID_PUBLISHER_CODE BAD_CHECKSUM GOOD_ISMN BAD_ISMN); our $VERSION = '1.205'; 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, $raw_ismn ) = @_; my $common_data = _common_format $raw_ismn; 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_country_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 country () { my $self = shift; return $self->{'country'} } sub publisher () { carp "publisher is deprecated. Use country instead."; &country } 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_country_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->{'country'} = $tuple->[0]; last; } } return $success; } sub is_valid_publisher_code { carp "is_valid_publisher_code is deprecated. Use is_valid_country_code"; &is_valid_country_code } 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, 4) eq 9790; #XXX: fix to change leading 0 back to M my $ismn = Business::ISMN->new( 'M' . substr($ean, 4, 9) ); $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__ =encoding utf8 =head1 NAME Business::ISMN - work with International Standard Music Numbers =head1 SYNOPSIS use Business::ISMN; $ismn_object = Business::ISMN->new('M021765430'); $ismn_object = Business::ISMN->new('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 publication country or publisher code print $ismn->country; # two letter country string print $ismn->publisher_code; # digits #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 country =item publisher Returns the country associated with the publisher code. This method was formerly called C (and that still works), but it's really returns a two letter country 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_country_code =item is_valid_publisher_code Returns true if the country code is valid, and false otherwise. This method was formerly called C. That's deprecated but still there. =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 =over 4 =item * I need more ISMN numbers for tests =back =head1 SOURCE AVAILABILITY This source is in Github: https://github.com/briandfoy/business-ismn/ =head1 AUTHOR brian d foy, C<< >> =head1 COPYRIGHT AND LICENSE Copyright © 2001-2025, brian d foy . All rights reserved. You may redistribute this under the terms of the Artistic License 2.0. =cut Business-ISMN-1.205/Makefile.PL0000644000076500000240000000525714777040440015030 0ustar brianstaffpackage Business::ISMN; use strict; use warnings; =encoding utf8 =head1 The build file for Business::ISMN This build file is a modulino; it works as both a build script and a module. To build the distribution, run this file normally: % perl Makefile.PL But, it's more interesting than that. You can load it with C and call C to get the data structure it passes to C: my $package = require '/path/to/Makefile.PL'; my $arguments = $package->arguments; Note that C-ing a file makes an entry in C<%INC> for exactly that name. If you try to C another file with the same name, even from a different path, C thinks it has already loaded the file. As such, I recommend you always require the full path to the file. The return value of the C is a package name (in this case, the name of the main module. Use that to call the C method. Even if this distribution needs a higher version of Perl, this bit only needs v5.8. You can play with the data structure with a primitive Perl. =cut use File::Spec::Functions qw(catfile); my $module = __PACKAGE__; ( my $dist = $module ) =~ s/::/-/g; my $github = 'https://github.com/briandfoy/business-ismn'; my $main_file = catfile( 'lib', split /::/, "$module.pm" ); my %WriteMakefile = ( 'MIN_PERL_VERSION' => '5.008', 'NAME' => $module, 'VERSION_FROM' => $main_file, 'ABSTRACT_FROM' => $main_file, 'LICENSE' => 'artistic_2', 'AUTHOR' => 'brian d foy ', 'CONFIGURE_REQUIRES' => { 'ExtUtils::MakeMaker' => '6.64', 'File::Spec::Functions' => '0', }, 'BUILD_REQUIRES' => { }, 'TEST_REQUIRES' => { 'Test::More' => '1', 'version' => '0.86', }, 'PREREQ_PM' => { 'List::Util' => '0', 'Tie::Cycle' => '1.21', }, 'META_MERGE' => { 'meta-spec' => { version => 2 }, resources => { repository => { type => 'git', url => $github, web => $github, }, bugtracker => { web => "$github/issues", }, homepage => $github, }, }, clean => { FILES => "$dist-*" }, ); sub arguments { \%WriteMakefile } do_it() unless caller; sub do_it { require File::Spec; my $MM ='ExtUtils::MakeMaker'; my $MM_version = eval{ "$MM " . $WriteMakefile{'CONFIGURE_REQUIRES'}{'ExtUtils::MakeMaker'} } || "$MM 6.64"; eval "use $MM_version; 1" or die "Could not load $MM_version: $@"; eval "use Test::Manifest 1.21" if -e File::Spec->catfile( qw(t test_manifest) ); my $arguments = arguments(); my $minimum_perl = $arguments->{MIN_PERL_VERSION} || '5.008'; eval "require $minimum_perl;" or die $@; WriteMakefile( %$arguments ); } no warnings; __PACKAGE__; Business-ISMN-1.205/INSTALL.SKIP0000644000076500000240000000015614777040440014645 0ustar brianstaffREADME\.pod README.* # things that might be in local directories after fooling # around with them \.DS_Store Business-ISMN-1.205/SECURITY.md0000644000076500000240000000230714777040440014640 0ustar brianstaff# Security Policy for Business::ISMN ## Reporting security issues **Do not report security problems on public forums or in repository issues.** Privately report vulnerabilities to the maintainers listed at the end of this document. Include as many details as possible to reproduce the issue, including code samples or test cases. Check that your report does not expose any of your sensitive data, such as passwords, tokens, or other secrets. You do not need to have a solution or fix. Depending on the issue, CPANSec may be notified. Depending on the issue, CPANSec may be notified. You can also privately report issues to the CPAN Security Group (CPANSec) . This is especially important if you think a vulnerability is being actively exploited. CPANSec may report the issue to the relevant authorities. See [Report a Security Issue](https://security.metacpan.org/docs/report.html). ## Response to reports The maintainers aim to respond to all reports within one day, but this may be affected by life and other things that happen to people who maintain open source code. A new release will be provided as soon as possible. ## Maintainers * brian d foy, Business-ISMN-1.205/META.json0000664000076500000240000000275014777040441014475 0ustar brianstaff{ "abstract" : "work with International Standard Music Numbers", "author" : [ "brian d foy " ], "dynamic_config" : 1, "generated_by" : "ExtUtils::MakeMaker version 7.70, CPAN::Meta::Converter version 2.150010", "license" : [ "artistic_2" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "Business-ISMN", "no_index" : { "directory" : [ "t", "inc" ] }, "prereqs" : { "build" : { "requires" : {} }, "configure" : { "requires" : { "ExtUtils::MakeMaker" : "6.64", "File::Spec::Functions" : "0" } }, "runtime" : { "requires" : { "List::Util" : "0", "Tie::Cycle" : "1.21", "perl" : "5.008" } }, "test" : { "requires" : { "Test::More" : "1", "version" : "0.86" } } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/briandfoy/business-ismn/issues" }, "homepage" : "https://github.com/briandfoy/business-ismn", "repository" : { "type" : "git", "url" : "https://github.com/briandfoy/business-ismn", "web" : "https://github.com/briandfoy/business-ismn" } }, "version" : "1.205", "x_serialization_backend" : "JSON::PP version 4.16" }