arxivarius 0.10.0 → 0.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ae569c1030d082bb94e10a63472ef34aeb89bb9bef56db25c57f68254dc00be8
4
- data.tar.gz: f3f664f4a8feb5b7a585166187590018ae68f7e98cd5ae290a85259baab40222
3
+ metadata.gz: 7fb7f547ba6bce8ce3f0f8558dcab98ac276cdd24b9b7576551b2da85c0ca8c6
4
+ data.tar.gz: 2f8426e7c7c1f7889808bbd72117ad2af9cf416236c4cc93b6060ea7943be57b
5
5
  SHA512:
6
- metadata.gz: f218c5e45f1f1305ab9437a205f9c35db5494bc5491af3d6d19c560e025ba452990caff7fb709fcde5e07302fe73ad8ea9e2a6f043831873cdd076c2fd8a8ccf
7
- data.tar.gz: 95396dc42e302e54b4e6ae42475bd375ee77d8f49b04ee6383e57dfb0a8d144c2cc1c59cd135ea57c043fa1be8c9fc575c8cf09240dea03179e939097415ca7b
6
+ metadata.gz: 2cbe81bb238d7fe52fe449a36faf32e5b5b16d96a338b081accb8c924b5bfd972fb74cd2d06aeb8752d0788bab623976a4649c1fd5e82eb66fe62ecb04a0f979
7
+ data.tar.gz: 48ef9e189a64ab2cb93bdf201c97a8407d60862bc370739af3bd7fa4f298c914ea89e6cc751fdaddaea90492027c6d5dffafecc3317e97e4198744b5db78b7f6
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Arxivarius
4
- VERSION = '0.10.0'
4
+ VERSION = '0.11.0'
5
5
  end
data/lib/arxivarius.rb CHANGED
@@ -19,6 +19,7 @@ module Arxivarius
19
19
  module Error
20
20
  class PaperNotFound < StandardError; end
21
21
  class MalformedId < StandardError; end
22
+ class ApiError < StandardError; end
22
23
  end
23
24
 
24
25
  # ArXiv uses two ID formats:
@@ -38,8 +39,7 @@ module Arxivarius
38
39
 
39
40
  id = normalize_legacy_id(id)
40
41
 
41
- url = URI("https://export.arxiv.org/api/query?id_list=#{id}")
42
- response = ::Nokogiri::XML(Net::HTTP.get(url)).remove_namespaces!
42
+ response = ::Nokogiri::XML(fetch_xml(id)).remove_namespaces!
43
43
  paper = Arxivarius::Paper.parse(response.to_s, single: true)
44
44
 
45
45
  # Paper is nil when the API returns no <entry> for the given ID.
@@ -71,6 +71,18 @@ module Arxivarius
71
71
  identifier.match?(LEGACY_URL_FORMAT)
72
72
  end
73
73
 
74
+ def fetch_xml(id)
75
+ url = URI("https://export.arxiv.org/api/query?id_list=#{id}")
76
+ response = Net::HTTP.get_response(url)
77
+
78
+ unless response.is_a?(Net::HTTPSuccess)
79
+ message = "ArXiv API returned #{response.code}: #{response.body&.strip}"
80
+ raise Arxivarius::Error::ApiError, message
81
+ end
82
+
83
+ response.body
84
+ end
85
+
74
86
  # The arXiv API no longer resolves subcategory legacy IDs.
75
87
  # Strips the subcategory: math.DG/0510097 -> math/0510097.
76
88
  def normalize_legacy_id(id)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arxivarius
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - antlypls
@@ -73,7 +73,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
73
73
  - !ruby/object:Gem::Version
74
74
  version: '0'
75
75
  requirements: []
76
- rubygems_version: 4.0.6
76
+ rubygems_version: 4.0.8
77
77
  specification_version: 4
78
78
  summary: Fetch and parse papers metadata from arXiv
79
79
  test_files: []