File Coverage

blib/lib/Astro/ADS/Paper.pm
Criterion Covered Total %
statement 18 22 81.8
branch 0 2 0.0
condition n/a
subroutine 6 7 85.7
pod 0 1 0.0
total 24 32 75.0


line stmt bran cond sub pod time code
1             package Astro::ADS::Paper;
2             $Astro::ADS::Paper::VERSION = '1.92';
3 4     4   207134 use Moo;
  4         9780  
  4         32  
4              
5 4     4   3410 use Carp;
  4         11  
  4         415  
6 4     4   586 use Data::Dumper::Concise;
  4         9398  
  4         328  
7 4     4   476 use Mojo::Base -strict; # do we want -signatures
  4         8245  
  4         80  
8 4     4   1509 use PerlX::Maybe;
  4         2244  
  4         38  
9 4     4   730 use Types::Standard qw( Int Str StrMatch ArrayRef HashRef Any ); # InstanceOf ConsumerOf
  4         109449  
  4         53  
10              
11             #declare "Bibcode",
12             # was StrMatch[ qr{^\d{4} [\w.&]{5} [\d.]{4} [ELP-Z\d.] [\d.]{4} [A-Z]$}x ];
13             # now StrMatch[ qr{^\d{4} [\w.&]{5} [\d.]{4} [AELP-Z\d.] [\d.]{3}[B\d] [A-Z]$}x ];
14             # YYYY JJJJJ VVVV M PPPP A (year journal volume type page author)
15             # 2006 nucl. ex.. . 1042 S
16             # 2005 astro .ph. 1 0346 T
17              
18             has [qw/id score/] => (
19             is => 'rw',
20             isa => Int->where( '$_ >= 0' ),
21             );
22             has bibcode => (
23             is => 'rw',
24             isa => StrMatch[ qr{^\d{4} # year
25             (?: [\w.&]{5} # ( journal
26             [\d.]{4} # volume )
27             | [a-z.]{9} ) # ( arxiv )
28             [AELP-Z\d.] # type
29             [\d.]{3}[B\d] # page
30             [A-Z] # author initial
31             $}x
32             ],
33             );
34             # astro-ph hep-ex|th|lat cond-mat gr-qc math-ph nlin physics quant-ph stat
35             # ph ex th lat mat qc ph
36             has title => (
37             is => 'rw',
38             isa => ArrayRef[],
39             );
40             has [qw/journal origin object/] => (
41             is => 'rw',
42             isa => Str,
43             );
44             has url => (
45             is => 'rw',
46             isa => Str, # Mojo::URL ?
47             );
48             has published => (
49             is => 'rw',
50             isa => Str, # qr/Month-Year/
51             );
52             has [qw/author aff keyword links_data/] => (
53             is => 'rw',
54             isa => ArrayRef[],
55             );
56             has abstract => (
57             is => 'rw',
58             isa => Any, # no idea what this is now
59             );
60              
61             sub summary {
62             # should this be a one line join or 3 line heredoc?
63 0     0 0   my $self = shift;
64              
65 0           return grep { defined }
66             $self->bibcode,
67             $self->score,
68             $self->title,
69 0 0         ($self->authors ? join('; ', @{$self->authors}) : undef),
  0            
70             $self->published;
71             }
72              
73             1;
74              
75             =pod
76              
77             =encoding UTF-8
78              
79             =head1 NAME
80              
81             Astro::ADS::Paper - A class for holding the document attributes for the results of a Search
82              
83             =head1 VERSION
84              
85             version 1.92
86              
87             =head1 SYNOPSIS
88              
89             my $result = $search->query();
90             say $_->title grep { $_->year > 2010 } for $result->get_papers();
91              
92             =head1 DESCRIPTION
93              
94             This class is used to contain the individual results from your searches.
95             Please note that it only contains the attributes fetched from the search,
96             not the whole ADS record for the paper.
97              
98             =head2 Notes
99              
100             In searches, the "=" sign turns off the synonym expansion feature
101             available with the author and title fields.
102              
103             =head2 Bibcodes
104              
105             This class has a regex for bibcodes!
106              
107             Coding that regex has shown that bibcodes fields are overloaded in ways not
108             documented. I did not know that 'A' is an acceptable bibcode field for publication
109             type, which maybe short for Abstract.
110              
111             arXiv papers don't have a Volume, so they overflow into that section
112              
113             =head2 Follow up queries
114              
115             Methods available in Astro::ADS v1 for fetching references and citations are
116             now accessed via the Links service (which will be on the development Roadmap).
117              
118             =head2 Allowed fields
119              
120             Allowed: abstract ┃ ack ┃ aff ┃ aff_id ┃ alternate_bibcode ┃ alternate_title ┃ arxiv_class ┃ author ┃ author_count ┃ author_norm ┃ bibcode ┃ bibgroup ┃ bibstem ┃ citation ┃ citation_count ┃ cite_read_boost ┃ classic_factor ┃ comment ┃ copyright ┃ data ┃ database ┃ date ┃ doctype ┃ doi ┃ eid ┃ entdate ┃ entry_date ┃ esources ┃ facility ┃ first_author ┃ first_author_norm ┃ grant ┃ grant_agencies ┃ grant_id ┃ id ┃ identifier ┃ indexstamp ┃ inst ┃ isbn ┃ issn ┃ issue ┃ keyword ┃ keyword_norm ┃ keyword_schema ┃ lang ┃ links_data ┃ nedid ┃ nedtype ┃ orcid_pub ┃ orcid_other ┃ orcid_user ┃ page ┃ page_count ┃ page_range ┃ property ┃ pub ┃ pub_raw ┃ pubdate ┃ pubnote ┃ read_count ┃ reference ┃ simbid ┃ title ┃ vizier ┃ volume ┃ year
121              
122             Given this list is 81 fields, it doesn't make sense to create that many empty attributes.
123              
124             The full list is at https://ui.adsabs.harvard.edu/help/search/comprehensive-solr-term-list
125              
126             =head1 TODO
127              
128             v1 had the following methods
129             * references
130             * citations
131             * alsoread
132             * tableofcontents
133              
134             all of which grepped $self->links for either REFERENCES, CITATIONS, AR or TOC
135              
136             These are returned in the links_data field, but we should be using the Links service to get this data
137              
138             =head1 COPYRIGHT AND LICENSE
139              
140             This software is Copyright (c) 2025 by Boyd Duffee.
141              
142             This is free software, licensed under:
143              
144             The MIT (X11) License
145              
146             =cut