Xapian/Result.pm

filter: Statementstmt 83.3% 10 / 12 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod n/a totaltotal 87.5% 14 / 16 CC 1 SCAR 0.7
CC
1
Cov
83%
BEGIN
1.3
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
↑ Summary Xapian/Results.pm »
1 package SWISH::Prog::Xapian::Result;
2 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use base qw( SWISH::Prog::Result );
Subroutine BEGIN: called CC=1 SCAR=0.0
5 0 ▶use SWISH::3 ':constants';
Subroutine BEGIN: called CC=1 SCAR=2.6
6 use Carp;
7  
8 __PACKAGE__->mk_ro_accessors(qw( prop_id_map ));
9  
10 our $VERSION = '0.09';
11  
12 my $field_map = SWISH_DOC_FIELDS_MAP();
13  
14 =head1 NAME
15  
16 SWISH::Prog::Xapian::Result - search result for Swish3 Xapian backend
17  
18 =head1 SYNOPSIS
19  
20 # see SWISH::Prog::Result
21
22 =cut
23  
24 =head1 METHODS
25  
26 Only new and overridden methods are documented here. See
27 the L<SWISH::Prog::Result> documentation.
28  
29 =cut
30  
31 =head2 prop_id_map
32  
33 Get the read-only internal map for PropertyNames to id values.
34  
35 =head2 uri
36  
37 Returns the uri (unique term) for the result document.
38  
39 =cut
40  
41 sub uri { $_[0]->{doc}->get_value( $field_map->{uri} ) }
42  
43 =head2 title
44  
45 Returns the title of the result document.
46  
47 =cut
48  
49 sub title { $_[0]->{doc}->get_value( $field_map->{title} ) }
50  
51 =head2 mtime
52  
53 Returns the last modified time of the result document.
54  
55 =cut
56  
57 sub mtime {
58 $_[0]->{doc}->get_value( $field_map->{mtime} );
59 }
60  
61 =head2 summary
62  
63 Returns body of the result document.
64  
65 =cut
66  
67 sub summary {
68 $_[0]->{doc}->get_value( $field_map->{description} );
69 }
70  
71 =head2 get_property(I<name>)
72  
73 Returns value for PropertyName I<name>.
74  
75 =cut
76  
77 sub get_property {
78 my $self = shift;
79 my $name = shift;
80 if ( !defined $name ) {
81 croak "name required";
82 }
83 if ( !exists $self->{prop_id_map}->{$name} ) {
84 warn "prop_id_map: " . Data::Dump::dump( $self->{prop_id_map} );
85 croak "unrecognized PropertyName: $name";
86 }
87 return $self->{doc}->get_value( $self->{prop_id_map}->{$name} );
88 }
89  
90 1;
91  
92 __END__
↑ Summary Xapian/Results.pm »