OpenInteract2/Manage/Package/CreatePackage.pm

filter: Statementstmt 44.4% 12 / 27 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 57.1% 4 / 7 Podpod 0.0% 0 / 5 totaltotal 34.0% 16 / 47 CC 5 SCAR 21.9
CC
5
Cov
34%
validate_param
20.0
run_task
6.0
get_brief_description
2.0
CRAP 8.9
« OpenInteract2/Config/Bootstrap.pm ↑ Summary OpenInteract2/Request/CGI.pm »
1 package OpenInteract2::Manage::Package::CreatePackage;
2  
3 # $Id: CreatePackage.pm,v 1.15 2005/03/17 14:58:03 sjn Exp $
4  
5 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 87 ▶use base qw( OpenInteract2::Manage::Package );
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 87 $OpenInteract2::Manage::Package::CreatePackage::VERSION = sprintf("%d.%02d", q$Revision: 1.15 $ =~ /(\d+)\.(\d+)/);
9  
10 # METADATA
11  
12 87 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod undocumented
13 87 return 'create_package';
14 }
15  
16 0 ▶sub get_brief_description {
Subroutine get_brief_description: not called CC=1 SCAR=6.9
Pod undocumented
17 0 return 'Create a new package, with most of the pieces filled in for you';
18 }
19  
20 1 ▶sub get_parameters {
Subroutine get_parameters: called CC=1 SCAR=0.0
Pod undocumented
21 1 my ( $self ) = @_;
22 return {
23 1 package => {
24 description => 'Name of the package to create',
25 is_required => 'yes',
26 },
27 package_dir => {
28 description => 'Directory to create package in',
29 do_validate => 'yes',
30 },
31 };
32 }
33  
34 # VALIDATION
35  
36 0 ▶sub validate_param {
Subroutine validate_param: not called CC=4 SCAR=30.0
Pod undocumented
37 0 my ( $self, $name, $value ) = @_;
38 0 ▶ if ( $name eq 'package_dir' ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($name eq "package_dir") 0 0 0
39 0 ▶ return undef unless ( $value );
Branch: 1 branch
BranchTrueFalseTotal
unless $value 0 0 0
40 0 ▶ return undef if ( -d $value );
Branch: 1 branch
BranchTrueFalseTotal
if -d $value 0 0 0
41 0 return "If specified 'package_dir' must be a valid directory";
42 }
43 0 return $self->SUPER::validate_param( $name, $value );
44 }
45  
46 # TASK
47  
48 0 ▶sub run_task {
Subroutine run_task: not called CC=2 SCAR=17.9
Pod undocumented
49 0 my ( $self ) = @_;
50 0 ▶ if ( $self->param( 'package_dir' ) ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($self->param("package_dir")) 0 0 0
51 0 chdir( $self->param( 'package_dir' ) );
52 }
53 0 my $package_name = $self->param( 'package' )->[0];
54 0 my $package = OpenInteract2::Package->create_skeleton({
55 name => $package_name,
56 });
57 0 my $msg = sprintf( 'Package %s created ok in %s',
58 $package->name, $package->directory );
59 0 $self->_ok( "create package $package_name", $msg );
60 0 return;
61 }
62  
63 87 OpenInteract2::Manage->register_factory_type( get_name() => __PACKAGE__ );
64  
65 87 1;
66  
67 __END__
« OpenInteract2/Config/Bootstrap.pm ↑ Summary OpenInteract2/Request/CGI.pm »