Shipwright::Backend - Backend


Shipwright documentation Contained in the Shipwright distribution.

Index


Code Index:

NAME

Top

Shipwright::Backend - Backend

SYNOPSIS

Top

    # shipwright some_command -r backend_type:path
    shipwright create -r svn:file:///svnrepo/shipwright/my_proj

DESCRIPTION

Top

See <Shipwright::Manual::Glossary/shipyard> to understand its concept. Look at list of </SUPPORTED BACKENDS> or IMPLEMENTING BACKENDS if you want add a new one.

SUPPORTED BACKENDS

Top

Currently, the supported backends are FS (Shipwright::BACKEND::FS), Git (Shipwright::BACKEND::Git), SVK (Shipwright::BACKEND::SVK) and SVN (Shipwright::BACKEND::SVN).

IMPLEMENTING BACKENDS

Top

Each implementation of a backend is a subclass of Shipwright::Backend::Base.

METHODS

Top

This is a tiny class with only one method new that loads particular implementation class and returns instance of that class.

new repository => "type:path"

Returns the backend object that corresponds to the type defined in the repository argument.

AUTHORS

Top

sunnavy <sunnavy@bestpractical.com>

LICENCE AND COPYRIGHT

Top


Shipwright documentation Contained in the Shipwright distribution.

package Shipwright::Backend;

use warnings;
use strict;
use UNIVERSAL::require;
use Shipwright::Util;

sub new {
    my $class = shift;
    my %args  = @_;

    confess_or_die 'need repository arg' unless exists $args{repository};

    $args{repository} =~ s/^\s+//;
    $args{repository} =~ s/\s+$//;

    # exception for svk repos, they can start with //
    if ( $args{repository} =~ m{^//} ) {
        $args{repository} = 'svk:'. $args{repository};
    }

    my $backend;
    if ( $args{repository} =~ /^([a-z]+)(?:\+([a-z]+))?:/ ) {
        ($backend) = $1;
    } else {
        confess_or_die "invalid repository, doesn't start with xxx: or xxx+yyy:";
    }

    my $module = find_module(__PACKAGE__, $backend);
    unless ( $module ) {
        confess_or_die "Couldn't find backend implementing '$backend'";
    }

    $module->require
        or confess_or_die "Couldn't load module '$module'"
            ." implementing backend '$backend': $@";
    return $module->new(%args);
}

1;

__END__