arxiv 0.1.10 → 0.2.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/.github/workflows/ci.yml +10 -3
- data/.ruby-version +1 -1
- data/lib/arxiv/models/manuscript.rb +5 -2
- data/lib/arxiv/version.rb +1 -1
- data/lib/arxiv.rb +13 -2
- data/spec/arxiv/arxiv_spec.rb +31 -0
- data/spec/arxiv/models/category_spec.rb +3 -2
- data/spec/arxiv/models/link_spec.rb +2 -2
- data/spec/arxiv/models/manuscript_spec.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- metadata +6 -6
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 36fafd1859dbcb78e4ce0c0c9e41cd8b184e40322a5c7652a6e2a3a382bf26ba
|
|
4
|
+
data.tar.gz: f815f06d993a7ca1c87869b60f686e5ab126f3c31d104dd48bd61a7ed27423c6
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4c01efe4cb1188ae415f4b652142b908fad23c9298866cfae4734675a9b6d2f62faa0cbb491cfb944cb8128bba8d57b101f092d46dbf7e81a66543af44c2730a
|
|
7
|
+
data.tar.gz: 666a53ac6831af22d291781f7762eb96961de82e4ead218ab1cfe0b80c833f69aba3e0da89efccc6210994953baf3507c7237d95ae8a9d04d9c4113adabfe972
|
data/.github/workflows/ci.yml
CHANGED
|
@@ -4,11 +4,14 @@ on:
|
|
|
4
4
|
jobs:
|
|
5
5
|
test:
|
|
6
6
|
runs-on: ubuntu-latest
|
|
7
|
+
strategy:
|
|
8
|
+
matrix:
|
|
9
|
+
ruby-version: ['3.0', '3.1', '3.2']
|
|
7
10
|
|
|
8
11
|
steps:
|
|
9
12
|
- uses: actions/checkout@v3
|
|
10
13
|
- name: Set up Ruby
|
|
11
|
-
uses: ruby/setup-ruby@
|
|
14
|
+
uses: ruby/setup-ruby@v1
|
|
12
15
|
- name: Install dependencies
|
|
13
16
|
run: bundle install
|
|
14
17
|
- name: Run tests
|
|
@@ -23,10 +26,14 @@ jobs:
|
|
|
23
26
|
steps:
|
|
24
27
|
- uses: actions/checkout@v3
|
|
25
28
|
- name: Set up Ruby
|
|
26
|
-
uses: ruby/setup-ruby@
|
|
29
|
+
uses: ruby/setup-ruby@v1
|
|
27
30
|
- name: Publish to GPR
|
|
28
31
|
run: |
|
|
29
|
-
|
|
32
|
+
mkdir -p $HOME/.gem
|
|
33
|
+
touch $HOME/.gem/credentials
|
|
34
|
+
chmod 0600 $HOME/.gem/credentials
|
|
35
|
+
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
|
36
|
+
curl -u $RUBYGEMS_USERNAME:$RUBYGEMS_PASSWORD https://rubygems.org/api/v1/api_key.yaml > $HOME/.gem/credentials; chmod 0600 $HOME/.gem/credentials
|
|
30
37
|
gem build arxiv.gemspec
|
|
31
38
|
gem push `ls | grep *.gem`
|
|
32
39
|
env:
|
data/.ruby-version
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
2.
|
|
1
|
+
3.2.2
|
|
@@ -44,6 +44,10 @@ module Arxiv
|
|
|
44
44
|
links.map(&:content_type).compact.delete_if { |t| t =~ /^\s*$/ }
|
|
45
45
|
end
|
|
46
46
|
|
|
47
|
+
def zip_url
|
|
48
|
+
StringScrubber.force_ssl_url("https://arxiv.org/src/#{arxiv_id}")
|
|
49
|
+
end
|
|
50
|
+
|
|
47
51
|
def available_in_pdf?
|
|
48
52
|
content_types.any? { |type| type == "application/pdf" }
|
|
49
53
|
end
|
|
@@ -51,8 +55,7 @@ module Arxiv
|
|
|
51
55
|
def pdf_url
|
|
52
56
|
if available_in_pdf?
|
|
53
57
|
url = links.find { |l| l.content_type == "application/pdf" }.url
|
|
54
|
-
|
|
55
|
-
"#{url}.pdf" unless url =~ /\.pdf$/
|
|
58
|
+
StringScrubber.force_ssl_url(url)
|
|
56
59
|
end
|
|
57
60
|
end
|
|
58
61
|
|
data/lib/arxiv/version.rb
CHANGED
data/lib/arxiv.rb
CHANGED
|
@@ -42,12 +42,12 @@ module Arxiv
|
|
|
42
42
|
response = ::Nokogiri::XML(URI.open(url)).remove_namespaces!
|
|
43
43
|
manuscript = Arxiv::Manuscript.parse(response.to_s, single: id)
|
|
44
44
|
|
|
45
|
-
raise Arxiv::Error::ManuscriptNotFound, "Manuscript #{id} doesn't exist on arXiv" if manuscript
|
|
45
|
+
raise Arxiv::Error::ManuscriptNotFound, "Manuscript #{id} doesn't exist on arXiv" if manuscript&.title.nil?
|
|
46
46
|
manuscript
|
|
47
47
|
end
|
|
48
48
|
|
|
49
49
|
def self.parse_arxiv_identifier(identifier)
|
|
50
|
-
if valid_id?(identifier)
|
|
50
|
+
id = if valid_id?(identifier)
|
|
51
51
|
identifier
|
|
52
52
|
elsif valid_url?(identifier)
|
|
53
53
|
format = legacy_url?(identifier) ? LEGACY_URL_FORMAT : CURRENT_URL_FORMAT
|
|
@@ -55,9 +55,20 @@ module Arxiv
|
|
|
55
55
|
else
|
|
56
56
|
identifier # probably an error
|
|
57
57
|
end
|
|
58
|
+
|
|
59
|
+
normalize_legacy_id(id)
|
|
58
60
|
end
|
|
59
61
|
private_class_method :parse_arxiv_identifier
|
|
60
62
|
|
|
63
|
+
# In April 2007, arxiv dropped the subject-class suffix from legacy identifiers
|
|
64
|
+
# (e.g. `math.DG/0510097` became `math/0510097`). The website still 301-redirects
|
|
65
|
+
# the old form, but the API at /api/query?id_list=math.DG/0510097 silently returns
|
|
66
|
+
# no results. Normalize so callers can pass either form.
|
|
67
|
+
def self.normalize_legacy_id(id)
|
|
68
|
+
id.sub(/\A([^.\/]+)\.[^\/]+\//, '\1/')
|
|
69
|
+
end
|
|
70
|
+
private_class_method :normalize_legacy_id
|
|
71
|
+
|
|
61
72
|
def self.valid_id?(identifier)
|
|
62
73
|
identifier =~ ID_FORMAT || identifier =~ LEGACY_ID_FORMAT
|
|
63
74
|
end
|
data/spec/arxiv/arxiv_spec.rb
CHANGED
|
@@ -51,4 +51,35 @@ module Arxiv
|
|
|
51
51
|
end
|
|
52
52
|
|
|
53
53
|
end
|
|
54
|
+
|
|
55
|
+
# NOTE: This describe block tests a private method (via `.send`) which is
|
|
56
|
+
# unusual for this codebase. It's here to make the regex's behavior visible
|
|
57
|
+
# at PR-review time across the various legacy ID forms arxiv has historically
|
|
58
|
+
# used. Feel free to drop this block — the behavior is also covered indirectly
|
|
59
|
+
# by the legacy-id specs above.
|
|
60
|
+
describe "normalize_legacy_id (private)" do
|
|
61
|
+
cases = {
|
|
62
|
+
# legacy with subject class -> stripped to bare archive
|
|
63
|
+
"math.DG/0510097" => "math/0510097",
|
|
64
|
+
"math.DG/0510097v1" => "math/0510097v1",
|
|
65
|
+
"cond-mat.dis-nn/9912001" => "cond-mat/9912001",
|
|
66
|
+
|
|
67
|
+
# already-canonical legacy -> unchanged
|
|
68
|
+
"math/0510097" => "math/0510097",
|
|
69
|
+
"math/0510097v1" => "math/0510097v1",
|
|
70
|
+
"cs/0002001" => "cs/0002001",
|
|
71
|
+
"cond-mat/9912001" => "cond-mat/9912001",
|
|
72
|
+
|
|
73
|
+
# current id format (no slash) -> unchanged
|
|
74
|
+
"1202.0819" => "1202.0819",
|
|
75
|
+
"1202.0819v1" => "1202.0819v1",
|
|
76
|
+
"1509.06369" => "1509.06369",
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
cases.each do |input, expected|
|
|
80
|
+
it "#{input.inspect} -> #{expected.inspect}" do
|
|
81
|
+
expect(Arxiv.send(:normalize_legacy_id, input)).to eql(expected)
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
54
85
|
end
|
|
@@ -4,7 +4,6 @@ module Arxiv
|
|
|
4
4
|
describe Category do
|
|
5
5
|
before(:all) do
|
|
6
6
|
@category = Arxiv.get('1202.0819').primary_category
|
|
7
|
-
@legacy_category = Arxiv.get('math.DG/0510097v1').categories.last
|
|
8
7
|
end
|
|
9
8
|
|
|
10
9
|
describe "abbreviation" do
|
|
@@ -25,7 +24,9 @@ module Arxiv
|
|
|
25
24
|
end
|
|
26
25
|
|
|
27
26
|
it "should return only the abbreviation when a description cannot be found (e.g. MSC classes)"do
|
|
28
|
-
|
|
27
|
+
category = Category.new
|
|
28
|
+
category.abbreviation = "58D15 (Primary); 58B10 (Secondary)"
|
|
29
|
+
expect(category.long_description).to eql("58D15 (Primary); 58B10 (Secondary)")
|
|
29
30
|
end
|
|
30
31
|
end
|
|
31
32
|
|
|
@@ -2,7 +2,7 @@ require 'spec_helper'
|
|
|
2
2
|
|
|
3
3
|
module Arxiv
|
|
4
4
|
describe Link do
|
|
5
|
-
before(:all) { @link = Arxiv.get('1202.0819').links.
|
|
5
|
+
before(:all) { @link = Arxiv.get('1202.0819').links.find { |l| l.content_type == 'application/pdf' } }
|
|
6
6
|
|
|
7
7
|
describe "content_type" do
|
|
8
8
|
it "should fetch the link's content type" do
|
|
@@ -12,7 +12,7 @@ module Arxiv
|
|
|
12
12
|
|
|
13
13
|
describe "url" do
|
|
14
14
|
it "should fetch the link's url" do
|
|
15
|
-
expect(@link.url).to eql('
|
|
15
|
+
expect(@link.url).to eql('https://arxiv.org/pdf/1202.0819v1')
|
|
16
16
|
end
|
|
17
17
|
end
|
|
18
18
|
|
|
@@ -93,7 +93,7 @@ module Arxiv
|
|
|
93
93
|
|
|
94
94
|
describe "pdf_url" do
|
|
95
95
|
it "should return the url to download the manuscript in PDF format" do
|
|
96
|
-
expect(@manuscript.pdf_url).to eql('https://arxiv.org/pdf/1202.0819v1
|
|
96
|
+
expect(@manuscript.pdf_url).to eql('https://arxiv.org/pdf/1202.0819v1')
|
|
97
97
|
end
|
|
98
98
|
end
|
|
99
99
|
|
data/spec/spec_helper.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: arxiv
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scholastica
|
|
8
|
-
autorequire:
|
|
8
|
+
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date:
|
|
11
|
+
date: 2026-05-13 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: happymapper
|
|
@@ -134,7 +134,7 @@ homepage: https://github.com/scholastica/arxiv
|
|
|
134
134
|
licenses:
|
|
135
135
|
- MIT
|
|
136
136
|
metadata: {}
|
|
137
|
-
post_install_message:
|
|
137
|
+
post_install_message:
|
|
138
138
|
rdoc_options: []
|
|
139
139
|
require_paths:
|
|
140
140
|
- lib
|
|
@@ -149,8 +149,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
149
149
|
- !ruby/object:Gem::Version
|
|
150
150
|
version: '0'
|
|
151
151
|
requirements: []
|
|
152
|
-
rubygems_version: 3.
|
|
153
|
-
signing_key:
|
|
152
|
+
rubygems_version: 3.4.10
|
|
153
|
+
signing_key:
|
|
154
154
|
specification_version: 4
|
|
155
155
|
summary: Ruby wrapper accessing the arXiv API
|
|
156
156
|
test_files: []
|