| 1 | package Shipwright::Backend; | ||||||||||
| 2 | |||||||||||
| 3 | 6 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 6 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 6 | ▶ | use UNIVERSAL::require; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 6 | ▶ | use Shipwright::Util; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | |||||||||||
| 8 | 17 | ▶ | sub new { | ||||||||
|
Subroutine
new: called CC=6 SCAR=18.0
Pod
documented
| |||||||||||
| 9 | 17 | my $class = shift; | |||||||||
| 10 | 17 | my %args = @_; | |||||||||
| 11 | |||||||||||
| 12 | 17 | ▶ | confess_or_die 'need repository arg' unless exists $args{repository}; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 13 | |||||||||||
| 14 | 16 | $args{repository} =~ s/^\s+//; | |||||||||
| 15 | 16 | $args{repository} =~ s/\s+$//; | |||||||||
| 16 | |||||||||||
| 17 | # exception for svk repos, they can start with // | ||||||||||
| 18 | 16 | ▶ | if ( $args{repository} =~ m{^//} ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 19 | 1 | $args{repository} = 'svk:'. $args{repository}; | |||||||||
| 20 | } | ||||||||||
| 21 | |||||||||||
| 22 | 16 | my $backend; | |||||||||
| 23 | 16 | ▶ | if ( $args{repository} =~ /^([a-z]+)(?:\+([a-z]+))?:/ ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 12 | ($backend) = $1; | |||||||||
| 25 | } else { | ||||||||||
| 26 | 4 | confess_or_die "invalid repository, doesn't start with xxx: or xxx+yyy:"; | |||||||||
| 27 | } | ||||||||||
| 28 | |||||||||||
| 29 | 12 | my $module = find_module(__PACKAGE__, $backend); | |||||||||
| 30 | 12 | ▶ | unless ( $module ) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | 0 | confess_or_die "Couldn't find backend implementing '$backend'"; | |||||||||
| 32 | } | ||||||||||
| 33 | |||||||||||
| 34 | $module->require | ||||||||||
| 35 | 12 | ▶ | or confess_or_die "Couldn't load module '$module'" | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | ." implementing backend '$backend': $@"; | ||||||||||
| 37 | 12 | return $module->new(%args); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | 6 | 1; | |||||||||
| 41 | |||||||||||
| 42 | __END__ | ||||||||||