lib/AI/MicroStructure/Util.pm

filter: Statementstmt 72.9% 35 / 48 Branchbran 37.5% 3 / 8 Conditioncond 34.7% 8 / 23 MC/DCmcdc 0.0% 0 / 13 Subroutinesub 100% 7 / 7 Podpod 0.0% 0 / 3 totaltotal 51.9% 53 / 102 CC 17 SCAR 29.1
CC
17
Cov
58%
load_config
37.5
config
9.4
get_cwd
2.1
CRAP 18.3
« lib/AI/MicroStructure/ObjectSet.pm ↑ Summary lib/AI/MicroStructure/Relations.pm »
1 package AI::MicroStructure::Util;
2  
3 8 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 8 ▶use Cwd;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 8 ▶use Config::Auto;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 8 ▶use Env qw/PWD/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 sub get_cwd {
9 8 ▶ my @CWD; if (!-e ".micro") {
Subroutine get_cwd: called CC=2 SCAR=7.4
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if (not -e '.micro') { } 8 0 8
10 8 push @CWD, $ENV{HOME}."/data-hub/";
11 } else {
12 0 push @CWD, getcwd();
13 }
14 8 return @CWD;
15 }
16  
17 sub load_config {
18  
19 8 ▶ my @CWD = AI::MicroStructure::Util::get_cwd();
Subroutine load_config: called CC=9 SCAR=36.2
Pod undocumented
20 8 my $config = {};#Config::Auto::parse(".micro", path => @CWD) || {};
21 8 ▶ if (-e ".micro" && -e $ENV{HOME}."/.micro") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e ".micro" and -e $ENV{"HOME"} . '/.micro') 0 8 8
Condition33%1/3
-e ".micro" and -e $ENV{"HOME"} . '/.micro'
!ll&&!rl&&r
800
MC/DC0%0/2
-e ".micro" and -e $ENV{"HOME"} . '/.micro'
-e ".micro" -e $ENV{"HOME"} . '/.micro'
Truth table33%1/3
A and B
A= -e ".micro"B= -e $ENV{"HOME"} . '/.micro'
ABresult
0X0
100
111
22 0 my $c = Config::Auto::parse($ENV{HOME}."/.micro");
23 0 ▶ foreach (keys %{$c}) { $config->{$_} ||= $c->{$_}; }
Condition0%0/3
$config->{$_} ||= $c->{$_}
l!l&&r!l&&!r
000
MC/DC0%0/2
$config->{$_} ||= $c->{$_}
$config->{$_} $c->{$_}
Truth table0%0/3
A ||= B
A= $config->{$_}B= $c->{$_}
ABresult
1X1
011
000
24 }
25 8 ▶ if($config->{default}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($config->{"default"}) 0 8 8
26 0 shift @CWD;
27 0 push @CWD, $config->{default};
28 0 ▶ if (-e "$CWD[0]/.micro") {
Branch: 1 branch
BranchTrueFalseTotal
if (-e "$CWD[0]/.micro") 0 0 0
29 0 my $c = Config::Auto::parse("$CWD[0]/.micro");
30 0 ▶ foreach (keys %{$config}) { $c->{$_} ||= $config->{$_}; }
Condition0%0/3
$c->{$_} ||= $config->{$_}
l!l&&r!l&&!r
000
MC/DC0%0/2
$c->{$_} ||= $config->{$_}
$c->{$_} $config->{$_}
Truth table0%0/3
A ||= B
A= $c->{$_}B= $config->{$_}
ABresult
1X1
011
000
31 0 $config = $c;
32 }
33 }
34 8 my $structdir = "structures";
35 8 my $path = {
36 "structures" => $structdir,
37 "cwd/structures" => "$CWD[0]/$structdir",
38 };
39  
40 8 return { "cwd" => @CWD, "path" => $path, "cfg" => $config };
41  
42 }
43  
44  
45 sub config {
46  
47 8 ▶ my $state = AI::MicroStructure::Util::load_config(); my @CWD = $state->{cwd};
Subroutine config: called CC=8 SCAR=22.4
Pod undocumented
48 8 ▶ $state->{cfg}->{query} ||= "micro";
Condition50%1/2
$state->{"cfg"}{"query"} ||= "micro"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"query"} ||= "micro"
$state->{"cfg"}{"query"}
Truth table50%1/2
A
A= $state->{"cfg"}{"query"}
Aresult
11
00
49 8 ▶ $state->{cfg}->{tempdir} ||= "/tmp/micro-temp/";
Condition50%1/2
$state->{"cfg"}{"tempdir"} ||= "/tmp/micro-temp/"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"tempdir"} ||= "/tmp/micro-temp/"
$state->{"cfg"}{"tempdir"}
Truth table50%1/2
A
A= $state->{"cfg"}{"tempdir"}
Aresult
11
00
50 8 ▶ $state->{cfg}->{couchdb} ||= "http://localhost:5984/";
Condition50%1/2
$state->{"cfg"}{"couchdb"} ||= "http://localhost:5984/"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"couchdb"} ||= "http://localhost:5984/"
$state->{"cfg"}{"couchdb"}
Truth table50%1/2
A
A= $state->{"cfg"}{"couchdb"}
Aresult
11
00
51 8 ▶ $state->{cfg}->{conceptimg} ||= "http://qunatup.com/tiny/concept2.php";
Condition50%1/2
$state->{"cfg"}{"conceptimg"} ||= "http://qunatup.com/tiny/concept2.php"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"conceptimg"} ||= "http://qunatup.com/tiny/concept2.php"
$state->{"cfg"}{"conceptimg"}
Truth table50%1/2
A
A= $state->{"cfg"}{"conceptimg"}
Aresult
11
00
52 8 ▶ $state->{cfg}->{wikipedia} ||= "http://en.wikipedia.org/wiki/";
Condition50%1/2
$state->{"cfg"}{"wikipedia"} ||= "http://en.wikipedia.org/wiki/"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"wikipedia"} ||= "http://en.wikipedia.org/wiki/"
$state->{"cfg"}{"wikipedia"}
Truth table50%1/2
A
A= $state->{"cfg"}{"wikipedia"}
Aresult
11
00
53 8 ▶ $state->{cfg}->{db} ||= "table";
Condition50%1/2
$state->{"cfg"}{"db"} ||= "table"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"db"} ||= "table"
$state->{"cfg"}{"db"}
Truth table50%1/2
A
A= $state->{"cfg"}{"db"}
Aresult
11
00
54 8 ▶ $state->{cfg}->{out} ||= "json";
Condition50%1/2
$state->{"cfg"}{"out"} ||= "json"
l!l
08
MC/DC0%0/1
$state->{"cfg"}{"out"} ||= "json"
$state->{"cfg"}{"out"}
Truth table50%1/2
A
A= $state->{"cfg"}{"out"}
Aresult
11
00
55 $state->{cfg}->{jsonout} = sprintf("%s/%s/",
56 $state->{cwd},
57 8 $state->{cfg}->{db});
58  
59  
60  
61  
62  
63 8 return $state;
64 }
65 8 1;
« lib/AI/MicroStructure/ObjectSet.pm ↑ Summary lib/AI/MicroStructure/Relations.pm »