blib/lib/Kook/Sandbox.pm

filter: Statementstmt 88.0% 44 / 50 Branchbran 50.0% 4 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 84.6% 11 / 13 Podpod 0.0% 0 / 3 totaltotal 79.7% 59 / 74 CC 5 SCAR 8.8
CC
5
Cov
83%
default
6.0
desc
6.0
prop
2.0
CRAP 2.4
« blib/lib/Kook/Misc.pm ↑ Summary blib/lib/Kook.pm »
1 ###
2 ### $Release: 0.0100 $
3 ### $Copyright: copyright(c) 2009-2011 kuwata-lab.com all rights reserved. $
4 ### $License: MIT License $
5 ###
6  
7  
8 package Kook::Sandbox;
9 38 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 38 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 38 ▶use Kook::Recipe;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 38 ▶use Kook::Commands qw(sys sys_f echo echo_n cp cp_p cp_r cp_pr mkdir mkdir_p rm rm_r rm_f rm_rf rmdir mv store store_p cd edit);
Subroutine BEGIN: called CC=1 SCAR=0.0
14 38 ▶use Kook::Util ('repr');
Subroutine BEGIN: called CC=1 SCAR=0.0
15  
16 38 our @_recipes; # out
17 38 our %_properties; # in
18 38 our @_property_tuples; # out
19 38 our $kook_default; # out # for backward compatibilidy
20 38 our $kook_desc; # out # for backward compatibilidy
21 38 our $kook; # out
22  
23 52 ▶sub __init {
Subroutine __init: called CC=1 SCAR=0.0
24 52 @_recipes = ();
25 52 %_properties = ();
26 52 @_property_tuples = ();
27 52 $kook_default = undef;
28 52 $kook_desc = undef;
29 52 $kook = Kook::Sandbox::BookConfig->new();
30 }
31  
32 249 ▶sub recipe {
Subroutine recipe: called CC=1 SCAR=0.0
Pod undocumented
33 249 my $recipe_obj = Kook::Recipe->new(@_);
34 249 push(@_recipes, $recipe_obj);
35 249 return $recipe_obj;
36 }
37  
38 135 ▶sub prop {
Subroutine prop: called CC=2 SCAR=6.9
Pod undocumented
39 135 my ($name, $default_value, $desc) = @_;
40 135 ▶ my $value = exists($_properties{$name}) ? $_properties{$name} : $default_value;
Branch: 1 branch
BranchTrueFalseTotal
exists $Kook::Sandbox::_properties{$name} ? : 5 130 135
41 135 push(@_property_tuples, [$name, $value, $desc]);
42 135 return $value;
43 }
44  
45 25 ▶sub private_prop {
Subroutine private_prop: called CC=1 SCAR=0.0
Pod undocumented
46 25 my ($name, $default_value, $desc) = @_;
47 25 return prop($name, $default_value, -1); # if $desc is -1, that property is regarded as private
48 }
49  
50 52 ▶sub _eval {
Subroutine _eval: called CC=2 SCAR=6.9
51 52 my ($_script, $_filename, $_props) = @_;
52 52 __init();
53 52 ▶ %_properties = %$_props if $_props;
Branch: 1 branch
BranchTrueFalseTotal
if $_props 29 23 52
54 52 eval "# line 1 \"$_filename\"\n".$_script;
55 }
56  
57  
58 package Kook::Sandbox::BookConfig;
59  
60 52 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
61 52 my ($class) = @_;
62 52 my $this = {
63 default => undef,
64 desc => undef,
65 };
66 52 return bless($this, $class);
67 }
68  
69 0 ▶sub default {
Subroutine default: not called CC=2 SCAR=17.9
70 0 my $this = shift;
71 0 ▶ $this->{default} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
72 0 return $this->{default};
73 }
74  
75 0 ▶sub desc {
Subroutine desc: not called CC=2 SCAR=17.9
76 0 my $this = shift;
77 0 ▶ $this->{desc} = shift if @_;
Branch: 1 branch
BranchTrueFalseTotal
if @_ 0 0 0
78 0 return $this->{desc};
79 }
80  
81  
82 38 1;
« blib/lib/Kook/Misc.pm ↑ Summary blib/lib/Kook.pm »