File Coverage

blib/lib/SVN/Class/Info.pm
Criterion Covered Total %
statement 21 36 58.3
branch 0 4 0.0
condition 0 6 0.0
subroutine 7 11 63.6
pod 3 3 100.0
total 31 60 51.6


line stmt bran cond sub pod time code
1             package SVN::Class::Info;
2 2     2   10 use strict;
  2         4  
  2         302  
3 2     2   16 use warnings;
  2         3  
  2         60  
4 2     2   9 use base qw( Rose::Object );
  2         4  
  2         207  
5             use Rose::Object::MakeMethods::Generic (
6 2         33 scalar => [
7             qw( path name wc_root _url root rev
8             node schedule author last_rev date
9             updated checksum uuid
10             )
11             ]
12 2     2   13 );
  2         4  
13 2     2   7518 use Carp;
  2         7  
  2         176  
14 2     2   53 use Data::Dump;
  2         4  
  2         121  
15 2     2   1657 use SVN::Class::Repos;
  2         8  
  2         855  
16              
17             our $VERSION = '0.17';
18              
19             =head1 NAME
20              
21             SVN::Class::Info - Subversion workspace info
22              
23             =head1 SYNOPSIS
24              
25             use SVN::Class;
26            
27             my $file = svn_file( 'path/to/file' );
28             my $info = $file->info;
29             printf "repository URL = %s\n", $info->url;
30            
31             =head1 DESCRIPTION
32              
33             SVN::Class::Info represents the output of the C command.
34              
35             =head1 METHODS
36              
37             SVN::Class::Info B inherit from SVN::Class, but only
38             Class::Accessor::Fast.
39              
40             =cut
41              
42             =head2 new( $dir->stdout )
43              
44             Creates new SVN::Class::Info instance. The lone argument should
45             be an array ref of output from a call to the SVN::Class object's
46             info() method.
47              
48             You normally do not need to use this method directly. See the SVN::Class
49             info() method.
50              
51             =cut
52              
53             sub new {
54 0     0 1   my $class = shift;
55 0           my $buf = shift;
56 0 0 0       if ( !$buf or !ref($buf) or ref($buf) ne 'ARRAY' ) {
      0        
57 0           croak "need array ref of 'svn info' output";
58             }
59 0           return $class->SUPER::new( _make_hash(@$buf) );
60             }
61              
62             =head2 dump
63              
64             Returns dump() of the object, just like SVN::Class->dump().
65              
66             =cut
67              
68             sub dump {
69 0     0 1   return Data::Dump::dump(@_);
70             }
71              
72             my %fieldmap = (
73             Path => 'path',
74             Name => 'name',
75             URL => '_url',
76             'Working Copy Root Path' => 'wc_root',
77             'Repository Root' => 'root',
78             'Repository UUID' => 'uuid',
79             'Revision' => 'rev',
80             'Node Kind' => 'node',
81             'Schedule' => 'schedule',
82             'Last Changed Author' => 'author',
83             'Last Changed Rev' => 'last_rev',
84             'Last Changed Date' => 'date',
85             'Text Last Updated' => 'updated',
86             'Checksum' => 'checksum'
87             );
88              
89             sub _make_hash {
90 0     0     my %hash;
91 0           for (@_) {
92 0           my ( $field, $value ) = (m/^([^:]+):\ (.+)$/);
93 0 0         if ( !exists $fieldmap{$field} ) {
94 0           croak "unknown field name in svn info: $field";
95             }
96 0           $hash{ $fieldmap{$field} } = $value;
97             }
98 0           return %hash;
99             }
100              
101             =head2 url
102              
103             Get the URL value. Returns a SVN::Class::Repos object.
104              
105             =cut
106              
107             sub url {
108 0     0 1   my $self = shift;
109 0           return SVN::Class::Repos->new( $self->_url );
110             }
111              
112             =head2 path
113              
114             =head2 wc_root
115              
116             Working Copy Root Path
117              
118             =head2 name
119              
120             =head2 root
121              
122             =head2 rev
123              
124             =head2 node
125              
126             =head2 schedule
127              
128             =head2 author
129              
130             =head2 last_rev
131              
132             =head2 date
133              
134             =head2 updated
135              
136             =head2 checksum
137              
138             =head2 uuid
139              
140             Get/set the info params. These are really only useful as accessors (getters).
141              
142             =cut
143              
144             1;
145              
146             __END__