r58827 - in /branches/upstream/libbusiness-issn-perl: ./ current/ current/examples/ current/lib/ current/t/

lars at users.alioth.debian.org lars at users.alioth.debian.org
Thu Jun 3 22:34:09 UTC 2010


Author: lars
Date: Thu Jun  3 22:33:49 2010
New Revision: 58827

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=58827
Log:
[svn-inject] Installing original source of libbusiness-issn-perl

Added:
    branches/upstream/libbusiness-issn-perl/
    branches/upstream/libbusiness-issn-perl/current/
    branches/upstream/libbusiness-issn-perl/current/Changes
    branches/upstream/libbusiness-issn-perl/current/LICENSE
    branches/upstream/libbusiness-issn-perl/current/MANIFEST
    branches/upstream/libbusiness-issn-perl/current/META.yml
    branches/upstream/libbusiness-issn-perl/current/Makefile.PL
    branches/upstream/libbusiness-issn-perl/current/README
    branches/upstream/libbusiness-issn-perl/current/examples/
    branches/upstream/libbusiness-issn-perl/current/examples/placeholder.pl
    branches/upstream/libbusiness-issn-perl/current/lib/
    branches/upstream/libbusiness-issn-perl/current/lib/ISSN.pm
    branches/upstream/libbusiness-issn-perl/current/t/
    branches/upstream/libbusiness-issn-perl/current/t/issn.t   (with props)
    branches/upstream/libbusiness-issn-perl/current/t/load.t
    branches/upstream/libbusiness-issn-perl/current/t/pod.t
    branches/upstream/libbusiness-issn-perl/current/t/pod_coverage.t
    branches/upstream/libbusiness-issn-perl/current/t/prereq.t
    branches/upstream/libbusiness-issn-perl/current/t/test_manifest

Added: branches/upstream/libbusiness-issn-perl/current/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/Changes?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/Changes (added)
+++ branches/upstream/libbusiness-issn-perl/current/Changes Thu Jun  3 22:33:49 2010
@@ -1,0 +1,8 @@
+Revision history for Perl extension Business::ISSN.
+
+0.91 - Wed Aug  6 06:30:10 2008
+	* module now maintained by brian d foy
+	* modernized, fully tested, and fixed RT #38174
+
+0.20  Tue Feb  9 11:09:41 1999
+	- 1st version

Added: branches/upstream/libbusiness-issn-perl/current/LICENSE
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/LICENSE?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/LICENSE (added)
+++ branches/upstream/libbusiness-issn-perl/current/LICENSE Thu Jun  3 22:33:49 2010
@@ -1,0 +1,1 @@
+You can use Business::ISSN under the same terms as Perl itself.

Added: branches/upstream/libbusiness-issn-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/MANIFEST?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/MANIFEST (added)
+++ branches/upstream/libbusiness-issn-perl/current/MANIFEST Thu Jun  3 22:33:49 2010
@@ -1,0 +1,14 @@
+Changes
+examples/placeholder.pl
+lib/ISSN.pm
+LICENSE
+Makefile.PL
+MANIFEST			This list of files
+README
+t/issn.t
+t/load.t
+t/pod.t
+t/pod_coverage.t
+t/prereq.t
+t/test_manifest
+META.yml                                 Module meta-data (added by MakeMaker)

Added: branches/upstream/libbusiness-issn-perl/current/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/META.yml?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/META.yml (added)
+++ branches/upstream/libbusiness-issn-perl/current/META.yml Thu Jun  3 22:33:49 2010
@@ -1,0 +1,14 @@
+--- #YAML:1.0
+name:                Business-ISSN
+version:             0.91
+abstract:            Work with International Standard Serial Numbers
+license:             perl
+author:              
+    - brian d foy <bdfoy at cpan.org>
+generated_by:        ExtUtils::MakeMaker version 6.44
+distribution_type:   module
+requires:     
+    Test::More:                    0
+meta-spec:
+    url:     http://module-build.sourceforge.net/META-spec-v1.3.html
+    version: 1.3

Added: branches/upstream/libbusiness-issn-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/Makefile.PL?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/Makefile.PL (added)
+++ branches/upstream/libbusiness-issn-perl/current/Makefile.PL Thu Jun  3 22:33:49 2010
@@ -1,0 +1,29 @@
+# $Id: Makefile.PL,v 1.4 2004/07/04 17:04:17 comdog Exp $
+use ExtUtils::MakeMaker;
+
+require 5.006;
+
+eval "use Test::Manifest 1.14";
+
+WriteMakefile(
+	'NAME'	       => 'Business::ISSN',
+	'ABSTRACT'     => 'Work with International Standard Serial Numbers',
+	'VERSION_FROM' => 'lib/ISSN.pm',
+	'LICENSE'      => 'perl',
+	'AUTHOR'       => 'brian d foy <bdfoy at cpan.org>',
+	
+	'PREREQ_PM'    => { 
+		'Test::More' => '0',
+		},
+
+	'PM'           => {
+		'lib/ISSN.pm'         => '$(INST_LIBDIR)/ISSN.pm',
+		},
+
+	'MAN3PODS'     => {
+		'lib/ISSN.pm' => '$(INST_MAN3DIR)/Business-ISSN.3',
+		},
+
+	clean  => { FILES    => q|Business-* cover_db *.old *.bak| },
+
+	);

Added: branches/upstream/libbusiness-issn-perl/current/README
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/README?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/README (added)
+++ branches/upstream/libbusiness-issn-perl/current/README Thu Jun  3 22:33:49 2010
@@ -1,0 +1,27 @@
+$Id: README,v 1.1 2004/09/08 00:25:41 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::ISSN
+	
+If you want to read it before you install it, you can use
+perldoc directly on the module file.
+
+	perldoc  lib/ISSN.pm
+	
+This module is also in CVS on SourceForge
+
+	http://sourceforge.net/projects/brian-d-foy/
+
+
+Enjoy, 
+
+brian d foy, bdfoy at cpan.org

Added: branches/upstream/libbusiness-issn-perl/current/examples/placeholder.pl
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/examples/placeholder.pl?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/examples/placeholder.pl (added)
+++ branches/upstream/libbusiness-issn-perl/current/examples/placeholder.pl Thu Jun  3 22:33:49 2010
@@ -1,0 +1,3 @@
+#!/usr/bin/perl
+
+# See the module synopsis until I can create some interesting examples

Added: branches/upstream/libbusiness-issn-perl/current/lib/ISSN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/lib/ISSN.pm?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/lib/ISSN.pm (added)
+++ branches/upstream/libbusiness-issn-perl/current/lib/ISSN.pm Thu Jun  3 22:33:49 2010
@@ -1,0 +1,238 @@
+package Business::ISSN;
+
+use strict;
+
+use warnings;
+no warnings;
+
+use subs qw(_common_format _checksum is_valid_checksum);
+use vars qw($VERSION @ISA @EXPORT @EXPORT_OK);
+
+use Exporter;
+
+ at ISA       = qw(Exporter);
+ at EXPORT_OK = qw(is_valid_checksum);
+
+$VERSION = '0.91';
+
+sub new 
+	{
+	my $class       = shift;
+	my $common_data = _common_format shift;
+	
+	return unless $common_data;
+
+	my $self = bless {}, $class;
+
+	$self->{'issn'}      = $common_data;
+
+	$common_data =~m/(\d{7,7})([\dxX])$/;
+	
+	@{$self}{ qw(checksum code) } = ( $2, $1 );
+
+	$self->_check_validity;
+
+	return $self;
+	}
+
+sub _issn             { $_[0]->{'issn'}         }
+sub is_valid          { $_[0]->{'valid'}        }
+sub checksum          { $_[0]->{'checksum'}     }
+sub _hyphen_positions { 4 }
+
+sub fix_checksum
+	{
+	my $self = shift;
+	my $debug = 1;
+	
+	my $last_char = substr($self->_issn, -1, 1);
+
+	my $checksum = _checksum $self->_issn;
+
+	substr( $self->{issn}, -1, 1) = $checksum;
+   
+	$self->_check_validity;
+	
+	return 0 if $last_char eq $checksum;
+	return 1;
+	}
+
+sub as_string
+	{		
+	return unless $_[0]->is_valid;
+
+	my $issn = $_[0]->_issn;
+	
+	substr($issn, $_[0]->_hyphen_positions, 0) = '-';
+
+	return $issn;
+	}
+
+sub is_valid_checksum
+	{
+	my $data = _common_format shift;
+	return 0 unless $data;        
+	return 1 if substr($data, -1, 1) eq _checksum $data;
+	return 0;
+	}
+
+sub _check_validity
+	{
+	$_[0]->{'valid'}  = is_valid_checksum( $_[0]->_issn );
+	}
+
+sub _checksum
+	{
+	my $data = _common_format shift;
+	
+	return unless $data;
+	
+	my @digits = split //, $data;
+	my $sum    = 0;         
+
+	foreach( reverse 2..8 ) # oli 10
+		{
+		$sum += $_ * (shift @digits);
+		}
+	
+	#return what the check digit should be
+	my $checksum = (11 - ($sum % 11))%11;
+	
+	$checksum = 'X' if $checksum == 10;
+	
+	return $checksum;
+	}
+
+sub _common_format
+	{
+	#we want uppercase X's
+	my $data = uc shift;
+	
+	#get rid of everything except decimal digits and X
+	$data =~ s/[^0-9X]//g;
+	
+	return $data if $data =~ m/^\d{7}[0-9X]\z/;
+					  
+	return;
+	}
+
+1;
+__END__
+
+=head1 NAME
+
+Business::ISSN - Perl extension for International Standard Serial Numbers
+
+=head1 SYNOPSIS
+
+	use Business::ISSN;
+	$issn_object = Business::ISSN->new('1456-5935');
+	
+	$issn_object = Business::ISSN->new('14565935');
+	
+	# print the ISSN (with hyphen)
+	print $issn_object->as_string;
+	
+	# check to see if the ISSN is valid
+	$issn_object->is_valid;
+	
+	#fix the ISSN checksum.  BEWARE:  the error might not be
+	#in the checksum!
+	$issn_object->fix_checksum;
+	
+	#EXPORTABLE FUNCTIONS
+		
+	use Business::ISSN qw( is_valid_checksum );
+		
+	#verify the checksum
+	if( is_valid_checksum('01234567') ) { ... }
+
+=head1 DESCRIPTION
+
+=over 4
+
+=item new($issn)
+
+The constructor accepts a scalar representing the ISSN.
+
+The string representing the ISSN may contain characters
+other than [0-9xX], although these will be removed in the
+internal representation.  The resulting string must look
+like an ISSN - the first seven characters must be digits and
+the eighth character must be a digit, 'x', or 'X'.
+
+The string passed as the ISSN need not be a valid ISSN as
+long as it superficially looks like one.  This allows one to
+use the C<fix_checksum> method. 
+
+One should check the validity of the ISSN 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 ISSN, 
+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 can't create an object, it
+returns undef.  It may do this if the string passed as the
+ISSN can't be munged to the internal format.
+
+=item $obj->checksum
+
+Return the ISSN checksum.
+
+=item $obj->as_string
+
+Return the ISSN as a string. 
+
+A terminating 'x' is changed to 'X'.
+
+=item  $obj->is_valid
+
+Returns 1 if the checksum is valid.
+
+Returns 0 if the ISSN does not pass the checksum test.  
+The constructor accepts invalid ISSN's so that
+they might be fixed with C<fix_checksum>.  
+
+=item  $obj->fix_checksum
+
+Replace the eighth character with the checksum the
+corresponds to the previous seven digits.  This does not
+guarantee that the ISSN corresponds to the product one
+thinks it does, or that the ISSN corresponds to any product
+at all.  It only produces a string that passes the checksum
+routine.  If the ISSN passed to the constructor was invalid,
+the error might have been in any of the other nine positions.
+
+=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('01234567')
+
+Takes the ISSN string and runs it through the checksum
+comparison routine.  Returns 1 if the ISSN is valid, 0 otherwise.
+
+=back
+
+=head1 AUTHOR
+
+Currently maintained by brian d foy C<< <brian.d.foy at gmail.com> >>.
+Sami Poikonen <sp at iki.fi>
+
+Original module by Sami Poikonen, based on Business::ISBN by brian d foy.
+
+This module is released under the terms of the Perl Artistic License.
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright (c) 1999-2008, brian d foy, All Rights Reserved.
+
+You may redistribute this under the same terms as Perl itself.
+
+=cut

Added: branches/upstream/libbusiness-issn-perl/current/t/issn.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/t/issn.t?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/t/issn.t (added)
+++ branches/upstream/libbusiness-issn-perl/current/t/issn.t Thu Jun  3 22:33:49 2010
@@ -1,0 +1,61 @@
+#!/usr/bin/perl
+use warnings;
+use strict;
+
+use Test::More 'no_plan';
+
+my $class = 'Business::ISSN';
+
+use_ok( $class, qw(is_valid_checksum) );
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Things that should work
+{
+my @valid_issns = qw( 0355-4325 1553-667X );
+
+foreach my $issn ( @valid_issns )
+	{
+	my $obj = $class->new( $issn );
+	isa_ok( $obj, $class );
+	ok( $obj->is_valid, "ISSN $issn is valid" );
+	is( $obj->checksum, substr( $issn, -1, 1 ), "checksum returns right value" );
+	is( $obj->as_string, $issn, "as_string matches original" );
+	ok( is_valid_checksum( $issn ), "is_valid_checksum returns true for good issn" );
+	ok( ! $obj->fix_checksum, "fix_checksum returns false for good issn" );
+	}
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Things that shouldn't work at all
+{
+my @invalid_issns = qw( 0355-4323 abcd pwer-1234 );
+
+foreach my $issn ( @invalid_issns )
+	{
+	my $obj = $class->new( $issn );
+	ok( ! eval { $obj->is_valid }, "ISSN $issn is not valid" );
+	ok( ! is_valid_checksum( $issn ), "is_valid_checksum returns false for bad issn" );
+	}
+}
+
+# # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # # #
+# Things that we can fix
+{
+my @invalid_issns = (
+	[ qw( 0355-4323 0355-4325 ) ],
+	[ qw( 1553-6673 1553-667X ) ],	
+	);
+
+foreach my $pair ( @invalid_issns )
+	{
+	my $obj = $class->new( $pair->[0] );
+	isa_ok( $obj, $class );
+	ok( ! eval { $obj->is_valid }, "ISSN $pair->[0] is not valid" );
+	ok( ! defined $obj->as_string, "as_string returns undef before we fix issn" );
+	ok( ! is_valid_checksum( $pair->[0] ), "is_valid_checksum returns false for fixable issn" );
+
+	ok( $obj->fix_checksum, "fix_checksum returns true" );
+	ok( $obj->is_valid, "ISSN $pair->[1] is now valid" );
+	is( $obj->as_string, $pair->[1], "as_string returns fixed issn" );
+	}
+}

Propchange: branches/upstream/libbusiness-issn-perl/current/t/issn.t
------------------------------------------------------------------------------
    svn:executable = 

Added: branches/upstream/libbusiness-issn-perl/current/t/load.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/t/load.t?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/t/load.t (added)
+++ branches/upstream/libbusiness-issn-perl/current/t/load.t Thu Jun  3 22:33:49 2010
@@ -1,0 +1,11 @@
+# $Id: load.t,v 1.2 2004/09/08 00:25:42 comdog Exp $
+BEGIN {
+	@classes = qw(Business::ISSN);
+	}
+
+use Test::More tests => scalar @classes;
+
+foreach my $class ( @classes )
+	{
+	print "Bail out! $class did not compile\n" unless use_ok( $class );
+	}

Added: branches/upstream/libbusiness-issn-perl/current/t/pod.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/t/pod.t?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/t/pod.t (added)
+++ branches/upstream/libbusiness-issn-perl/current/t/pod.t Thu Jun  3 22:33:49 2010
@@ -1,0 +1,5 @@
+# $Id$
+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();

Added: branches/upstream/libbusiness-issn-perl/current/t/pod_coverage.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/t/pod_coverage.t?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/t/pod_coverage.t (added)
+++ branches/upstream/libbusiness-issn-perl/current/t/pod_coverage.t Thu Jun  3 22:33:49 2010
@@ -1,0 +1,6 @@
+# $Id$
+use Test::More;
+eval "use Test::Pod::Coverage 1.00";
+plan skip_all => "Test::Pod::Coverage 1.00 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
+																						 

Added: branches/upstream/libbusiness-issn-perl/current/t/prereq.t
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/t/prereq.t?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/t/prereq.t (added)
+++ branches/upstream/libbusiness-issn-perl/current/t/prereq.t Thu Jun  3 22:33:49 2010
@@ -1,0 +1,5 @@
+# $Id$
+use Test::More;
+eval "use Test::Prereq";
+plan skip_all => "Test::Prereq required to test dependencies" if $@;
+prereq_ok();

Added: branches/upstream/libbusiness-issn-perl/current/t/test_manifest
URL: http://svn.debian.org/wsvn/pkg-perl/branches/upstream/libbusiness-issn-perl/current/t/test_manifest?rev=58827&op=file
==============================================================================
--- branches/upstream/libbusiness-issn-perl/current/t/test_manifest (added)
+++ branches/upstream/libbusiness-issn-perl/current/t/test_manifest Thu Jun  3 22:33:49 2010
@@ -1,0 +1,6 @@
+# $Id$
+load.t
+pod.t
+pod_coverage.t
+#prereq.t
+issn.t




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