| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Astro::ADS::Result; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
|
4
|
|
|
|
|
|
|
|
|
5
|
|
|
|
|
|
|
#+ |
|
6
|
|
|
|
|
|
|
# Name: |
|
7
|
|
|
|
|
|
|
# Astro::ADS::Result |
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
# Purposes: |
|
10
|
|
|
|
|
|
|
# Perl wrapper for the ADS database |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
# Language: |
|
13
|
|
|
|
|
|
|
# Perl module |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
# Description: |
|
16
|
|
|
|
|
|
|
# This module wraps the ADS online database. |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
# Authors: |
|
19
|
|
|
|
|
|
|
# Alasdair Allan (aa@astro.ex.ac.uk) |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
# Revision: |
|
22
|
|
|
|
|
|
|
# $Id: Result.pm,v 1.14 2001/12/03 03:41:45 aa Exp $ |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Copyright: |
|
25
|
|
|
|
|
|
|
# Copyright (C) 2001 University of Exeter. All Rights Reserved. |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
#- |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
# --------------------------------------------------------------------------- |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
=head1 NAME |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
Astro::ADS::Result - Results from an ADS Query |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
$result = new Astro::ADS::Result( Papers => \@papers ); |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
Stores the results returned from an ADS search as an array of |
|
42
|
|
|
|
|
|
|
Astro::ADS::Result::Paper objects. |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
# L O A D M O D U L E S -------------------------------------------------- |
|
47
|
|
|
|
|
|
|
|
|
48
|
5
|
|
|
5
|
|
553452
|
use strict; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
236
|
|
|
49
|
5
|
|
|
5
|
|
38
|
use warnings; |
|
|
5
|
|
|
|
|
11
|
|
|
|
5
|
|
|
|
|
184
|
|
|
50
|
5
|
|
|
5
|
|
27
|
use vars qw/ $VERSION /; |
|
|
5
|
|
|
|
|
10
|
|
|
|
5
|
|
|
|
|
263
|
|
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Overloading |
|
53
|
5
|
|
|
5
|
|
2034
|
use overload '""' => "stringify"; |
|
|
5
|
|
|
|
|
1792
|
|
|
|
5
|
|
|
|
|
52
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
5
|
|
|
5
|
|
12369
|
use Astro::ADS::Result::Paper; |
|
|
5
|
|
|
|
|
27
|
|
|
|
5
|
|
|
|
|
3134
|
|
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
'$Revision: 1.26 $ ' =~ /.*:\s(.*)\s\$/ && ($VERSION = $1); |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# C O N S T R U C T O R ---------------------------------------------------- |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
=head1 REVISION |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
$Id: Result.pm,v 1.14 2001/12/03 03:41:45 aa Exp $ |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 METHODS |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head2 Constructor |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
=over 4 |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=item B |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
Create a new instance from a hash of options |
|
74
|
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
$result = new Astro::ADS::Result( Papers => \@papers ); |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
returns a reference to an ADS Result object. |
|
78
|
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
=cut |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub new { |
|
82
|
10
|
|
|
10
|
1
|
35
|
my $proto = shift; |
|
83
|
10
|
|
33
|
|
|
91
|
my $class = ref($proto) || $proto; |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# bless the query hash into the class |
|
86
|
10
|
|
|
|
|
64
|
my $block = bless { RESULTS => [] }, $class; |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
# If we have arguments configure the object |
|
89
|
10
|
100
|
|
|
|
62
|
$block->configure( @_ ) if @_; |
|
90
|
|
|
|
|
|
|
|
|
91
|
10
|
|
|
|
|
42
|
return $block; |
|
92
|
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
} |
|
94
|
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
# A C C E S S O R -------------------------------------------------------- |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=back |
|
98
|
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=head2 Accessor Methods |
|
100
|
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
=over 4 |
|
102
|
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=item B |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
Return the number of papers in the Astro::ADS::Result object. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
$paper = $result->sizeof(); |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
=cut |
|
110
|
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
sub sizeof { |
|
112
|
7
|
|
|
7
|
1
|
44
|
my $self = shift; |
|
113
|
|
|
|
|
|
|
|
|
114
|
7
|
|
|
|
|
12
|
return scalar( @{$self->{RESULTS}} ); |
|
|
7
|
|
|
|
|
47
|
|
|
115
|
|
|
|
|
|
|
} |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=item B |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Push a new paper onto the end of the Astro::ADS::Result object |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
$result->pushpaper( $paper ); |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
returns the number of papers now in the Result object. |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
=cut |
|
126
|
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub pushpaper { |
|
128
|
234
|
|
|
234
|
1
|
519
|
my $self = shift; |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
# return unless we have arguments |
|
131
|
234
|
50
|
|
|
|
576
|
return unless @_; |
|
132
|
|
|
|
|
|
|
|
|
133
|
234
|
|
|
|
|
288
|
my $paper = shift; |
|
134
|
234
|
|
|
|
|
640
|
my $bibcode = $paper->bibcode(); |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
# push the new hash item onto the stack |
|
137
|
234
|
|
|
|
|
306
|
return push( @{$self->{RESULTS}}, $paper ); |
|
|
234
|
|
|
|
|
951
|
|
|
138
|
|
|
|
|
|
|
} |
|
139
|
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=item B |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Pop a paper from the end of the Astro::ADS::Result object |
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
$paper = $result->poppaper(); |
|
145
|
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
the method deletes the paper and returns the deleted paper object. |
|
147
|
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
=cut |
|
149
|
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
sub poppaper { |
|
151
|
1
|
|
|
1
|
1
|
2
|
my $self = shift; |
|
152
|
1
|
|
|
|
|
1
|
my $bibcode = shift; |
|
153
|
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
# pop the paper out of the stack |
|
155
|
1
|
|
|
|
|
2
|
return pop( @{$self->{RESULTS}} ); |
|
|
1
|
|
|
|
|
3
|
|
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
=item B |
|
159
|
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
Return a list of all the C objects |
|
161
|
|
|
|
|
|
|
stored in the results object. |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
@papers = $result->papers; |
|
164
|
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=cut |
|
166
|
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
sub papers { |
|
168
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
|
169
|
0
|
|
|
|
|
0
|
return @{ $self->{RESULTS} }; |
|
|
0
|
|
|
|
|
0
|
|
|
170
|
|
|
|
|
|
|
} |
|
171
|
|
|
|
|
|
|
|
|
172
|
|
|
|
|
|
|
=item B |
|
173
|
|
|
|
|
|
|
|
|
174
|
|
|
|
|
|
|
Return the Astro::ADS::Result::Paper object at index $index |
|
175
|
|
|
|
|
|
|
|
|
176
|
|
|
|
|
|
|
$paper = $result->paperbyindex( $index ); |
|
177
|
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
the first paper is at index 0 (not 1). Returns undef if no arguements |
|
179
|
|
|
|
|
|
|
are provided. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
|
182
|
|
|
|
|
|
|
|
|
183
|
|
|
|
|
|
|
sub paperbyindex { |
|
184
|
4
|
|
|
4
|
1
|
20
|
my $self = shift; |
|
185
|
|
|
|
|
|
|
|
|
186
|
|
|
|
|
|
|
# return unless we have arguments |
|
187
|
4
|
50
|
|
|
|
17
|
return unless @_; |
|
188
|
|
|
|
|
|
|
|
|
189
|
4
|
|
|
|
|
5
|
my $index = shift; |
|
190
|
|
|
|
|
|
|
|
|
191
|
4
|
|
|
|
|
7
|
return ${$self->{RESULTS}}[$index]; |
|
|
4
|
|
|
|
|
18
|
|
|
192
|
|
|
|
|
|
|
} |
|
193
|
|
|
|
|
|
|
|
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
# C O N F I G U R E ------------------------------------------------------- |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=back |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
=head2 General Methods |
|
200
|
|
|
|
|
|
|
|
|
201
|
|
|
|
|
|
|
=over 4 |
|
202
|
|
|
|
|
|
|
|
|
203
|
|
|
|
|
|
|
=item B |
|
204
|
|
|
|
|
|
|
|
|
205
|
|
|
|
|
|
|
Configures the object, takes an options hash as argument |
|
206
|
|
|
|
|
|
|
|
|
207
|
|
|
|
|
|
|
$result->configure( %options ); |
|
208
|
|
|
|
|
|
|
|
|
209
|
|
|
|
|
|
|
Takes a hash as argument with the following keywords: |
|
210
|
|
|
|
|
|
|
|
|
211
|
|
|
|
|
|
|
=over 4 |
|
212
|
|
|
|
|
|
|
|
|
213
|
|
|
|
|
|
|
=item B |
|
214
|
|
|
|
|
|
|
|
|
215
|
|
|
|
|
|
|
An reference to an array of Astro::ADS::Result::Paper objects. |
|
216
|
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
|
|
218
|
|
|
|
|
|
|
=back |
|
219
|
|
|
|
|
|
|
|
|
220
|
|
|
|
|
|
|
Does nothing if these keys are not supplied. |
|
221
|
|
|
|
|
|
|
|
|
222
|
|
|
|
|
|
|
=cut |
|
223
|
|
|
|
|
|
|
|
|
224
|
|
|
|
|
|
|
sub configure { |
|
225
|
1
|
|
|
1
|
1
|
1
|
my $self = shift; |
|
226
|
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
# return unless we have arguments |
|
228
|
1
|
50
|
|
|
|
3
|
return unless @_; |
|
229
|
|
|
|
|
|
|
|
|
230
|
|
|
|
|
|
|
# grab the argument list |
|
231
|
1
|
|
|
|
|
3
|
my %args = @_; |
|
232
|
|
|
|
|
|
|
|
|
233
|
1
|
50
|
|
|
|
4
|
if (defined $args{Papers}) { |
|
234
|
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
# Go through each of the supplied paper objects |
|
236
|
1
|
|
|
|
|
1
|
for my $i ( 0 ...$#{$args{Papers}} ) { |
|
|
1
|
|
|
|
|
556
|
|
|
237
|
2
|
|
|
|
|
3
|
${$self->{RESULTS}}[$i] = ${$args{Papers}}[$i]; |
|
|
2
|
|
|
|
|
35
|
|
|
|
2
|
|
|
|
|
3
|
|
|
238
|
|
|
|
|
|
|
} |
|
239
|
|
|
|
|
|
|
} |
|
240
|
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
} |
|
242
|
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=item B |
|
244
|
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Return a summary of the object as either plain text table or in XML. |
|
246
|
|
|
|
|
|
|
Simply invokes the C method of each paper in turn and combines |
|
247
|
|
|
|
|
|
|
the results as a single string. |
|
248
|
|
|
|
|
|
|
|
|
249
|
|
|
|
|
|
|
The arguments are passed through to the C method unchanged. |
|
250
|
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
=cut |
|
252
|
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
sub summary { |
|
254
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
255
|
0
|
|
|
|
|
|
my %args = @_; |
|
256
|
|
|
|
|
|
|
|
|
257
|
|
|
|
|
|
|
# Array for strings |
|
258
|
0
|
|
|
|
|
|
my @output; |
|
259
|
|
|
|
|
|
|
|
|
260
|
|
|
|
|
|
|
# If we are in XML mode we need to add a wrapper |
|
261
|
0
|
0
|
0
|
|
|
|
push(@output, "") if exists $args{format} and |
|
262
|
|
|
|
|
|
|
$args{format} eq 'XML'; |
|
263
|
|
|
|
|
|
|
|
|
264
|
|
|
|
|
|
|
# loop over papers |
|
265
|
0
|
|
|
|
|
|
push(@output, map { $_->summary(%args) } $self->papers); |
|
|
0
|
|
|
|
|
|
|
|
266
|
|
|
|
|
|
|
|
|
267
|
|
|
|
|
|
|
# If we are in XML mode we need to add a wrapper |
|
268
|
0
|
0
|
0
|
|
|
|
push(@output, "") if exists $args{format} and |
|
269
|
|
|
|
|
|
|
$args{format} eq 'XML'; |
|
270
|
|
|
|
|
|
|
|
|
271
|
0
|
|
|
|
|
|
return join("\n", @output). "\n"; |
|
272
|
|
|
|
|
|
|
} |
|
273
|
|
|
|
|
|
|
|
|
274
|
|
|
|
|
|
|
=item B |
|
275
|
|
|
|
|
|
|
|
|
276
|
|
|
|
|
|
|
Method called automatically when the object is printed in |
|
277
|
|
|
|
|
|
|
a string context. Simple invokes the C method with |
|
278
|
|
|
|
|
|
|
default arguments. |
|
279
|
|
|
|
|
|
|
|
|
280
|
|
|
|
|
|
|
=cut |
|
281
|
|
|
|
|
|
|
|
|
282
|
|
|
|
|
|
|
sub stringify { |
|
283
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
|
284
|
0
|
|
|
|
|
|
return $self->summary(); |
|
285
|
|
|
|
|
|
|
} |
|
286
|
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# T I M E A T T H E B A R -------------------------------------------- |
|
288
|
|
|
|
|
|
|
|
|
289
|
|
|
|
|
|
|
=back |
|
290
|
|
|
|
|
|
|
|
|
291
|
|
|
|
|
|
|
=head1 COPYRIGHT |
|
292
|
|
|
|
|
|
|
|
|
293
|
|
|
|
|
|
|
Copyright (C) 2001 University of Exeter. All Rights Reserved. |
|
294
|
|
|
|
|
|
|
|
|
295
|
|
|
|
|
|
|
This program was written as part of the eSTAR project and is free software; |
|
296
|
|
|
|
|
|
|
you can redistribute it and/or modify it under the terms of the GNU Public |
|
297
|
|
|
|
|
|
|
License. |
|
298
|
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
=head1 AUTHORS |
|
300
|
|
|
|
|
|
|
|
|
301
|
|
|
|
|
|
|
Alasdair Allan Eaa@astro.ex.ac.ukE, |
|
302
|
|
|
|
|
|
|
|
|
303
|
|
|
|
|
|
|
=cut |
|
304
|
|
|
|
|
|
|
|
|
305
|
|
|
|
|
|
|
# L A S T O R D E R S ------------------------------------------------------ |
|
306
|
|
|
|
|
|
|
|
|
307
|
|
|
|
|
|
|
1; |