Module: Arxivarius

Defined in:
lib/arxivarius.rb,
lib/arxivarius/link.rb,
lib/arxivarius/text.rb,
lib/arxivarius/paper.rb,
lib/arxivarius/author.rb,
lib/arxivarius/version.rb,
lib/arxivarius/category.rb,
lib/arxivarius/web_source.rb

Defined Under Namespace

Modules: Error, Text, WebSource Classes: Author, Category, Link, Paper

Constant Summary collapse

LEGACY_URL_FORMAT =

ArXiv uses two ID formats:

Legacy:  math/0510097v1   (pre-2007)
Current: 1202.0819v1      (2007+)
/[^\/]+\/\d+(?:v\d+)?$/
CURRENT_URL_FORMAT =
/\d{4,}\.\d{4,}(?:v\d+)?$/
LEGACY_ID_FORMAT =
/^#{LEGACY_URL_FORMAT}/
ID_FORMAT =
/^#{CURRENT_URL_FORMAT}/
VERSION =
'0.12.0'

Class Method Summary collapse

Class Method Details

.get(identifier, source: :api) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/arxivarius.rb', line 36

def get(identifier, source: :api)
  id = parse_arxiv_identifier(identifier)

  raise Arxivarius::Error::MalformedId, 'Paper ID format is invalid' unless valid_id?(id)

  id = normalize_legacy_id(id)

  paper = fetch_paper(id, source)

  # Paper is nil when the source returns no entry for the given ID.
  raise Arxivarius::Error::PaperNotFound, "Paper #{id} doesn't exist on arXiv" unless paper&.title

  paper
end