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 +4 -4
- data/lib/arxivarius/version.rb +1 -1
- data/lib/arxivarius.rb +14 -2
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7fb7f547ba6bce8ce3f0f8558dcab98ac276cdd24b9b7576551b2da85c0ca8c6
|
|
4
|
+
data.tar.gz: 2f8426e7c7c1f7889808bbd72117ad2af9cf416236c4cc93b6060ea7943be57b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 2cbe81bb238d7fe52fe449a36faf32e5b5b16d96a338b081accb8c924b5bfd972fb74cd2d06aeb8752d0788bab623976a4649c1fd5e82eb66fe62ecb04a0f979
|
|
7
|
+
data.tar.gz: 48ef9e189a64ab2cb93bdf201c97a8407d60862bc370739af3bd7fa4f298c914ea89e6cc751fdaddaea90492027c6d5dffafecc3317e97e4198744b5db78b7f6
|
data/lib/arxivarius/version.rb
CHANGED
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
|
-
|
|
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.
|
|
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.
|
|
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: []
|