Commits

Anonymous committed 4bf0568

Importing the sources for www-opensvn

  • Participants

Comments (0)

Files changed (9)

+blib*
+Makefile
+Makefile.old
+Build
+_build*
+pm_to_blib*
+*.tar.gz
+.lwpcookies
+WWW-OpenSVN-*
+cover_db
+Revision history for WWW-OpenSVN
+
+0.01    Date/time
+        First version, released on an unsuspecting world.
+
+Changes
+MANIFEST
+META.yml # Will be created by "make dist"
+Makefile.PL
+README
+lib/WWW/OpenSVN.pm
+t/00-load.t
+t/pod-coverage.t
+t/pod.t
+use strict;
+use warnings;
+use ExtUtils::MakeMaker;
+
+WriteMakefile(
+    NAME                => 'WWW::OpenSVN',
+    AUTHOR              => 'Shlomi Fish <shlomif@iglu.org.il>',
+    VERSION_FROM        => 'lib/WWW/OpenSVN.pm',
+    ABSTRACT_FROM       => 'lib/WWW/OpenSVN.pm',
+    PL_FILES            => {},
+    PREREQ_PM => {
+        'Test::More' => 0,
+    },
+    dist                => { COMPRESS => 'gzip -9f', SUFFIX => 'gz', },
+    clean               => { FILES => 'WWW-OpenSVN-*' },
+);
+WWW-OpenSVN
+
+The README is used to introduce the module and provide instructions on
+how to install the module, any machine dependencies it may have (for
+example C compilers and installed libraries) and any other information
+that should be provided before the module is installed.
+
+A README file is required for CPAN modules since CPAN extracts the README
+file from a module distribution so that people browsing the archive
+can use it get an idea of the modules uses. It is usually a good idea
+to provide version information here so that people can decide whether
+fixes for the module are worth downloading.
+
+INSTALLATION
+
+To install this module, run the following commands:
+
+    perl Makefile.PL
+    make
+    make test
+    make install
+
+
+COPYRIGHT AND LICENCE
+
+Put the correct copyright and licence information here.
+
+Copyright (C) 2005 Shlomi Fish
+
+This library is free software; you can redistribute it and/or modify
+it under the same terms as Perl itself.

Perl/lib/WWW/OpenSVN.pm

+package WWW::OpenSVN;
+
+use strict;
+
+use LWP::UserAgent;
+use LWP::Simple;
+use HTTP::Cookies;
+
+=head1 NAME
+
+WWW::OpenSVN - An automated interface for OpenSVN.csie.org.
+
+=cut
+
+use vars qw($VERSION);
+
+$VERSION = '0.01';
+
+=head1 SYNOPSIS
+
+    my $opensvn = 
+        WWW::OpenSVN->new(
+            'project' => "myproject", 
+            'password' => "MySecretPassphrase",
+        );
+
+=head1 FUNCTIONS
+
+=cut
+
+package WWW::OpenSVN::Base;
+
+sub new
+{
+    my $class = shift;
+    my $self = {};
+    bless $self, $class;
+    $self->initialize(@_);
+    return $self;
+}
+
+sub project
+{
+    my $self = shift;
+    return $self->{'project'};
+}
+
+package WWW::OpenSVN::Error;
+
+sub initialize
+{
+    my $self = shift;
+    my (%args) = (@_);
+    $self->{'project'} = $args{'project'};
+    $self->{'phase'} = $args{'phase'};
+
+    return 0;
+}
+
+sub phase
+{
+    my $self = shift;
+    return $self->{'phase'};
+}
+
+package WWW::OpenSVN;
+
+sub initialize
+{
+    my $self = shift;
+    my (%args) = (@_);
+    $self->{'project'} = $args{'project'}
+        or die "Project ID not specified!";
+    $self->{'password'} = $args{'password'}
+        or die "Project Password not speicified!";
+    return 0;
+}
+
+
+sub password
+{
+    my $self = shift;
+    return $self->{'password'};
+}
+
+sub gen_error
+{
+    my $self = shift;
+
+    my (%args) = (@_);
+
+    die
+        WWW::OpenSVN::Error->new(
+            'project' => $self->project(),
+            'phase' => $args{'phase'}
+        );
+}
+
+sub get_repos_revision
+{
+    my $self = shift;
+    if (exists($self->{'repos_version'}))
+    {
+        return $self->{'repos_version'};
+    }
+    my $project = $self->project();
+    my $url = "http://opensvn.csie.org/$project/";
+    my $page = get($url);
+    if ($page =~ /<title>Revision (\d+): \/<\/title>/)
+    {
+        return ($self->{'repos_version'} = $1);
+    }
+    else
+    {
+        $self->gen_error(
+            'phase' => 'get_repos_rev',
+        );
+    }
+}
+
+sub fetch_dump
+{
+    my $self = shift;
+    my (%args) = (@_);
+
+    my $url = "https://OpenSVN.csie.org/";
+
+    my $repos_top_version = get_repos_revision($self->project());
+    my %login_params =
+    (
+        'project' => $self->project(),
+        'password' => $self->password(),
+        'action' => "login",
+    );
+
+    my $ua = LWP::UserAgent->new();
+    $ua->cookie_jar({});
+    my $response = $ua->post($url, \%login_params);
+
+    if (!$response->is_success())
+    {
+        $self->gen_error(
+            'phase' => "login",
+        );
+    }
+
+    # We only need the previous response for the cookie.
+
+    my %backup_params =
+    (
+        'action' => "backup1",
+        'r1' => 0,
+        'r2' => $repos_top_version,
+        'i' => 1,
+        'd' => 1,
+    );
+
+    $response = $ua->post($url, \%backup_params);
+
+    if (! $response->is_success())
+    {
+        $self->gen_error(
+            'phase' => "dump_request",
+        );
+    }
+
+    my $server_return = $response->content();
+    
+    my $fetch_file_path;
+    if ($server_return =~ m{<meta http-equiv="refresh" content="0;url=/([^"]+)"})
+    {
+        $fetch_file_path = $1;
+    }
+    else
+    {
+        $self->gen_error(
+            'phase' => "dump_wrong_redirect",
+        );
+    }
+
+    $response =
+        $ua->get(
+            "$url/$fetch_file_path", 
+            ":content_file" => $self->project() . ".dump.gz",
+        );
+
+    if (! $response->is_success())
+    {
+        $self->gen_error(
+            'phase' => "dump_fetch"
+        );
+    }
+}
+
+=head1 AUTHOR
+
+Shlomi Fish, C<< <shlomif@iglu.org.il> >>
+
+=head1 BUGS
+
+Please report any bugs or feature requests to
+C<bug-www-opensvn@rt.cpan.org>, or through the web interface at
+L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=WWW-OpenSVN>.
+I will be notified, and then you'll automatically be notified of progress on
+your bug as I make changes.
+
+=head1 ACKNOWLEDGEMENTS
+
+=head1 COPYRIGHT & LICENSE
+
+Copyright 2005 Shlomi Fish, All Rights Reserved.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the MIT X11 License.
+
+=cut
+
+1; # End of WWW::OpenSVN
+use Test::More tests => 1;
+
+BEGIN {
+use_ok( 'WWW::OpenSVN' );
+}
+
+diag( "Testing WWW::OpenSVN $WWW::OpenSVN::VERSION, Perl 5.008006, /usr/bin/perl5.8.6" );

Perl/t/pod-coverage.t

+#!perl -T
+
+use Test::More;
+eval "use Test::Pod::Coverage 1.04";
+plan skip_all => "Test::Pod::Coverage 1.04 required for testing POD coverage" if $@;
+all_pod_coverage_ok();
+#!perl -T
+
+use Test::More;
+eval "use Test::Pod 1.14";
+plan skip_all => "Test::Pod 1.14 required for testing POD" if $@;
+all_pod_files_ok();