Biblio-COUNTER-0.11/0040755000076500007650000000000011146514757013727 5ustar nkuitsenkuitseBiblio-COUNTER-0.11/bin/0040755000076500007650000000000011146514757014477 5ustar nkuitsenkuitseBiblio-COUNTER-0.11/bin/counterproc0100444000076500007650000007007111146514757016765 0ustar nkuitsenkuitse#!/usr/bin/perl -w # counterproc by Paul Hoffman (nkuitse AT nkuitse DOT com). # Copyright 2008-2009 Paul M. Hoffman. # This software is made available under the same terms as Perl; # see below for details. use strict; # -------------------------------- Required modules use Biblio::COUNTER::Processor::Simple; use File::Basename qw(basename); use Getopt::Long qw(:config posix_default gnu_compat require_order pass_through no_ignore_case); # -------------------------------- Variables use vars qw($PROGRAM $VERSION $AUTHOR $COPYRIGHT $PAGER); $PROGRAM = basename($0); $VERSION = '0.03'; $AUTHOR = 'Paul Hoffman (nkuitse AT nkuitse DOT com)'; $COPYRIGHT = "Copyright 2008-2009 Paul M. Hoffman"; my $action = \&run; my $verbose; my $processor_class = 'Simple'; my @processor_args; my @ignore; # -------------------------------- Setup $| = 1; # -------------------------------- Read command-line options and arguments GetOptions( 'P|processor=s' => \$processor_class, 'D|proc-arg=s' => \@processor_args, 'I|ignore=s' => \@ignore, 'u|unbuffered' => sub { $| = 1 }, 'v|verbose' => sub { $verbose = 1; push @processor_args, 'verbose' }, 'c|validate' => sub { $processor_class = 'Validate' }, 'A|atomize' => sub { $processor_class = 'Atomize' }, 'h|help' => sub { $action = \&help }, 'V|version' => sub { $action = \&version }, 'M|manual' => sub { $action = \&manual }, 'L|license' => sub { $action = \&license }, ) or exit usage(); # -------------------------------- Perform the desired action $action->(); # -------------------------------- Action functions sub run { if ($processor_class !~ /::/) { $processor_class = 'Biblio::COUNTER::Processor::' . $processor_class; } die "Can't load processor '$processor_class': $@\n" unless eval "use $processor_class; 1"; my %args; foreach (@processor_args) { my ($key, $val) = split /=/, $_, 2; $args{$key} = defined($val) ? $val : 1; } my $processor = $processor_class->new(%args); if (@ignore) { if ($processor->can('ignore')) { $processor->ignore(split /,/, @ignore); } else { print STDERR "Processor '$processor' can't ignore events\n"; exit 2; } } @ARGV = ('-') unless @ARGV; exit usage() unless @ARGV == 1; my $f = shift @ARGV; my $report = $processor->run($f); if ($report->is_valid) { exit 0; } else { exit -1; } } sub help { usage(); options(); exit 0; } sub version { print "This is $PROGRAM " if $verbose; print $VERSION; print <<"EOS" if $verbose; by $AUTHOR. $COPYRIGHT. This is free software, made available under the same terms as Perl itself. EOS print "\n" unless $verbose; exit 0; } sub manual { system(podder()) == 0 or print STDERR "I can't find a way to print the manual page for $PROGRAM.\n"; } sub license { my $pager = pager(); if ($pager and which('sed')) { system(qq{sed '/^This software is made available/,/^The End/!d' "$0" | "$pager"}); } else { print STDERR "I can't find a way to print the license for $PROGRAM\n"; } } # -------------------------------- Other functions sub options { print <<"EOS"; Options: -v|--verbose Be verbose EOS } sub usage { print STDERR "$_\n" foreach @_; print <<"EOS"; Usage: $PROGRAM [OPTION...] [FILE...] $PROGRAM -h|--help $PROGRAM -V|--version $PROGRAM -M|--manual $PROGRAM -L|--license EOS return 1; } sub pager { return $PAGER if defined $PAGER; $PAGER = $ENV{'PAGER'} || which(qw(less more)) || which('cat') || 0; return $PAGER; } sub podder { return "cat $0 | pod2man -n $PROGRAM -s 1 -r $VERSION -c '' | nroff -man | " . pager() if pager() and which('pod2man') and which('nroff'); return "man 1 $PROGRAM" if manpage($PROGRAM); return "perldoc -F $0" if which('perldoc'); return undef; } sub which { my $out; no warnings; foreach my $prog (@_) { $out = `which $prog 2>/dev/null`; if (defined $out) { chomp $out; return $out if -x $out; } } return undef; } sub manpage { return unless which('man'); my $out = `man -w 1 $PROGRAM 2>/dev/null`; return unless defined $out; chomp $out; return $out; } =pod =head1 NAME counterproc - process a COUNTER report =head1 SYNOPSIS B [I