buildlib/Lucy/Build/Binding/Highlight.pm

filter: Statementstmt 100% 27 / 27 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 5 / 5 Podpod 0.0% 0 / 3 totaltotal 91.4% 32 / 35 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
bind_all
1.0
CRAP 1.0
« buildlib/Lucy/Build/Binding/Object.pm ↑ Summary Charmony.pm »
1 # Licensed to the Apache Software Foundation (ASF) under one or more
2 # contributor license agreements. See the NOTICE file distributed with
3 # this work for additional information regarding copyright ownership.
4 # The ASF licenses this file to You under the Apache License, Version 2.0
5 # (the "License"); you may not use this file except in compliance with
6 # the License. You may obtain a copy of the License at
7 #
8 # http://www.apache.org/licenses/LICENSE-2.0
9 #
10 # Unless required by applicable law or agreed to in writing, software
11 # distributed under the License is distributed on an "AS IS" BASIS,
12 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
15 package Lucy::Build::Binding::Highlight;
16 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 1 our $VERSION = '0.008000';
20 1 $VERSION = eval $VERSION;
21  
22 1 ▶sub bind_all {
Subroutine bind_all: called CC=1 SCAR=0.0
Pod undocumented
23 1 my $class = shift;
24 1 $class->bind_heatmap;
25 1 $class->bind_highlighter;
26 }
27  
28 1 ▶sub bind_heatmap {
Subroutine bind_heatmap: called CC=1 SCAR=0.0
Pod undocumented
29 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
30 1 my $constructor = <<'END_CONSTRUCTOR';
31 my $heat_map = Lucy::Highlight::HeatMap->new(
32 spans => \@highlight_spans,
33 window => 100,
34 );
35 END_CONSTRUCTOR
36 1 $pod_spec->add_constructor( alias => 'new', sample => $constructor );
37  
38 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
39 parcel => "Lucy",
40 class_name => "Lucy::Highlight::HeatMap",
41 );
42 #$binding->set_pod_spec($pod_spec); TODO
43  
44 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
45 }
46  
47 1 ▶sub bind_highlighter {
Subroutine bind_highlighter: called CC=1 SCAR=0.0
Pod undocumented
48 1 my $pod_spec = Clownfish::CFC::Binding::Perl::Pod->new;
49 1 my $synopsis = <<'END_SYNOPSIS';
50 my $highlighter = Lucy::Highlight::Highlighter->new(
51 searcher => $searcher,
52 query => $query,
53 field => 'body'
54 );
55 my $hits = $searcher->hits( query => $query );
56 while ( my $hit = $hits->next ) {
57 my $excerpt = $highlighter->create_excerpt($hit);
58 ...
59 }
60 END_SYNOPSIS
61 1 my $constructor = <<'END_CONSTRUCTOR';
62 my $highlighter = Lucy::Highlight::Highlighter->new(
63 searcher => $searcher, # required
64 query => $query, # required
65 field => 'content', # required
66 excerpt_length => 150, # default: 200
67 );
68 END_CONSTRUCTOR
69 1 $pod_spec->set_synopsis($synopsis);
70 1 $pod_spec->add_constructor( alias => 'new', sample => $constructor );
71  
72 1 my $binding = Clownfish::CFC::Binding::Perl::Class->new(
73 parcel => "Lucy",
74 class_name => "Lucy::Highlight::Highlighter",
75 );
76 1 $binding->bind_method(
77 alias => '_raw_excerpt',
78 method => 'Raw_Excerpt'
79 );
80 1 $binding->bind_method(
81 alias => '_highlight_excerpt',
82 method => 'Highlight_Excerpt'
83 );
84 1 $binding->set_pod_spec($pod_spec);
85  
86 1 Clownfish::CFC::Binding::Perl::Class->register($binding);
87 }
88  
89 1 1;
« buildlib/Lucy/Build/Binding/Object.pm ↑ Summary Charmony.pm »