r9720 - in /branches/upstream/libmarc-crosswalk-dublincore-perl: ./ current/ current/bin/ current/lib/ current/lib/MARC/ current/lib/MARC/Crosswalk/ current/t/

vdanjean at users.alioth.debian.org vdanjean at users.alioth.debian.org
Sat Nov 24 16:50:18 UTC 2007


Author: vdanjean
Date: Sat Nov 24 16:50:18 2007
New Revision: 9720

URL: http://svn.debian.org/wsvn/?sc=1&rev=9720
Log:
[svn-inject] Installing original source of libmarc-crosswalk-dublincore-perl

Added:
    branches/upstream/libmarc-crosswalk-dublincore-perl/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/Build.PL
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/Changes
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/MANIFEST
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/META.yml
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/Makefile.PL
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/README
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/bin/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/bin/marc2dc
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/Crosswalk/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/Crosswalk/DublinCore.pm
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/01-use.t
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/10-dc_simple.t
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/11-dc_qualified.t
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/98-pod_coverage.t
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/99-pod.t
    branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/camel.usmarc

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/Build.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/Build.PL?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/Build.PL (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/Build.PL Sat Nov 24 16:50:18 2007
@@ -1,0 +1,19 @@
+use strict;
+
+use Module::Build;
+
+my $build = Module::Build->new(
+	module_name        => 'MARC::Crosswalk::DublinCore',
+	dist_author        => 'Brian Cassidy <bricas at cpan.org>',
+	license            => 'perl',
+	create_readme      => 1,
+	create_makefile_pl => 'traditional',
+	script_files       => [ qw( bin/marc2dc ) ],
+	requires           => {
+		'DublinCore::Record' => 0,
+		'MARC::Record'       => 0,
+		'Test::More'         => 0
+	},
+);
+
+$build->create_build_script;

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/Changes
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/Changes?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/Changes (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/Changes Sat Nov 24 16:50:18 2007
@@ -1,0 +1,10 @@
+Revision history for Perl extension MARC::Crosswalk::DublinCore
+
+0.02  Wed Mar 30 2005
+	- switched to Module::Build
+	- added dc simple and qualified tests
+	- added pod_coverage.t
+
+0.01  Wed Nov 17 20:31:45 2004
+	- original version
+

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/MANIFEST
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/MANIFEST?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/MANIFEST (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/MANIFEST Sat Nov 24 16:50:18 2007
@@ -1,0 +1,14 @@
+bin/marc2dc
+Build.PL
+Changes
+lib/MARC/Crosswalk/DublinCore.pm
+MANIFEST
+META.yml
+t/01-use.t
+t/10-dc_simple.t
+t/11-dc_qualified.t
+t/98-pod_coverage.t
+t/99-pod.t
+t/camel.usmarc
+Makefile.PL
+README

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/META.yml
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/META.yml?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/META.yml (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/META.yml Sat Nov 24 16:50:18 2007
@@ -1,0 +1,16 @@
+--- #YAML:1.0
+name: MARC-Crosswalk-DublinCore
+version: 0.02
+author:
+  - Brian Cassidy <bricas at cpan.org>
+abstract: Convert data between MARC and Dublin Core
+license: perl
+requires:
+  DublinCore::Record: 0
+  MARC::Record: 0
+  Test::More: 0
+provides:
+  MARC::Crosswalk::DublinCore:
+    file: lib/MARC/Crosswalk/DublinCore.pm
+    version: 0.02
+generated_by: Module::Build version 0.2609

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/Makefile.PL
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/Makefile.PL?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/Makefile.PL (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/Makefile.PL Sat Nov 24 16:50:18 2007
@@ -1,0 +1,18 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.03
+use ExtUtils::MakeMaker;
+WriteMakefile
+(
+          'PL_FILES' => {},
+          'INSTALLDIRS' => 'site',
+          'NAME' => 'MARC::Crosswalk::DublinCore',
+          'EXE_FILES' => [
+                           'bin/marc2dc'
+                         ],
+          'VERSION_FROM' => 'lib/MARC/Crosswalk/DublinCore.pm',
+          'PREREQ_PM' => {
+                           'Test::More' => 0,
+                           'DublinCore::Record' => 0,
+                           'MARC::Record' => 0
+                         }
+        )
+;

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/README
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/README?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/README (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/README Sat Nov 24 16:50:18 2007
@@ -1,0 +1,89 @@
+NAME
+    MARC::Crosswalk::DublinCore - Convert data between MARC and Dublin Core
+
+SYNOPSIS
+            my $crosswalk = MARC::Crosswalk::DublinCore->new;
+        
+            # Convert a MARC record to Dublin Core (simple)
+            my $marc = MARC::Record->new_from_usmarc( $blob );
+            my $dc   = $crosswalk->as_dublincore( $marc );
+
+            # Convert simple DC to MARC
+            $marc = $crosswalk->as_marc( $dc );
+        
+            # Convert MARC to qualified DC instead
+            $crosswalk->qualified( 1 );
+            $dc = $crosswalk->as_dublincore( $marc );
+
+DESCRIPTION
+    This module provides an implentation of the LOC's spec on how to convert
+    metadata between MARC and Dublin Core format. The spec for converting
+    MARC to Dublin Core is available at:
+    http://www.loc.gov/marc/marc2dc.html, and from DC to MARC:
+    http://www.loc.gov/marc/dccross.html.
+
+    NB: The conversion cannot be done in a round-trip manner. i.e. Doing a
+    conversion from MARC to DC, then trying to go back to MARC will not
+    yield the original record.
+
+INSTALLATION
+    To install this module via Module::Build:
+
+            perl Build.PL
+            ./Build         # or `perl Build`
+            ./Build test    # or `perl Build test`
+            ./Build install # or `perl Build install`
+
+    To install this module via ExtUtils::MakeMaker:
+
+            perl Makefile.PL
+            make
+            make test
+            make install
+
+METHODS
+  new( %options )
+    Creates a new crosswalk object. You can pass the "qualified" option
+    (true/false) as well.
+
+            # DC Simple
+            $crosswalk = MARC::Crosswalk::DublinCore->new;
+
+            # DC Qualified
+            $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
+
+  qualified( $qualified )
+    Allows you to specify if qualified Dublin Core should be used in the
+    input or output. Defaults to false (DC simple).
+
+            # DC Simple
+            $crosswalk->qualified( 0 );
+
+            # DC Qualified
+            $crosswalk->qualified( 1 );
+
+  as_dublincore( $marc )
+    convert a MARC::Record to a DublinCore::Record.
+
+  as_marc( $dublincore )
+    convert a DublinCore::Record to a MARC::Record. NB: Not yet implemented.
+
+TODO
+    * Implement as_marc()
+    * add tests
+
+SEE ALSO
+    * http://www.loc.gov/marc/marc2dc.html
+    * http://www.loc.gov/marc/dccross.html
+    * MARC::Record
+    * DublinCore::Record
+
+AUTHOR
+    * Brian Cassidy <bricas at cpan.org>
+
+COPYRIGHT AND LICENSE
+    Copyright 2005 by Brian Cassidy
+
+    This library is free software; you can redistribute it and/or modify it
+    under the same terms as Perl itself.
+

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/bin/marc2dc
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/bin/marc2dc?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/bin/marc2dc (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/bin/marc2dc Sat Nov 24 16:50:18 2007
@@ -1,0 +1,75 @@
+#!/usr/bin/perl
+
+=head1 NAME 
+
+marc2dc - convert a MARC record to Dublin Core
+
+=head1 SYNOPSIS
+
+    % marc2dc [-q] marc.dat
+
+=head1 DESCRIPTION
+
+This script takes a MARC record as input and converts it
+to an ad-hoc text format created from the conversion of the
+record into Dublin Core.
+
+=head1 TODO
+
+=over 4 
+
+=item * generate more useful output
+
+=back
+
+=head1 AUTHOR
+
+=over 4 
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2004 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself. 
+
+=cut
+
+use strict;
+use warnings;
+
+use MARC::Crosswalk::DublinCore;
+use MARC::Record;
+use File::Slurp;
+use Getopt::Std;
+use Pod::Usage;
+
+our $VERSION = '0.01';
+
+my %options;
+
+getopts( 'q', \%options );
+
+my $file = $ARGV[ 0 ];
+
+HELP_MESSAGE() unless defined $file;
+
+my $blob = read_file( $file );
+my $marc = MARC::Record->new_from_usmarc( $blob );
+
+my $crosswalk = MARC::Crosswalk::DublinCore->new( qualified => $options{ q } );
+my $dc        = $crosswalk->as_dublincore( $marc );
+
+for( $dc->elements ) {
+	my $qualifier = $_->qualifier;
+	my $scheme    = $_->scheme;
+	printf( "%s: %s\n", $_->name . ( $qualifier ? ".$qualifier" : '' ) . (  $scheme ? "($scheme)" : '' ), $_->content );
+}
+
+sub HELP_MESSAGE {
+	pod2usage();
+}

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/Crosswalk/DublinCore.pm
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/Crosswalk/DublinCore.pm?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/Crosswalk/DublinCore.pm (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/lib/MARC/Crosswalk/DublinCore.pm Sat Nov 24 16:50:18 2007
@@ -1,0 +1,620 @@
+package MARC::Crosswalk::DublinCore;
+
+=head1 NAME
+
+MARC::Crosswalk::DublinCore - Convert data between MARC and Dublin Core
+
+=head1 SYNOPSIS
+
+	my $crosswalk = MARC::Crosswalk::DublinCore->new;
+	
+	# Convert a MARC record to Dublin Core (simple)
+	my $marc = MARC::Record->new_from_usmarc( $blob );
+	my $dc   = $crosswalk->as_dublincore( $marc );
+
+	# Convert simple DC to MARC
+	$marc = $crosswalk->as_marc( $dc );
+	
+	# Convert MARC to qualified DC instead
+	$crosswalk->qualified( 1 );
+	$dc = $crosswalk->as_dublincore( $marc );
+
+=head1 DESCRIPTION
+
+This module provides an implentation of the LOC's spec on how to convert
+metadata between MARC and Dublin Core format. The spec for converting MARC to
+Dublin Core is available at: http://www.loc.gov/marc/marc2dc.html, and from DC to
+MARC: http://www.loc.gov/marc/dccross.html.
+
+NB: The conversion cannot be done in a round-trip manner. i.e. Doing a conversion
+from MARC to DC, then trying to go back to MARC will not yield the original record.
+
+=head1 INSTALLATION
+
+To install this module via Module::Build:
+
+	perl Build.PL
+	./Build         # or `perl Build`
+	./Build test    # or `perl Build test`
+	./Build install # or `perl Build install`
+
+To install this module via ExtUtils::MakeMaker:
+
+	perl Makefile.PL
+	make
+	make test
+	make install
+
+=cut
+
+use strict;
+use warnings;
+
+use MARC::Record;
+use MARC::Field;
+use DublinCore::Record;
+use DublinCore::Element;
+
+use Carp qw( croak );
+
+our $VERSION = '0.02';
+
+my %leader06_lut = (
+	a => 'Text',
+	c => 'Text',
+	d => 'Text',
+	t => 'Text',
+	e => 'Image',
+	f => 'Image',
+	g => 'Image',
+	k => 'Image',
+	i => 'Sound',
+	j => 'Sound',
+#	m => 'No Type Provided',
+#	o => 'No Type Provided',
+#	p => 'No Type Provided',
+#	r => 'No Type Provided'
+);
+
+my %leader07_lut = (
+	c => 'Collection',
+	s => 'Collection',
+	p => 'Collection'
+);
+
+my @dc_qualified = (
+	{
+		tag => 245,
+		dc  => { name => 'Title' }
+	},
+	( map +{
+		tag => $_,
+		dc  => { name => 'Title', qualifier => 'Alternative' }
+	}, ( 130, 210, 240, 242, 246, 730, 740 ) ),
+	( map +{
+		tag => $_,
+		dc  => { name => 'Creator' }
+	}, ( 100, 110, 111, 700, 710, 711, 720 ) ),
+	( map +{
+		tag        => $_,
+		indicators => [ undef, 0 ],
+		dc         => { name => 'Subject', scheme => 'LCSH' }
+	}, ( 600, 610, 611, 630, 650 ) ),
+	( map +{
+		tag        => $_,
+		indicators => [ undef, 2 ],
+		dc         => { name => 'Subject', scheme => 'MeSH' }
+	}, ( 600, 610, 611, 630, 650 ) ),
+	{
+		tag => '050',
+		dc  => { name => 'Subject', scheme => 'LCC' }
+	},
+	{
+		tag => '082',
+		dc  => { name => 'Subject', scheme => 'DDC' }
+	},
+	{
+		tag => '080',
+		dc  => { name => 'Subject', scheme => 'UDC' }
+	},
+	( map +{
+		tag => $_,
+		dc  => { name => 'Description' }
+	}, grep { $_ !~ /^(505|506|520|530|540|546)$/ } 500..599 ),
+	{
+		tag        => 505,
+		indicators => [ 3, undef ],
+		dc         => { name => 'Description', qualifier => 'tableOfContents' }
+	},
+	{
+		tag => 520,
+		dc  => { name => 'Description', qualifier => 'Abstract' }
+	},
+	{
+		tag       => 260,
+		subfields => 'ab',
+		dc        => { name => 'Publisher' }
+	},
+	{
+		tag       => 260,
+		subfields => 'cg',
+		dc        => { name => 'Date', qualifier => 'Created' }
+	},
+	{
+		tag       => 533,
+		subfields => 'd',
+		dc        => { name => 'Date', qualifier => 'Created' }
+	},
+	{
+		tag       => 260,
+		subfields => 'c',
+		dc        => { name => 'Date', qualifier => 'Issued' }
+	},
+	{
+		tag  => '008',
+		code => sub {
+			return substr( shift, 7, 4 );
+		},
+		dc   => { name => 'Date', qualifier => 'Issued' }
+	},
+	{
+		tag  => 'Leader',
+		code => sub { return $leader06_lut{ substr( shift, 6, 1 ) }; },
+		dc   => { name => 'Type', scheme => 'DCMI Type Vocabulary' }
+	},
+	{
+		tag  => 'Leader',
+		code => sub { return $leader07_lut{ substr( shift, 7, 1 ) }; },
+		dc   => { name => 'Type', scheme => 'DCMI Type Vocabulary' }
+	},
+	{
+		tag         => 655,
+		subfield_eq => [ '2', 'dct' ],
+		dc          => { name => 'Type', scheme => 'DCMI Type Vocabulary' }
+	},
+	{
+		tag       => 865,
+		subfields => 'q',
+		dc        => { name => 'Format', scheme => 'IMT' }
+	},
+	{
+		tag       => 300,
+		subfields => 'a',
+		dc        => { name => 'Format', qualifier => 'Extent' }
+	},
+	{
+		tag       => 533,
+		subfields => 'e',
+		dc        => { name => 'Format', qualifier => 'Extent' }
+	},
+	{
+		tag       => 340,
+		subfields => 'a',
+		dc        => { name => 'Format', qualifier => 'Medium' }
+	},
+	{
+		tag       => 856,
+		subfields => 'u',
+		dc        => { name => 'Identifier', scheme => 'URI' }
+	},
+	{
+		tag       => 786,
+		subfields => 'o',
+		dc        => { name => 'Source', scheme => 'URI' }
+	},
+	{
+		tag  => '008',
+		code => sub {
+			return substr( shift, 35, 3 );
+		},
+		dc   => { name => 'Language', scheme => 'ISO 639-2' }
+	},
+	{
+		tag => '041',
+		dc  => { name => 'Language', scheme => 'ISO 639-2' }
+	},
+	{
+		tag => '546',
+		dc  => { name => 'Language', scheme => 'RFC 1766' }
+	},
+	{
+		tag => 775,
+		dc  => { name => 'Relation', qualifier => 'isVersionOf' }
+	},
+	{
+		tag       => 786,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'isVersionOf' }
+	},
+	{
+		tag => 775,
+		dc  => { name => 'Relation', qualifier => 'isVersionOf', scheme => 'URI' }
+	},
+	{
+		tag       => 786,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'isVersionOf', scheme => 'URI' }
+	},
+	{
+		tag       => 775,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'hasVersion' }
+	},
+	{
+		tag       => 775,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'hasVersion', scheme => 'URI' }
+	},
+	{
+		tag       => 785,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'isReplaceBy' }
+	},
+	{
+		tag       => 785,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'isReplaceBy', scheme => 'URI' }
+	},
+	{
+		tag       => 780,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'Replaces' }
+	},
+	{
+		tag       => 780,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'Replaces', scheme => 'URI' }
+	},
+	{
+		tag => 538,
+		dc  => { name => 'Relation', qualifier => 'Requires' }
+	},
+	{
+		tag       => 773,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'isPartOf' }
+	},
+	( map +{
+		tag => $_,
+		dc  => { name => 'Relation', qualifier => 'isPartOf' }
+	}, ( 760, 440, 490, 800, 810, 811, 830 ) ),
+	{
+		tag => 760,
+		dc  => { name => 'Relation', qualifier => 'isPartOf', scheme => 'URI' }
+	},
+	{
+		tag       => 773,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'isPartOf', scheme => 'URI' }
+	},
+	{
+		tag       => 774,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'hasPart' }
+	},
+	{
+		tag       => 774,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'hasPart', scheme => 'URI' }
+	},
+	{
+		tag => 510,
+		dc  => { name => 'Relation', qualifier => 'isReferencedBy' }
+	},
+	{
+		tag       => 776,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'isFormatOf' }
+	},
+	{
+		tag => 530,
+		dc  => { name => 'Relation', qualifier => 'isFormatOf' }
+	},
+	{
+		tag       => 776,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'isFormatOf', scheme => 'URI' }
+	},
+	{
+		tag       => 530,
+		subfields => 'u',
+		dc        => { name => 'Relation', qualifier => 'isFormatOf', scheme => 'URI' }
+	},
+	{
+		tag       => 776,
+		subfields => 'nt',
+		dc        => { name => 'Relation', qualifier => 'hasFormat' }
+	},
+	{
+		tag => 530,
+		dc  => { name => 'Relation', qualifier => 'hasFormat' }
+	},
+	{
+		tag       => 776,
+		subfields => 'o',
+		dc        => { name => 'Relation', qualifier => 'hasFormat', scheme => 'URI' }
+	},
+	{
+		tag       => 530,
+		subfields => 'u',
+		dc        => { name => 'Relation', qualifier => 'hasFormat', scheme => 'URI' }
+	},
+	( map +{
+		tag => $_,
+		dc  => { name => 'Coverage', qualifier => 'Spacial' }
+	}, ( 522, 651, 255, 752 ) ),
+	{
+		tag       => 650,
+		subfields => 'z',
+		dc        => { name => 'Coverage', qualifier => 'Spacial' }
+	},
+	( map +{
+		tag       => $_,
+		subfields => 'c',
+		dc        => { name => 'Coverage', qualifier => 'Spacial', scheme => 'ISO 3166' }
+	}, ( '043', '044' ) ),
+	{
+		tag         => 651,
+		subfield_eq => [ '2', 'tgn' ],
+		dc          => { name => 'Coverage', qualifier => 'Spacial', scheme => 'TGN' }
+	},
+	{
+		tag       => 513,
+		subfields => 'b',
+		dc        => { name => 'Coverage', qualifier => 'Temporal' }
+	},
+	{
+		tag       => '033',
+		subfields => 'a',
+		dc        => { name => 'Coverage', qualifier => 'Temporal' }
+	},
+	( map +{
+		tag => $_,
+		dc  => { name => 'Rights' }
+	}, ( 506, 540 ) )
+
+);
+
+my @dc_simple    = (
+	{
+		tag => 245,
+		dc  => { name => 'Title' }
+	},
+	( map +{
+		tag => $_,
+		dc  => { name => 'Creator' }
+	}, ( 100, 110, 111, 700, 710, 711, 720 ) ),
+	( map +{
+		tag => $_,
+		dc  => { name => 'Subject' }
+	}, ( 600, 610, 611, 630, 650, 653 ) ),
+	( map +{
+		tag => $_,
+		dc  => { name => 'Description' }
+	}, grep { $_ !~ /^(506|530|540|546)$/ } 500..599 ),
+	{
+		tag       => 260,
+		subfields => 'ab',
+		dc        => { name => 'Publisher' }
+	},
+	{
+		tag  => 'Leader',
+		code => sub { return $leader06_lut{ substr( shift, 6, 1 ) }; },
+		dc   => { name => 'Type' }
+	},
+	{
+		tag  => 'Leader',
+		code => sub { return $leader07_lut{ substr( shift, 7, 1 ) }; },
+		dc   => { name => 'Type' }
+	},
+	{
+		tag => 655,
+		dc  => { name => 'Type' }
+	},
+	{
+		tag       => 856,
+		subfields => 'q',
+		dc        => { name => 'Format' }
+	},
+	{
+		tag       => 856,
+		subfields => 'u',
+		dc        => { name => 'Identifier' }
+	},
+	{
+		tag       => 786,
+		subfields => 'ot',
+		dc        => { name => 'Source' }
+	},
+	{
+		tag  => '008',
+		code => sub {
+			return substr( shift, 35, 3 );
+		},
+		dc   => { name => 'Language' }
+	},
+	{
+		tag => 546,
+		dc  => { name => 'Language' }
+	},
+	{
+		tag => 530,
+		dc  => { name => 'Relation' }
+	},
+	( map +{
+		tag       => $_,
+		subfields => 'ot',
+		dc        => { name => 'Relation' }
+	}, ( 760..787 ) ),
+	( map +{
+		tag => $_,
+		dc  => { name => 'Coverage' }
+	}, ( 651, 752 ) ),
+	( map +{
+		tag => $_,
+		dc  => { name => 'Rights' }
+	}, ( 506, 540 ) )
+);
+
+my @marc_qualified;
+my @marc_simple;
+
+=head1 METHODS
+
+=head2 new( %options )
+
+Creates a new crosswalk object. You can pass the "qualified" option (true/false) as
+well.
+
+	# DC Simple
+	$crosswalk = MARC::Crosswalk::DublinCore->new;
+
+	# DC Qualified
+	$crosswalk = MARC::Crosswalk::DublinCore->new( qualified => 1 );
+
+=cut
+
+sub new {
+	my $class   = shift;
+	my %options = @_;
+	my $self    = {};
+
+	bless $self, $class;
+
+	$self->qualified( 1 ) if $options{ qualified }; 
+
+	return $self;
+}
+
+=head2 qualified( $qualified )
+
+Allows you to specify if qualified Dublin Core should be used in
+the input or output. Defaults to false (DC simple).
+
+	# DC Simple
+	$crosswalk->qualified( 0 );
+
+	# DC Qualified
+	$crosswalk->qualified( 1 );
+
+=cut
+
+sub qualified {
+	my $self      = shift;
+	my $qualified = @_;
+
+	$self->{ _QUALIFIED } = $qualified if @_;
+
+	return $self->{ _QUALIFIED };
+}
+
+=head2 as_dublincore( $marc )
+
+convert a MARC::Record to a DublinCore::Record.
+
+=cut
+
+sub as_dublincore {
+	my $self = shift;
+	my $marc = shift;
+
+	croak( 'Input is not a MARC::Record!' ) unless $marc->isa( 'MARC::Record' );
+
+	my $rules = $self->qualified ? \@dc_qualified : \@dc_simple;
+	my $dc    = DublinCore::Record->new;
+
+	for my $rule ( @$rules ) {
+		for my $field ( $rule->{ tag } eq 'Leader' ? $marc->leader : $marc->field( $rule->{ tag } ) ) {
+			next unless defined $field;
+
+			my $content = ref $field ? $field->as_string( $rule->{ subfields } ) : $field;
+
+			if( $rule->{ subfield_eq } ) {
+				my @eq = @{ $rule->{ subfield_eq } };
+				while( @eq ) {
+					$content = undef unless $field->subfield( shift( @eq ) ) eq shift( @eq );
+				}
+			}
+			if( $rule->{ indicators } ) {
+				for( 0, 1 ) {
+					next unless defined $rule->{ indicators }->[ $_ ];
+					$content = undef unless $field->indicator( $_ + 1 ) == $rule->{ indicators }->[ $_ ];
+				}
+			}
+
+			if( $rule->{ code } ) {
+				$content = $rule->{ code }->( $content );
+			}
+
+			if( $content ) {
+				my $element = DublinCore::Element->new( $rule->{ dc } );
+				$content    =~ s/^\s+|\s+$//;
+				$element->content( $content );
+				$dc->add( $element );
+			}
+		}
+	}
+
+	return $dc;
+}
+
+=head2 as_marc( $dublincore )
+
+convert a DublinCore::Record to a MARC::Record. NB: Not yet implemented.
+
+=cut
+
+sub as_marc {
+	my $self = shift;
+	my $dc   = shift;
+
+	croak( 'Input is not a DublinCore::Record!' ) unless $dc->isa( 'DublinCore::Record' );
+
+	my $rules = $self->qualified ? \@marc_qualified : \@marc_simple;
+	my $marc  = MARC::Record->new;
+
+	croak( 'Not implemented.' );
+}
+
+=head1 TODO
+
+=over 4
+
+=item * Implement as_marc()
+
+=item * add tests
+
+=back
+
+=head1 SEE ALSO
+
+=over 4
+
+=item * http://www.loc.gov/marc/marc2dc.html
+
+=item * http://www.loc.gov/marc/dccross.html
+
+=item * MARC::Record
+
+=item * DublinCore::Record
+
+=back
+
+=head1 AUTHOR
+
+=over 4 
+
+=item * Brian Cassidy E<lt>bricas at cpan.orgE<gt>
+
+=back
+
+=head1 COPYRIGHT AND LICENSE
+
+Copyright 2005 by Brian Cassidy
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself. 
+
+=cut
+
+1;

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/01-use.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/01-use.t?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/01-use.t (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/01-use.t Sat Nov 24 16:50:18 2007
@@ -1,0 +1,11 @@
+use Test::More tests => 2;
+
+use strict;
+use warnings;
+
+BEGIN {
+	use_ok( 'MARC::Crosswalk::DublinCore' );
+}
+
+my $crosswalk = MARC::Crosswalk::DublinCore->new;
+isa_ok( $crosswalk, 'MARC::Crosswalk::DublinCore' );

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/10-dc_simple.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/10-dc_simple.t?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/10-dc_simple.t (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/10-dc_simple.t Sat Nov 24 16:50:18 2007
@@ -1,0 +1,34 @@
+use Test::More tests => 10;
+
+BEGIN {
+	use_ok( 'MARC::Crosswalk::DublinCore' );
+}
+
+use strict;
+use MARC::File::USMARC;
+
+my $crosswalk = MARC::Crosswalk::DublinCore->new;
+
+isa_ok( $crosswalk, 'MARC::Crosswalk::DublinCore' );
+ok( !$crosswalk->qualified, 'DC simple' );
+
+my $dc = $crosswalk->as_dublincore( MARC::File::USMARC->in( 't/camel.usmarc' )->next );
+
+my $record = {
+	subject     => [
+		'Active server pages.',
+		'ActiveX.',
+		'Perl (Computer program language)'
+	],
+	type        => [ 'Text' ],
+	description => [ '"Wiley Computer Publishing."' ],
+	creator     => [ 'Martinsson, Tobias, 1976-' ],
+	publisher   => [ 'New York : John Wiley & Sons,' ],
+	language    => [ 'eng' ],
+	title       => [ 'ActivePerl with ASP and ADO / Tobias Martinsson.' ]
+};
+
+foreach my $element ( keys %$record ) {
+	my @elements = $dc->$element;
+	is_deeply( [ sort map { $_->content } @elements ], $record->{ $element }, $element );
+}

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/11-dc_qualified.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/11-dc_qualified.t?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/11-dc_qualified.t (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/11-dc_qualified.t Sat Nov 24 16:50:18 2007
@@ -1,0 +1,60 @@
+use Test::More tests => 12;
+
+BEGIN {
+	use_ok( 'MARC::Crosswalk::DublinCore' );
+}
+
+use strict;
+use MARC::File::USMARC;
+
+my $crosswalk = MARC::Crosswalk::DublinCore->new;
+
+isa_ok( $crosswalk, 'MARC::Crosswalk::DublinCore' );
+
+$crosswalk->qualified( 1 );
+
+ok( $crosswalk->qualified, 'DC qualified' );
+
+my $dc = $crosswalk->as_dublincore( MARC::File::USMARC->in( 't/camel.usmarc' )->next );
+
+my $record = {
+	format      => [
+		{ content => 'xxi, 289 p. :', qualifier => 'Extent', scheme => undef }
+	],
+	subject     => [
+		{ content => '005.13/3 21', scheme => 'DDC', qualifier => undef },
+		{ content => 'Active server pages.', scheme => 'LCSH', qualifier => undef },
+		{ content => 'ActiveX.', scheme => 'LCSH', qualifier => undef },
+		{ content => 'Perl (Computer program language)', scheme => 'LCSH', qualifier => undef },
+		{ content => 'QA76.73.P22 M33 2000', scheme => 'LCC', qualifier => undef },
+	],
+	type        => [
+		{ content => 'Text', scheme => 'DCMI Type Vocabulary', qualifier => undef },
+	],
+	description => [
+		{ content => '"Wiley Computer Publishing."', qualifier => undef, scheme => undef },
+	],
+	creator     => [
+		{ content => 'Martinsson, Tobias, 1976-', qualifier => undef, scheme => undef },
+	],
+	date     => [
+		{ content => '2000', qualifier => 'Issued', scheme => undef },
+		{ content => '2000.', qualifier => 'Created', scheme => undef },
+		{ content => '2000.', qualifier => 'Issued', scheme => undef },
+	],
+	publisher   => [
+		{ content => 'New York : John Wiley & Sons,', qualifier => undef, scheme => undef },
+	],
+	language    => [
+		{ content => 'eng', scheme => 'ISO 639-2', qualifier => undef },
+	],
+	title       => [
+		{ content => 'ActivePerl with ASP and ADO / Tobias Martinsson.', qualifier => undef, scheme => undef },
+	]
+};
+
+foreach my $element ( keys %$record ) {
+	my @elements = sort { $a->content cmp $b->content || $a->qualifier cmp $b->qualifier || $a->scheme cmp $b->scheme } $dc->$element;
+	my @result   = map +{ qualifier => $_->qualifier || undef, scheme => $_->scheme || undef, content => $_->content || undef }, @elements;
+	is_deeply( \@result, $record->{ $element }, $element );
+}

Added: branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/98-pod_coverage.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/98-pod_coverage.t?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/98-pod_coverage.t (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/98-pod_coverage.t Sat Nov 24 16:50:18 2007
@@ -1,0 +1,4 @@
+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/libmarc-crosswalk-dublincore-perl/current/t/99-pod.t
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/99-pod.t?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/99-pod.t (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/99-pod.t Sat Nov 24 16:50:18 2007
@@ -1,0 +1,8 @@
+use Test::More;
+
+use strict;
+use warnings;
+
+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/libmarc-crosswalk-dublincore-perl/current/t/camel.usmarc
URL: http://svn.debian.org/wsvn/branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/camel.usmarc?rev=9720&op=file
==============================================================================
--- branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/camel.usmarc (added)
+++ branches/upstream/libmarc-crosswalk-dublincore-perl/current/t/camel.usmarc Sat Nov 24 16:50:18 2007
@@ -1,0 +1,1 @@
+00755cam  22002414a 4500001001300000003000600013005001700019008004100036010001700077020004300094040001800137042000800155050002600163082001700189100003100206245005400237260004200291300007200333500003300405650003700438630002500475630001300500
fol05731351 
IMchF
20000613133448.0
000107s2000    nyua          001 0 eng  
  a   00020737 
  a0471383147 (paper/cd-rom : alk. paper)
  aDLCcDLCdDLC
  apcc
00aQA76.73.P22bM33 2000
00a005.13/3221
1 aMartinsson, Tobias,d1976-
10aActivePerl with ASP and ADO /cTobias Martinsson.
  aNew York :bJohn Wiley & Sons,c2000.
  axxi, 289 p. :bill. ;c23 cm. +e1 computer  laser disc (4 3/4 in.)
  a"Wiley Computer Publishing."
 0aPerl (Computer program language)
00aActive server pages.
00aActiveX.

00647pam  2200241 a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002600135082001500161100002600176245006700202260003800269263000900307300001100316650003700327650002500364700001600389
fol05754809 
IMchF
20000601115601.0
000203s2000    mau           001 0 eng  
  a   00022023 
  a1565926994
  aDLCcDLCdDLC
  apcc
00aQA76.73.P22bD47 2000
00a005.74221
1 aDescartes, Alligator.
10aProgramming the Perl DBI /cAlligator Descartes and Tim Bunce.
  aCmabridge, MA :bO'Reilly,c2000.
  a1111
  ap. cm.
 0aPerl (Computer program language)
 0aDatabase management.
1 aBunce, Tim.

00605cam  22002054a 4500001001300000003000600013005001700019008004100036010001700077040001800094042000800112050002700120082001700147100002100164245005500185260004500240300002600285504005100311650003700362
fol05843555 
IMchF
20000525142739.0
000318s1999    cau      b    001 0 eng  
  a   00501349 
  aDLCcDLCdDLC
  apcc
00aQA76.73.P22bB763 1999
00a005.13/3221
1 aBrown, Martin C.
10aPerl :bprogrammer's reference /cMartin C. Brown.
  aBerkeley :bOsborne/McGraw-Hill,cc1999.
  axix, 380 p. ;c22 cm.
  aIncludes bibliographical references and index.
 0aPerl (Computer program language)

00579cam  22002054a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002700135082001700162100002100179245005500200260004500255300003600300650003700336
fol05843579 
IMchF
20000525142716.0
000318s1999    caua          001 0 eng  
  a   00502116 
  a0072120002
  aDLCcDLCdDLC
  apcc
00aQA76.73.P22bB762 1999
00a005.13/3221
1 aBrown, Martin C.
10aPerl :bthe complete reference /cMartin C. Brown.
  aBerkeley :bOsborne/McGraw-Hill,cc1999.
  axxxv, 1179 p. :bill. ;c24 cm.
 0aPerl (Computer program language)

00801nam  22002778a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001800156100002000174245008800194250003200282260004100314263000900355300001100364650003700375650003600412650002600448700002500474700002400499
fol05848297 
IMchF
20000524125727.0
000518s2000    mau           001 0 eng  
  a   00041664 
  a1565924193
  aDLCcDLC
  apcc
00aQA76.73.P22bG84 2000
00a005.2/762221
1 aGuelich, Scott.
10aCGI programming with Perl /cScott Guelich, Shishir Gundavaram & Gunther Birznieks.
  a2nd ed., expanded & updated
  aCambridge, Mass. :bO'Reilly,c2000.
  a0006
  ap. cm.
 0aPerl (Computer program language)
 0aCGI (Computer network protocol)
 0aInternet programming.
1 aGundavaram, Shishir.
1 aBirznieks, Gunther.

00665nam  22002298a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002700130082001700157111005200174245008600226250001200312260004100324263000900365300001100374650005000385
fol05865950 
IMchF
20000615103017.0
000612s2000    mau           100 0 eng  
  a   00055759 
  a0596000138
  aDLCcDLC
  apcc
00aQA76.73.P22bP475 2000
00a005.13/3221
2 aPerl Conference 4.0d(2000 :cMonterey, Calif.)
10aProceedings of the Perl Conference 4.0 :bJuly 17-20, 2000, Monterey, California.
  a1st ed.
  aCambridge, Mass. :bO'Reilly,c2000.
  a0006
  ap. cm.
 0aPerl (Computer program language)vCongresses.

00579nam  22002178a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001700156100002800173245006200201260004100263263000900304300001100313650003700324
fol05865956 
IMchF
20000615102948.0
000612s2000    mau           000 0 eng  
  a   00055770 
  a1565926099
  aDLCcDLC
  apcc
00aQA76.73.P22bB43 2000
00a005.13/3221
1 aBlank-Edelman, David N.
10aPerl for system administration /cDavid N. Blank-Edelman.
  aCambridge, Mass. :bO'Reilly,c2000.
  a0006
  ap. cm.
 0aPerl (Computer program language)

00661nam  22002538a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001300109042000800122050002600130082001700156100001700173245006700190250001200257260004100269263000900310300001100319650003700330700002300367700001700390
fol05865967 
IMchF
20000615102611.0
000614s2000    mau           000 0 eng  
  a   00055799 
  a0596000278
  aDLCcDLC
  apcc
00aQA76.73.P22bW35 2000
00a005.13/3221
1 aWall, Larry.
10aProgramming Perl /cLarry Wall, Tom Christiansen & Jon Orwant.
  a3rd ed.
  aCambridge, Mass. :bO'Reilly,c2000.
  a0007
  ap. cm.
 0aPerl (Computer program language)
1 aChristiansen, Tom.
1 aOrwant, Jon.

00603cam  22002054a 4500001001300000003000600013005001700019008004100036010001700077020001500094040001800109042000800127050002600135082001700161100003200178245006000210260005700270300003300327650003700360
fol05872355 
IMchF
20000706095105.0
000315s1999    njua          001 0 eng  
  a   00500678 
  a013020868X
  aDLCcDLCdDLC
  apcc
00aQA76.73.P22bL69 1999
00a005.13/3221
1 aLowe, Vincentq(Vincent D.)
10aPerl programmer's interactive workbook /cVincent Lowe.
  aUpper Saddle River, NJ :bPrentice Hall PTP,cc1999.
  axx, 633 p. :bill. ;c23 cm.
 0aPerl (Computer program language)

00696nam  22002538a 4500001001300000003000600013005001700019008004100036010001700077020002800094040001300122042000800135050002600143082001700169100002600186245004400212260005100256263000900307300001100316500002000327650003700347650001700384650004100401
fol05882032 
IMchF
20000707091904.0
000630s2000    cau           001 0 eng  
  a   00058174 
  a0764547291 (alk. paper)
  aDLCcDLC
  apcc
00aQA76.73.P22bF64 2000
00a005.13/3221
2 aFoster-Johnson, Eric.
10aCross-platform Perl /cEric F. Johnson.
  aFoster City, CA :bIDG Books Worldwide,c2000.
  a0009
  ap. cm.
  aIncludes index.
 0aPerl (Computer program language)
 0aWeb servers.
 0aCross-platform software development.






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