File Coverage

blib/lib/SVK.pm
Criterion Covered Total %
statement 7 9 77.7
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 10 12 83.3


line stmt bran cond sub pod time code
1             # BEGIN BPS TAGGED BLOCK {{{
2             # COPYRIGHT:
3             #
4             # This software is Copyright (c) 2003-2008 Best Practical Solutions, LLC
5             #
6             #
7             # (Except where explicitly superseded by other copyright notices)
8             #
9             #
10             # LICENSE:
11             #
12             #
13             # This program is free software; you can redistribute it and/or
14             # modify it under the terms of either:
15             #
16             # a) Version 2 of the GNU General Public License. You should have
17             # received a copy of the GNU General Public License along with this
18             # program. If not, write to the Free Software Foundation, Inc., 51
19             # Franklin Street, Fifth Floor, Boston, MA 02110-1301 or visit
20             # their web page on the internet at
21             # http://www.gnu.org/copyleft/gpl.html.
22             #
23             # b) Version 1 of Perl's "Artistic License". You should have received
24             # a copy of the Artistic License with this package, in the file
25             # named "ARTISTIC". The license is also available at
26             # http://opensource.org/licenses/artistic-license.php.
27             #
28             # This work is distributed in the hope that it will be useful, but
29             # WITHOUT ANY WARRANTY; without even the implied warranty of
30             # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
31             # General Public License for more details.
32             #
33             # CONTRIBUTION SUBMISSION POLICY:
34             #
35             # (The following paragraph is not intended to limit the rights granted
36             # to you to modify and distribute this software under the terms of the
37             # GNU General Public License and is only of importance to you if you
38             # choose to contribute your changes and enhancements to the community
39             # by submitting them to Best Practical Solutions, LLC.)
40             #
41             # By intentionally submitting any modifications, corrections or
42             # derivatives to this work, or any other work intended for use with SVK,
43             # to Best Practical Solutions, LLC, you confirm that you are the
44             # copyright holder for those contributions and you grant Best Practical
45             # Solutions, LLC a nonexclusive, worldwide, irrevocable, royalty-free,
46             # perpetual, license to use, copy, create derivative works based on
47             # those contributions, and sublicense and distribute those contributions
48             # and any derivatives thereof.
49             #
50             # END BPS TAGGED BLOCK }}}
51             package SVK;
52 176     176   1108 use strict;
  176         357  
  176         10010  
53 176     176   1014 use SVK::Version; our $VERSION = $SVK::VERSION;
  176         703  
  176         8586  
54              
55             # Load classes on demand.
56 176     176   465879 use Class::Autouse qw(SVK::Command);
  0            
  0            
57              
58             use SVN::Core;
59             BEGIN {
60             # autouse hates Devel::DProf. If we're running with DProf,
61             # we need to emasculate autouse by blowing a new import sub into its
62             # package at runtime.
63             if($main::INC{'Devel/DProf.pm'}) {
64             no strict 'refs';
65             $main::INC{'autouse.pm'} = __FILE__;
66             *{'autouse::import'} = sub {
67             require UNIVERSAL::require;
68             shift; # get rid of $CLASS
69             my $class = shift;
70             $class->require or die "$class: $!";
71             my @arg = @_;
72             $class->export_to_level(1, undef, map {s/\(.*\)//g;$_} @arg);
73             }
74             }
75             }
76              
77             sub import {
78             return unless ref ($_[0]);
79             our $AUTOLOAD = 'import';
80             goto &AUTOLOAD;
81             }
82              
83             sub new {
84             my $class = shift;
85             my $self = bless {}, $class;
86             %$self = @_;
87             return $self;
88             }
89              
90             sub AUTOLOAD {
91             my $cmd = our $AUTOLOAD;
92             $cmd =~ s/^SVK:://;
93             return if $cmd =~ /^[A-Z]+$/;
94              
95             no strict 'refs';
96             no warnings 'redefine';
97             *$cmd = sub {
98             my $self = shift;
99             my ($buf, $output, $ret) = ('');
100             open $output, '>', \$buf if $self->{output};
101             eval { $ret = SVK::Command->invoke ($self->{xd}, $cmd, $output, @_) };
102             if ($output) {
103             close $output;
104             ${$self->{output}} = $buf;
105             }
106             return $ret;
107             };
108             goto &$cmd;
109             }
110              
111             1;
112              
113             __DATA__