OpenInteract2/Manage/Website/ThemeDump.pm

filter: Statementstmt 39.1% 18 / 46 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 75.0% 6 / 8 Podpod 0.0% 0 / 4 totaltotal 36.3% 24 / 66 CC 6 SCAR 30.0
CC
6
Cov
33%
run_task
42.0
get_brief_description
2.0
BEGIN
1.0
CRAP 20.0
« OpenInteract2/ErrorStorage.pm ↑ Summary OpenInteract2/Setup/RequireIndexers.pm »
1 package OpenInteract2::Manage::Website::ThemeDump;
2  
3 # $Id: ThemeDump.pm,v 1.10 2005/03/17 14:58:04 sjn Exp $
4  
5 87 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 87 ▶use base qw( OpenInteract2::Manage::Website );
Subroutine BEGIN: called CC=1 SCAR=0.0
7 87 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 87 ▶use OpenInteract2::Context qw( CTX );
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10  
11 87 $OpenInteract2::Manage::Website::ThemeDump::VERSION = sprintf("%d.%02d", q$Revision: 1.10 $ =~ /(\d+)\.(\d+)/);
12  
13 87 ▶sub get_name {
Subroutine get_name: called CC=1 SCAR=0.0
Pod undocumented
14 87 return 'dump_theme';
15 }
16  
17 0 ▶sub get_brief_description {
Subroutine get_brief_description: not called CC=1 SCAR=6.9
Pod undocumented
18 0 return 'Dump a theme to a distributable format';
19 }
20  
21 1 ▶sub get_parameters {
Subroutine get_parameters: called CC=1 SCAR=0.0
Pod undocumented
22 1 my ( $self ) = @_;
23 return {
24 1 website_dir => $self->_get_website_dir_param,
25 theme_id => {
26 description => 'ID of theme to export',
27 is_required => 'yes',
28 },
29 theme_file => {
30 description => 'Name of file to export the theme to',
31 is_required => 'yes',
32 },
33 };
34 }
35  
36 # We don't validate theme_id until run_task() since context isn't yet
37 # created
38  
39 0 ▶sub run_task {
Subroutine run_task: not called CC=6 SCAR=37.4
Pod undocumented
40 0 my ( $self ) = @_;
41 0 my $action = 'dump theme';
42  
43 0 my $theme_id = $self->param( 'theme_id' );
44 0 my $theme = eval {
45 0 CTX->lookup_object( 'theme' )->fetch( $theme_id )
46 };
47 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
48 0 $self->_fail( $action, "Error fetching theme '$theme_id': $@" );
49 0 return;
50 }
51  
52 0 my $properties = eval { $theme->themeprop };
53 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
54 0 $self->_fail( $action, "Error fetching theme properties: $@" );
55 0 return;
56 }
57  
58 0 my @structure = (
59 { theme_fields => [ qw( title description credit ) ],
60 theme_prop_fields => [ qw( prop value description ) ] },
61 [ $theme->title, $theme->description, $theme->credit ]
62 );
63  
64 0 foreach my $prop ( @{ $properties } ) {
65 0 push @structure, [ $prop->prop, $prop->value, $prop->description ];
66 }
67  
68 0 my $filename = $self->param( 'theme_file' );
69 0 ▶ eval { open( THEMEBALL, '>', $filename ) || die $! };
Branch: 1 branch
BranchTrueFalseTotal
open THEMEBALL, ">", $filename or die $! 0 0 0
70 0 ▶ if ( $@ ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
71 0 $self->_fail( $action,
72 "Could not open themeball file '$filename': $@" );
73 0 return;
74 }
75 0 print THEMEBALL Data::Dumper->Dump( [ \@structure ], [ 'themeball' ] );
76 0 close THEMEBALL;
77 0 $self->_ok( $action, "Themeball saved ok",
78 filename => $filename );
79 0 return;
80 }
81  
82 87 OpenInteract2::Manage->register_factory_type( get_name() => __PACKAGE__ );
83  
84 87 1;
85  
86 __END__
« OpenInteract2/ErrorStorage.pm ↑ Summary OpenInteract2/Setup/RequireIndexers.pm »