1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
|
package VCS::Version;
my $PREFIX = 'VCS';
sub new {
my $container_classtype = shift;
$container_classtype =~ s#^$PREFIX##;
my ($hostname, $impl_class, $path, $query) = VCS->parse_url(@_);
VCS->class_load($impl_class);
my $this_class = "$impl_class$container_classtype";
return $this_class->new(@_);
}
sub init {
my ($class, $url) = @_;
my ($hostname, $impl_class, $path, $query) = VCS->parse_url($url);
my @path = split '/', $path;
my $version = pop @path;
my $filename = join '/', @path;
my $self = {
URL => $url,
VERSION => $version,
PATH => $filename,
};
bless $self, $class;
}
sub url {
my $self = shift;
$self->{URL};
}
sub version {
my $self = shift;
$self->{VERSION};
}
sub tags {
}
sub text {
}
sub diff {
}
sub author {
}
sub date {
}
sub reason {
}
sub path {
my $self = shift;
$self->{PATH};
}
1;
__END__
=head1 NAME
VCS::Version - module for access to a VCS version
=head1 SYNOPSIS
use VCS;
die "Usage: $0 file-url\ne.g.: vcs://localhost/VCS::Rcs/file/name/1.2\n"
unless @ARGV == 1;
my $version = VCS::Version->new(@ARGV);
print "Methods of \$version:\n",
"url: ", $version->url, "\n",
"author: ", $version->author, "\n",
"version: ", $version->version, "\n",
;
=head1 DESCRIPTION
VCS::Version abstracts a single revision of a file under version
control.
=head1 METHODS
Methods marked with a "*" are not yet finalised/implemented.
=head2 VCS::Version-E<gt>create_new(@version_args) *
C<@version_args> is a list which will be treated as a hash, with
contents as follow:
@version_args = (
name => 'a file name',
version => 'an appropriate version identifier',
tags => [ 'A_TAG_NAME', 'SECOND_TAG' ],
author => 'the author name',
reason => 'the reason for the checkin',
text => 'either literal text, or a ref to the filename',
);
This is a pure virtual method, which must be over-ridden, and cannot be
called directly in this class (a C<die> will result).
=head2 VCS::Version-E<gt>new($url)
C<$url> is a VCS URL, of the format:
vcs://localhost/VCS::Rcs/file/name/1.2
The version is a version number, or tag. Returns an object of class
C<VCS::Version>, or throws an exception if it fails. Normally, an
override of this method will call C<VCS::Version-E<gt>init($url)> to
make an object, and then add to it as appropriate.
=head2 VCS::Version-E<gt>init($url)
C<$url> is a version URL. Returns an object of class C<VCS::Version>. This
method calls C<VCS-E<gt>parse_url> to make sense of the URL.
=head2 $version-E<gt>url
Returns the C<$url> argument to C<new>.
=head2 $version-E<gt>version
Returns the C<$version> argument to C<new>.
=head2 $version-E<gt>tags
Returns a list of tags applied to this version.
=head2 $version-E<gt>text
Returns the text of this version of the file.
=head2 $version-E<gt>diff($other_version)
Returns the differences (in C<diff -u> format) between this version and
the other version. Currently, the other version must also be a
C<VCS::Version> object.
=head2 $version-E<gt>author
Returns the name of the user who checked in this version.
=head2 $version-E<gt>date
Returns the date this version was checked in.
=head2 $version-E<gt>reason
Returns the reason given on checking in this version.
=head2 $version-E<gt>path
Returns the absolute path of the file to which this version relates.
=head1 SEE ALSO
L<VCS>.
=head1 COPYRIGHT
This library is free software; you can redistribute it and/or
modify it under the same terms as Perl itself.
=cut
|