blib/lib/Dancer/Plugin/Apache/Solr.pm

filter: Statementstmt 97.3% 36 / 37 Branchbran 87.5% 14 / 16 Conditioncond 50.0% 1 / 2 MC/DCmcdc 0.0% 0 / 1 Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 91.9% 57 / 62 CC 10 SCAR 19.6
CC
10
Cov
93%
solr
10.1
BEGIN
1.0
BEGIN
1.0
CRAP 7.1
↑ Summary
1 package Dancer::Plugin::Apache::Solr;
2  
3 4 our $VERSION = '0.001'; # VERSION
4  
5 4 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 4 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 4 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
8 4 ▶use Dancer::Plugin;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 4 ▶use Apache::Solr;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 4 my $servers = {};
12  
13 9 ▶sub solr {
Subroutine solr: called CC=10 SCAR=23.2
14 9 my ($self, $name) = plugin_args(@_);
15 9 my $cfg = plugin_setting;
16  
17 9 ▶ if (not defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $name) 5 4 9
18 5 ▶ if (keys %$cfg == 1) {
Branch: 2 branches
BranchTrueFalseTotal
if (keys %$cfg == 1) { } 1 4 5
elsif (keys %$cfg) { } 4 0 4
19 1 ($name) = keys %$cfg;
20 } elsif (keys %$cfg) {
21 4 $name = "default";
22 } else {
23 0 die "No Solr servers are configured";
24 }
25 }
26  
27 9 ▶ return $servers->{$name} if $servers->{$name};
Branch: 1 branch
BranchTrueFalseTotal
if $servers->{$name} 1 8 9
28  
29 8 ▶ my $options = $cfg->{$name} or die "The server $name is not configured";
Branch: 1 branch
BranchTrueFalseTotal
my $options = $cfg->{$name} or die "The server $name is not configured" 6 2 8
30  
31 6 ▶ if ( my $alias = $options->{alias} ) {
Branch: 1 branch
BranchTrueFalseTotal
if (my $alias = $options->{"alias"}) 3 3 6
32 3 ▶ $options = $cfg->{$alias}
Branch: 1 branch
BranchTrueFalseTotal
$options = $cfg->{$alias} or die "The server alias $alias does not exist in the config" 2 1 3
33 or die "The server alias $alias does not exist in the config";
34 2 ▶ return $servers->{$alias} if $servers->{$alias};
Branch: 1 branch
BranchTrueFalseTotal
if $servers->{$alias} 2 0 2
35 }
36  
37 my $server_info =
38 $options->{server_info}
39 //
40 {
41 3 ▶ map { $_, $options->{$_} } qw(
Condition50%1/2
$options->{"server_info"} // {map({$_, $options->{$_};} "autocommit", "core", "format", "server", "server_version")}
l!l
03
MC/DC0%0/1
$options->{"server_info"} // {map({$_, $options->{$_};} "autocommit", "core", "format", "server", "server_version")}
$options->{"server_info"}
Truth table50%1/2
A
A= $options->{"server_info"}
Aresult
11
00
42 autocommit
43 core
44 format
45 server
46 server_version
47 )
48 }
49 ;
50  
51 3 my $server;
52  
53 3 $server = Apache::Solr->new(%$server_info);
54  
55 3 return $servers->{$name} = $server;
56 };
57  
58 4 register solr => \&solr;
59  
60 4 register_plugin for_versions => [ 1, 2 ];
61  
62 # ABSTRACT: Apache::Solr interface for Dancer applications
63  
64  
65 4 1;
66  
67 __END__
↑ Summary