line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Genealogy::ObituaryDailyTimes; |
2
|
|
|
|
|
|
|
|
3
|
4
|
|
|
4
|
|
370892
|
use warnings; |
|
4
|
|
|
|
|
26
|
|
|
4
|
|
|
|
|
142
|
|
4
|
4
|
|
|
4
|
|
19
|
use strict; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
72
|
|
5
|
4
|
|
|
4
|
|
17
|
use Carp; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
202
|
|
6
|
4
|
|
|
4
|
|
24
|
use File::Spec; |
|
4
|
|
|
|
|
7
|
|
|
4
|
|
|
|
|
115
|
|
7
|
4
|
|
|
4
|
|
2063
|
use Module::Info; |
|
4
|
|
|
|
|
28464
|
|
|
4
|
|
|
|
|
134
|
|
8
|
4
|
|
|
4
|
|
1995
|
use Genealogy::ObituaryDailyTimes::DB; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
158
|
|
9
|
4
|
|
|
4
|
|
1750
|
use Genealogy::ObituaryDailyTimes::DB::obituaries; |
|
4
|
|
|
|
|
11
|
|
|
4
|
|
|
|
|
2310
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
=head1 NAME |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
Genealogy::ObituaryDailyTimes - Lookup an entry in the Obituary Daily Times |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
=head1 VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
Version 0.10 |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
=cut |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
our $VERSION = '0.10'; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
use Genealogy::ObituaryDailyTimes; |
26
|
|
|
|
|
|
|
my $info = Genealogy::ObituaryDailyTimes->new(); |
27
|
|
|
|
|
|
|
# ... |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SUBROUTINES/METHODS |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head2 new |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Creates a Genealogy::ObituaryDailyTimes object. |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
Takes two optional arguments: |
36
|
|
|
|
|
|
|
directory: that is the directory containing obituaries.sql |
37
|
|
|
|
|
|
|
logger: an object to send log messages to |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=cut |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub new { |
42
|
5
|
|
|
5
|
1
|
3228
|
my $class = $_[0]; |
43
|
5
|
|
|
|
|
10
|
shift; |
44
|
5
|
50
|
|
|
|
18
|
my %args = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_; |
|
0
|
|
|
|
|
0
|
|
45
|
|
|
|
|
|
|
|
46
|
5
|
100
|
|
|
|
18
|
if(!defined($class)) { |
|
|
100
|
|
|
|
|
|
47
|
|
|
|
|
|
|
# Use Genealogy::ObituaryDailyTimes->new, not Genealogy::ObituaryDailyTimes::new |
48
|
|
|
|
|
|
|
# carp(__PACKAGE__, ' use ->new() not ::new() to instantiate'); |
49
|
|
|
|
|
|
|
# return; |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
# FIXME: this only works when no arguments are given |
52
|
1
|
|
|
|
|
2
|
$class = __PACKAGE__; |
53
|
|
|
|
|
|
|
} elsif(ref($class)) { |
54
|
|
|
|
|
|
|
# clone the given object |
55
|
1
|
|
|
|
|
1
|
return bless { %{$class}, %args }, ref($class); |
|
1
|
|
|
|
|
9
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
4
|
|
33
|
|
|
26
|
my $directory = $args{'directory'} || Module::Info->new_from_loaded(__PACKAGE__)->file(); |
59
|
4
|
|
|
|
|
550
|
$directory =~ s/\.pm$//; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
# The database is updated daily |
62
|
4
|
|
50
|
|
|
115
|
$args{'cache_duration'} ||= '1 day'; |
63
|
|
|
|
|
|
|
|
64
|
4
|
|
|
|
|
55
|
Genealogy::ObituaryDailyTimes::DB::init(directory => File::Spec->catfile($directory, 'database'), %args); |
65
|
4
|
|
|
|
|
24
|
return bless { }, $class; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
=head2 search |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
my $obits = Genealogy::ObituaryDailyTimes->new(); |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
# Returns an array of hashrefs |
73
|
|
|
|
|
|
|
my @smiths = $obits->search(last => 'Smith'); # You must at least define the last name to search for |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
print $smiths[0]->{'first'}, "\n"; |
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
=cut |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub search { |
80
|
3
|
|
|
3
|
1
|
770
|
my $self = shift; |
81
|
|
|
|
|
|
|
|
82
|
3
|
100
|
|
|
|
13
|
my %params = (ref($_[0]) eq 'HASH') ? %{$_[0]} : @_; |
|
1
|
|
|
|
|
6
|
|
83
|
|
|
|
|
|
|
|
84
|
3
|
50
|
|
|
|
9
|
if(!defined($params{'last'})) { |
85
|
3
|
|
|
|
|
10
|
Carp::carp("Value for 'last' is mandatory"); |
86
|
3
|
|
|
|
|
944
|
return; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
0
|
|
|
|
$self->{'obituaries'} ||= Genealogy::ObituaryDailyTimes::DB::obituaries->new(no_entry => 1); |
90
|
|
|
|
|
|
|
|
91
|
0
|
0
|
|
|
|
|
if(!defined($self->{'obituaries'})) { |
92
|
0
|
|
|
|
|
|
Carp::croak("Can't open the obituaries database"); |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
0
|
0
|
|
|
|
|
if(wantarray) { |
96
|
0
|
|
|
|
|
|
my @obituaries = @{$self->{'obituaries'}->selectall_hashref(\%params)}; |
|
0
|
|
|
|
|
|
|
97
|
0
|
|
|
|
|
|
foreach my $obit(@obituaries) { |
98
|
0
|
|
|
|
|
|
$obit->{'url'} = _create_url($obit); |
99
|
|
|
|
|
|
|
} |
100
|
0
|
|
|
|
|
|
return @obituaries; |
101
|
|
|
|
|
|
|
} |
102
|
0
|
0
|
|
|
|
|
if(defined(my $obit = $self->{'obituaries'}->fetchrow_hashref(\%params))) { |
103
|
0
|
|
|
|
|
|
$obit->{'url'} = _create_url($obit); |
104
|
0
|
|
|
|
|
|
return $obit; |
105
|
|
|
|
|
|
|
} |
106
|
0
|
|
|
|
|
|
return; # undef |
107
|
|
|
|
|
|
|
} |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
sub _create_url { |
110
|
0
|
|
|
0
|
|
|
my $obit = shift; |
111
|
0
|
|
|
|
|
|
my $source = $obit->{'source'}; |
112
|
0
|
|
|
|
|
|
my $page = $obit->{'page'}; |
113
|
|
|
|
|
|
|
|
114
|
0
|
0
|
|
|
|
|
if(!defined($page)) { |
115
|
|
|
|
|
|
|
# use Data::Dumper; |
116
|
|
|
|
|
|
|
# ::diag(Data::Dumper->new([$obit])->Dump()); |
117
|
0
|
|
|
|
|
|
Carp::croak(__PACKAGE__, ': undefined $page'); |
118
|
|
|
|
|
|
|
} |
119
|
0
|
0
|
|
|
|
|
if(!defined($source)) { |
120
|
0
|
|
|
|
|
|
Carp::croak(__PACKAGE__, ": $page: undefined source"); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
0
|
0
|
|
|
|
|
if($source eq 'M') { |
124
|
0
|
|
|
|
|
|
return "https://mlarchives.rootsweb.com/listindexes/emails?listname=gen-obit&page=$page"; |
125
|
|
|
|
|
|
|
} |
126
|
0
|
0
|
|
|
|
|
if($source eq 'F') { |
127
|
0
|
|
|
|
|
|
return "https://www.freelists.org/post/obitdailytimes/Obituary-Daily-Times-$page"; |
128
|
|
|
|
|
|
|
} |
129
|
0
|
|
|
|
|
|
Carp::croak(__PACKAGE__, ": Invalid source, '$source'"); |
130
|
|
|
|
|
|
|
} |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=head1 AUTHOR |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Nigel Horne, C<< >> |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=head1 BUGS |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=head1 SEE ALSO |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
The Obituary Daily Times, L |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=head1 SUPPORT |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
perldoc Genealogy::ObituaryDailyTimes |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
You can also look for information at: |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=over 4 |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=item * MetaCPAN |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
L |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
L |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
=item * CPAN Testers' Matrix |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
L |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=item * CPAN Testers Dependencies |
165
|
|
|
|
|
|
|
|
166
|
|
|
|
|
|
|
L |
167
|
|
|
|
|
|
|
|
168
|
|
|
|
|
|
|
=back |
169
|
|
|
|
|
|
|
|
170
|
|
|
|
|
|
|
=head1 LICENSE AND COPYRIGHT |
171
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
Copyright 2020-2023 Nigel Horne. |
173
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
This program is released under the following licence: GPL2 |
175
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
=cut |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; |