V-0.13/0000755000076500001200000000000010714201166012353 5ustar abeltjeadmin00000000000000V-0.13/Changes0000644000076500001200000001377010714201164013654 0ustar abeltjeadmin00000000000000These changes are from the Subversion repository at Url: http://source.test-smoke.org/svn/V The filelists have a short symbolic indicator: ! modified + added - deleted !> merged change !< replaced Enjoy! ___________________________________________________________________________ [ 1126] By: abeltje on 2007-11-07 01:10:02 +0100 Log: * [CHANGE] * FIX: bug reported by Merijn: my $version = map { "$_ " . V::get_version( $_ ) } qw/ Cwd /; "Modification of a read-only value attempted" * local()ize $_ before reading the file to find the version Url: http://source.test-smoke.org/svn/V + /V/t/03bug.t ! /V/MANIFEST, /V/V.pm ___________________________________________________________________________ [ 938] By: abeltje on 2006-03-31 17:29:56 +0200 Log: * [CORE] * put the tests for the core-distribution in their own directory Url: http://source.test-smoke.org/svn/V + /V/core-t, /V/core-t/02useit.t - /V/t/01core.t !> /V/core-t/01core.t =(/V/t/01core.t:936) ___________________________________________________________________________ [ 937] By: abeltje on 2006-03-31 17:28:21 +0200 Log: * [CHANGE] * small rework of the AUTHOR/LICENSE sections in pod Url: http://source.test-smoke.org/svn/V ! /V/V.pm ___________________________________________________________________________ [ 933] By: abeltje on 2006-02-03 18:07:51 +0100 Log: * Regenerate Changes for V 0.11 Url: http://source.test-smoke.org/svn/V ! /V/Changes ___________________________________________________________________________ [ 932] By: abeltje on 2006-02-03 17:04:17 +0100 Log: * [CHANGE] + add untainting stuff by Stas Bekman (2004/03/24) Url: http://source.test-smoke.org/svn/V ! /V/V.pm ___________________________________________________________________________ [ 661] By: abeltje on 2004-03-24 07:44:42 +0100 Log: * Regen Changes for 0.10 Url: http://source.test-smoke.org/svn/V ! /V/Changes ___________________________________________________________________________ [ 660] By: abeltje on 2004-03-24 07:43:27 +0100 Log: * [CHANGE] * added the license stuff Url: http://source.test-smoke.org/svn/V ! /V/V.pm ___________________________________________________________________________ [ 576] By: abeltje on 2004-01-16 14:13:13 +0100 Log: * regen Changes for 0.09 Url: http://source.test-smoke.org/svn/V ! /V/Changes ___________________________________________________________________________ [ 575] By: abeltje on 2004-01-16 14:09:03 +0100 Log: * [ADD] + feature request by Merijn Brand: * Can you add a sub that returns the version only for a given module + added a test for V::get_version * VERSION += 0.01 Url: http://source.test-smoke.org/svn/V ! /V/README, /V/V.pm, /V/t/01basic.t, /V/t/02useit.t ___________________________________________________________________________ [ 574] By: abeltje on 2004-01-16 13:58:27 +0100 Log: * [FIX] by Merijn Brand * fix a syntax error in the PREREQ_PM target Url: http://source.test-smoke.org/svn/V ! /V/Makefile.PL ___________________________________________________________________________ [ 406] By: abeltje on 2003-08-22 03:51:06 +0200 Log: * [CHANGE] * general cleanup and $VERSION += 0.01 Url: http://source.test-smoke.org/svn/V ! /V/MANIFEST, /V/Makefile.PL, /V/README, /V/V.pm ___________________________________________________________________________ [ 405] By: abeltje on 2003-08-22 03:49:41 +0200 Log: * [FIX] make the tests pass again Url: http://source.test-smoke.org/svn/V ! /V/t/01basic.t, /V/t/02useit.t ___________________________________________________________________________ [ 404] By: abeltje on 2003-08-22 03:46:32 +0200 Log: * [REMOVE] No more Test::More, make it a PREREQ Url: http://source.test-smoke.org/svn/V - /V/t/lib ___________________________________________________________________________ [ 52] By: abeltje on 2003-03-10 00:40:16 +0100 Log: $VERSION += 0.01 Url: http://source.test-smoke.org/svn/V ! /V/README ___________________________________________________________________________ [ 51] By: abeltje on 2003-03-10 00:38:13 +0100 Log: $VERSION += 0.01 Url: http://source.test-smoke.org/svn/V ! /V/V.pm ___________________________________________________________________________ [ 50] By: abeltje on 2003-03-10 00:37:05 +0100 Log: Change the way we C<< use lib $lib; >> for Test-More Url: http://source.test-smoke.org/svn/V ! /V/t/01basic.t, /V/t/02useit.t ___________________________________________________________________________ [ 49] By: abeltje on 2003-03-10 00:17:33 +0100 Log: Initial import of V-0.06 Url: http://source.test-smoke.org/svn/V + /V/Changes, /V/MANIFEST, /V/Makefile.PL, /V/README, /V/V.pm, /V/t, /V/t/01basic.t, /V/t/02useit.t, /V/t/lib, /V/t/lib/Test, /V/t/lib/Test/Builder.pm, /V/t/lib/Test/More.pm, /V/t/lib/Test/Simple.pm ___________________________________________________________________________ [ 48] By: abeltje on 2003-03-10 00:16:24 +0100 Log: Create space for the V module Url: http://source.test-smoke.org/svn/V + /V -- Generated by 'svnchanges' (0.013) -- V-0.13/Makefile.PL0000644000076500001200000000065110676027255014343 0ustar abeltjeadmin00000000000000#! usr/bin/perl -w use strict; # $Id: Makefile.PL 574 2004-01-16 12:58:27Z abeltje $ use ExtUtils::MakeMaker; WriteMakefile( NAME => 'V', VERSION_FROM => 'V.pm', PREREQ_PM => { 'Test::More' => 0 }, ($] >= 5.005 ? ## Add these new keywords supported since 5.005 (ABSTRACT_FROM => 'V.pm', AUTHOR => 'Abe Timmerman ') : () ), ); V-0.13/MANIFEST0000644000076500001200000000031610714201166013504 0ustar abeltjeadmin00000000000000MANIFEST # $Id: MANIFEST 1126 2007-11-07 00:10:02Z abeltje $ Changes Makefile.PL README V.pm t/01basic.t t/02useit.t t/03bug.t META.yml Module meta-data (added by MakeMaker) V-0.13/META.yml0000664000076500001200000000065310714201166013632 0ustar abeltjeadmin00000000000000--- #YAML:1.0 name: V version: 0.13 abstract: Print version of the specified module(s). license: ~ generated_by: ExtUtils::MakeMaker version 6.36 distribution_type: module requires: Test::More: 0 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.2.html version: 1.2 author: - Abe Timmerman V-0.13/README0000644000076500001200000000220610676027255013247 0ustar abeltjeadmin00000000000000V version 0.09 ============== This module uses stolen code from C to find the location and version of the specified module(s). It prints them and exit()s. It works by definening C and is based on an idea from Michael Schwern on the perl5-porters list. See the discussion: L $ perl -MV=CPAN or if you want more than one $ perl -MV=CPAN,V INSTALLATION To install this module type the following: perl Makefile.PL make test make install DEPENDENCIES This module requires no other modules or libraries (exept Test::More for the test-suite). COPYRIGHT AND LICENCE Copyright (c) 2002 Abe Timmerman . All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See: * http://www.perl.com/perl/misc/Artistic.html * http://www.gnu.org/copyleft/gpl.html This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. V-0.13/t/0000755000076500001200000000000010714201166012616 5ustar abeltjeadmin00000000000000V-0.13/t/01basic.t0000755000076500001200000000147610676027255014254 0ustar abeltjeadmin00000000000000#!/usr/bin/perl -w use strict; # $Id: 01basic.t 575 2004-01-16 13:09:03Z abeltje $ use Test::More tests => 3; require_ok( 'V' ); ok( $V::VERSION, '$V::VERSION is there' ); SKIP: { local *PIPE; my $out; if ( open PIPE, qq!$^X -Mblib -MV |! ) { $out = do { local $/; }; unless ( close PIPE ) { if ( open PIPE, qq!$^X -I. -e 'use V;' |! ) { $out = do { local $/; }; skip "Error in pipe(2): $! [$?]", 1 unless close PIPE; } else { skip "Could not fork: $!", 1; } $out or skip "Error in pipe(1): $! [$?]", 1; } } else { skip "Could not fork: $!"; } my( $version ) = $out =~ /^.+?([\d._]+)$/m; is( $version, $V::VERSION, "Version ok ($version)" ); } __END__ V-0.13/t/02useit.t0000755000076500001200000000147110676027255014320 0ustar abeltjeadmin00000000000000#!/usr/bin/perl -w use strict; $|=1; # $Id: 02useit.t 575 2004-01-16 13:09:03Z abeltje $ use Test::More tests => 6; package Catch; sub TIEHANDLE { bless \( my $self ), shift } sub PRINT { my $self = shift; $$self .= $_[0] } sub PRINTF { my $self = shift; my $format = shift; $$self .= sprintf $format, @_; } package main; my $out; local *CATCHOUT; #BEGIN { $out = tie *CATCHOUT, 'Catch'; select CATCHOUT; require_ok( 'V' ); $V::NO_EXIT = 1; #} V->import( 'V' ); select STDOUT; # Stop gathering output via *CATCHOUT; ok( $$out, "V->import() produced output" ); like( $$out, qr/^V\n/, "Module is V" ); like( $$out, qr/^\t(.+?)V\.pm: $V::VERSION$/m, "VERSION is $V::VERSION" ); is( $V::NO_EXIT, 1 , "Packagevar \$V::NO_EXIT set" ); is V::get_version( 'V' ), $V::VERSION, "get_version()"; V-0.13/t/03bug.t0000644000076500001200000000061310714201030013711 0ustar abeltjeadmin00000000000000#! perl use warnings; use strict; # $Id: 03bug.t 1126 2007-11-07 00:10:02Z abeltje $ use Test::More tests => 2; BEGIN { $V::NO_EXIT = $V::NO_EXIT = 1 } require_ok 'V'; my @modules = map { s{/}{::}g; s{\.pm$}{}; $_ } grep /\.pm$/ && ! /^Config\.pm$/ => keys %INC; my $versions = eval { join ", ", map { "$_: " . V::get_version( $_ ) } qw/ Cwd /; }; is $@, "", "readonly bug"; V-0.13/V.pm0000644000076500001200000001027410714201030013110 0ustar abeltjeadmin00000000000000package V; use strict; # $Id: V.pm 1126 2007-11-07 00:10:02Z abeltje $ use vars qw( $VERSION $NO_EXIT ); $VERSION = '0.13'; $NO_EXIT ||= 0; # prevent import() from exit()ing and fall of the edge =head1 NAME V - Print version of the specified module(s). =head1 SYNOPSIS $ perl -MV=V or if you want more than one $ perl -MV=CPAN,V Can now also be used as a light-weight module for getting versions of modules without loading them: BEGIN { $V::NO_EXIT = 1 } require V; printf "%s has version '%s'\n", "V", V::get_version( "V" ); =head1 DESCRIPTION This module uses stolen code from L to find the location and version of the specified module(s). It prints them and exit()s. It defines C and is based on an idea from Michael Schwern on the perl5-porters list. See the discussion: http://www.xray.mpe.mpg.de/mailing-lists/perl5-porters/2002-01/msg00760.html =head1 AUTHOR Abe Timmerman C<< >>. =head1 COPYRIGHT & LICENSE Copyright 2002-2006 Abe Timmerman, All Rights Reserved. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. =cut sub report_pkg($@) { my $pkg = shift; print "$pkg\n"; @_ or print "\tNot found\n"; for my $module ( @_ ) { printf "\t%s: %s\n", $module->file, $module->version || '?'; } } sub import { shift; @_ or push @_, 'V'; for my $pkg ( @_ ) { my @modules = V::Module::Info->all_installed( $pkg ); report_pkg $pkg, @modules; } exit() unless $NO_EXIT; } sub get_version { my( $pkg ) = @_; my( $first ) = V::Module::Info->all_installed( $pkg ); return $first ? $first->version : undef; } caller or V->import( @ARGV ); 1; # Okay I did the AUTOLOAD() bit, but this is a Copy 'n Paste job. # Thank you Michael Schwern for Module::Info! This one is mostly that! package V::Module::Info; require File::Spec; sub new_from_file { my($proto, $file) = @_; my($class) = ref $proto || $proto; return unless -r $file; my $self = {}; $self->{file} = File::Spec->rel2abs($file); $self->{dir} = ''; $self->{name} = ''; return bless $self, $class; } sub all_installed { my($proto, $name, @inc) = @_; my($class) = ref $proto || $proto; @inc = @INC unless @inc; my $file = File::Spec->catfile(split m/::/, $name) . '.pm'; my @modules = (); foreach my $dir (@inc) { # Skip the new code ref in @INC feature. next if ref $dir; my $filename = File::Spec->catfile($dir, $file); if( -r $filename ) { my $module = $class->new_from_file($filename); $module->{dir} = File::Spec->rel2abs($dir); $module->{name} = $name; push @modules, $module; } } return @modules; } # Thieved from ExtUtils::MM_Unix 1.12603 sub version { my($self) = shift; my $parsefile = $self->file; local *MOD; open(MOD, $parsefile) or die $!; my $inpod = 0; my $result; local $_; while () { $inpod = /^=(?!cut)/ ? 1 : /^=cut/ ? 0 : $inpod; next if $inpod || /^\s*#/; chomp; next unless m/([\$*])(([\w\:\']*)\bVERSION)\b.*\=/; { local($1, $2); ($_ = $_) = m/(.*)/; } # untaint my $eval = qq{ package V::Module::Info::_version; no strict; local $1$2; \$$2=undef; do { $_ }; \$$2 }; local $^W = 0; $result = eval($eval); warn "Could not eval '$eval' in $parsefile: $@" if $@; $result = "undef" unless defined $result; last; } close MOD; return $result; } sub accessor { my $self = shift; my $field = shift; $self->{ $field } = $_[0] if @_; return $self->{ $field }; } sub AUTOLOAD { my( $self ) = @_; use vars qw( $AUTOLOAD ); my( $method ) = $AUTOLOAD =~ m|.+::(.+)$|; if ( exists $self->{ $method } ) { splice @_, 1, 0, $method; goto &accessor; } }