arx 0.3.2 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +124 -0
- data/LICENSE +1 -1
- data/README.md +107 -27
- data/Rakefile +1 -1
- data/arx.gemspec +7 -5
- data/lib/arx.rb +19 -7
- data/lib/arx/categories.rb +30 -0
- data/lib/arx/cleaner.rb +46 -5
- data/lib/arx/entities/author.rb +40 -1
- data/lib/arx/entities/category.rb +38 -1
- data/lib/arx/entities/link.rb +1 -0
- data/lib/arx/entities/paper.rb +108 -20
- data/lib/arx/inspector.rb +2 -0
- data/lib/arx/query/query.rb +46 -36
- data/lib/arx/query/validate.rb +4 -1
- data/lib/arx/version.rb +3 -3
- metadata +51 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1dae69d65fb2846820e6c457a10c5249a210ddfb551bd9cf7311562b1071da08
|
4
|
+
data.tar.gz: d32adc9bf13a8e6d6cf0a1394d76f2a03b0406530f58b6a68604b66dda71a312
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f2af67fbe94f57dbfc5883dccd0bd74e023cfe400e4a8caecf95de0034646c3544e3f07b21787f0cd6fcc1eb7accb49328d60b8922a3b0d2cbacbc094106cbb
|
7
|
+
data.tar.gz: 3e73cc8f30205c8077c945221f719186fc4c1ee6945a8cc9d5e1d8221d8075083eebc79b74c698559c98355b0513a76888b8e1bef65b424ca5be2eb4d1d82561
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,127 @@
|
|
1
|
+
# 1.2.1
|
2
|
+
|
3
|
+
#### Major changes
|
4
|
+
|
5
|
+
- Add support for saving PDFs with `Paper#save` (see #81). ([#90](https://github.com/eonu/arx/pull/90))
|
6
|
+
- Change gem Ruby version specifier from `~> 2.5` to `>= 2.5`. ([#86](https://github.com/eonu/arx/pull/86))
|
7
|
+
|
8
|
+
#### Minor changes
|
9
|
+
|
10
|
+
- Remove arXiv logo from `README.md`. ([#87](https://github.com/eonu/arx/pull/87))
|
11
|
+
- Use `URI.open` instead of `Kernel.open` (see #82). ([#86](https://github.com/eonu/arx/pull/86))
|
12
|
+
- Add CI rubies `2.7` and `3.0` (see #84). ([#86](https://github.com/eonu/arx/pull/86))
|
13
|
+
- Remove unnecessary arXiv information from `README.md` (see #83). ([#86](https://github.com/eonu/arx/pull/86))
|
14
|
+
- Remove system gem update directive in `.travis.yml`. ([#78](https://github.com/eonu/arx/pull/78))
|
15
|
+
- Remove version specifier for `bundler` gem in `arx.gemspec`. ([#77](https://github.com/eonu/arx/pull/77))
|
16
|
+
- Update specs using paper `1710.02185` to account for revision and acceptance by journal (_congratulations!_). ([#76](https://github.com/eonu/arx/pull/76))
|
17
|
+
- Update email address in `LICENSE.md`. ([#73](https://github.com/eonu/arx/pull/73))
|
18
|
+
|
19
|
+
# 1.2.0
|
20
|
+
|
21
|
+
#### Major changes
|
22
|
+
|
23
|
+
- Adds serialization support through the following methods ([#63](https://github.com/eonu/arx/pull/63)):
|
24
|
+
- `to_h`: Serialize into a Ruby hash (with symbol keys). Accepts a boolean argument, representing whether or not to deep-serialize nested `Author` and `Category` objects (defaults to `false`).
|
25
|
+
- `as_json`: Serialize into a Ruby hash which is also a valid JSON hash.
|
26
|
+
- `to_json`: Serialize into a valid JSON string.
|
27
|
+
- Remove version filter from query ID list. ([#69](https://github.com/eonu/arx/pull/69))
|
28
|
+
> Previously, all of the following would return the latest paper, `1807.06918v2`:
|
29
|
+
> ```ruby
|
30
|
+
> Arx.get('1807.06918').version #=> 2
|
31
|
+
> Arx.get('1807.06918v1').version #=> 2
|
32
|
+
> Arx.get('1807.06918v2').version #=> 2
|
33
|
+
> ```
|
34
|
+
|
35
|
+
- Adds `ATTRIBUTES` constant for `Paper`, `Author` and `Category` entities, as a list of which attributes are available for the entity. ([#63](https://github.com/eonu/arx/pull/63))
|
36
|
+
- Remove key-word arguments from `Paper#id` and `Paper#url`. ([#70](https://github.com/eonu/arx/pull/70))
|
37
|
+
> Previously, `Paper#id` and `Paper#url` accepted a `version` key-word argument, which was a boolean variable indicating whether or not to include the version number in the ID or URL.
|
38
|
+
>
|
39
|
+
> This has now been changed to a regular argument, which still defaults to `false`.
|
40
|
+
> ```ruby
|
41
|
+
> paper = Arx.get('cond-mat/9609089')
|
42
|
+
>
|
43
|
+
> # Old (no longer works)
|
44
|
+
> paper.id(version: true)
|
45
|
+
> paper.url(version: true)
|
46
|
+
>
|
47
|
+
> # New
|
48
|
+
> paper.id(true) #=> "cond-mat/9609089v1"
|
49
|
+
> paper.url(true) #=> "http://arxiv.org/abs/cond-mat/9609089v1"
|
50
|
+
> ```
|
51
|
+
|
52
|
+
- Add equality operator (`==`) to entities. ([#68](https://github.com/eonu/arx/pull/68))
|
53
|
+
|
54
|
+
#### Minor changes
|
55
|
+
|
56
|
+
- Add more category mappings to `CATEGORIES`. ([#71](https://github.com/eonu/arx/pull/71))
|
57
|
+
- Add licensing information to `README.md` under the *Acknowledgements* section. ([#66](https://github.com/eonu/arx/pull/66))
|
58
|
+
- Add `yard` development dependency for documentation. ([#65](https://github.com/eonu/arx/pull/65))
|
59
|
+
- Make documentation spacing uniform. ([#64](https://github.com/eonu/arx/pull/64))
|
60
|
+
- Coveralls:
|
61
|
+
- `coveralls` [`= 0.8.22` to `= 0.8.23`] ([#62](https://github.com/eonu/arx/pull/62))
|
62
|
+
- `thor` [`~> 0.19.4` to `~> 0.20.3`] ([#67](https://github.com/eonu/arx/pull/67))
|
63
|
+
|
64
|
+
# 1.1.0
|
65
|
+
|
66
|
+
#### Major changes
|
67
|
+
|
68
|
+
- Change `bundler` requirement to `>= 1.17` in `arx.gemspec`. ([#53](https://github.com/eonu/arx/pull/53))
|
69
|
+
- Remove `Arx.find` alias of `Arx.search`. ([#57](https://github.com/eonu/arx/pull/57))
|
70
|
+
- Add `Query#group` for subquery grouping support. ([#59](https://github.com/eonu/arx/pull/59))
|
71
|
+
|
72
|
+
#### Minor changes
|
73
|
+
|
74
|
+
- Add contributing guidelines (`CONTRIBUTING.md`). ([#48](https://github.com/eonu/arx/pull/48))
|
75
|
+
- Add issue templates to `./github/ISSUE_TEMPLATE` for ([#49](https://github.com/eonu/arx/pull/49), [#54](https://github.com/eonu/arx/pull/54), [#55](https://github.com/eonu/arx/pull/55)):
|
76
|
+
- **Error or warning**<br>For reporting an error or warning generated by Arx.
|
77
|
+
- **Unexpected or incorrect functionality**<br>For reporting something that doesn't seem to be working correctly or is unexpected.
|
78
|
+
- **Improvement to an existing feature**<br>For suggesting an improvement to a feature already offered by Arx.
|
79
|
+
- **Suggesting a new feature**<br>For proposing a new feature to Arx that would be beneficial.
|
80
|
+
- Add a pull request template at `./github/PULL_REQUEST_TEMPLATE.md`. ([#49](https://github.com/eonu/arx/pull/49))
|
81
|
+
- Remove issue templates from `CONTRIBUTING.md`. ([#49](https://github.com/eonu/arx/pull/49))
|
82
|
+
- Remove `LICENSE` from YARD documentation (remove from `.yardopts`). ([#50](https://github.com/eonu/arx/pull/50))
|
83
|
+
- Add RVM ruby version `2.6` to `.travis.yml`. ([#53](https://github.com/eonu/arx/pull/53))
|
84
|
+
- Add contributor code-of-conduct (`CODE_OF_CONDUCT.md`). ([#56](https://github.com/eonu/arx/pull/56))
|
85
|
+
- Thank Scholastica in `README.md`. ([#58](https://github.com/eonu/arx/pull/58))
|
86
|
+
- Add `bin/console` for gem debugging. ([#60](https://github.com/eonu/arx/pull/60))
|
87
|
+
- Modify `gem:debug` rake task to run `bin/console`. ([#60](https://github.com/eonu/arx/pull/60))
|
88
|
+
|
89
|
+
# 1.0.1
|
90
|
+
|
91
|
+
#### Major changes
|
92
|
+
|
93
|
+
- Add cases to handle `nil` query returns. ([#45](https://github.com/eonu/arx/pull/45))
|
94
|
+
- Add support for the `coveralls` gem (`.coveralls.yml` configuration file). ([#42](https://github.com/eonu/arx/pull/42))
|
95
|
+
|
96
|
+
#### Minor changes
|
97
|
+
|
98
|
+
- Add code coverage badge to `README.md`. ([#42](https://github.com/eonu/arx/pull/42))
|
99
|
+
- Remove documentation badge from top of `README.md`. ([#42](https://github.com/eonu/arx/pull/42))
|
100
|
+
- Change author email from `ed@mail.eonu.net` to `ed@eonu.net`. ([#43](https://github.com/eonu/arx/pull/43))
|
101
|
+
- Change `ends_with_connective?` to `end_with_connective?` to follow typical Ruby patterns. ([#44](https://github.com/eonu/arx/pull/44))
|
102
|
+
- Add `/coverage/` directory to `.gitignore`. ([#45](https://github.com/eonu/arx/pull/45))
|
103
|
+
- Remove version numbers from paper identifiers in error message in `README.md`. ([#46](https://github.com/eonu/arx/pull/46))
|
104
|
+
|
105
|
+
# 1.0.0
|
106
|
+
|
107
|
+
#### Major changes
|
108
|
+
|
109
|
+
- Change `Query` connective instance methods ([#38](https://github.com/eonu/arx/pull/38)):
|
110
|
+
- `#&` -> `#and`
|
111
|
+
- `#|` -> `#or`
|
112
|
+
- `#!` -> `#and_not`
|
113
|
+
- Split version number from paper identifier in `Paper` (add `version` key-word argument to `#id` and `#url`, and add `#version`). ([#39](https://github.com/eonu/arx/pull/39))
|
114
|
+
- Add `Cleaner.extract_id` and `Cleaner.extract_version`. ([#39](https://github.com/eonu/arx/pull/39))
|
115
|
+
- Make `Query#add_connective` always return `self`. ([#40](https://github.com/eonu/arx/pull/40))
|
116
|
+
- Redefine `Arx.search` to user `Paper.parse`'s `search` key-word argument. ([#40](https://github.com/eonu/arx/pull/40))
|
117
|
+
- Implement all tests. ([#40](https://github.com/eonu/arx/pull/40))
|
118
|
+
|
119
|
+
#### Minor changes
|
120
|
+
|
121
|
+
- Change declared regular expression literals from `%r""` to standard `//`. ([#39](https://github.com/eonu/arx/pull/39))
|
122
|
+
- Remove `#extract_id` from `Query` and use `Cleaner.extract_id` instead. ([#39](https://github.com/eonu/arx/pull/39))
|
123
|
+
- Redefine `Paper#revision?` to use the new `#version` instead of `#updated_at` and`#published_at`. ([#39](https://github.com/eonu/arx/pull/39))
|
124
|
+
|
1
125
|
# 0.3.2
|
2
126
|
|
3
127
|
#### Major changes
|
data/LICENSE
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
MIT License
|
2
2
|
|
3
|
-
Copyright (c) 2019 Edwin Onuonga <ed@
|
3
|
+
Copyright (c) 2019 Edwin Onuonga <ed@eonu.net>
|
4
4
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
of this software and associated documentation files (the "Software"), to deal
|
data/README.md
CHANGED
@@ -1,48 +1,71 @@
|
|
1
1
|
# Arx
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
[![Ruby Version](https://img.shields.io/badge/ruby-~%3E%202.5-red.svg)](https://github.com/eonu/arx/blob/503a1c95ac450dbc20623491060c3fc32d213627/arx.gemspec#L19)
|
3
|
+
[![Ruby Version](https://img.shields.io/badge/ruby-%3E=%202.5-red.svg)](https://github.com/eonu/arx/blob/503a1c95ac450dbc20623491060c3fc32d213627/arx.gemspec#L19)
|
6
4
|
[![Gem](https://img.shields.io/gem/v/arx.svg)](https://rubygems.org/gems/arx)
|
7
5
|
[![License](https://img.shields.io/github/license/eonu/arx.svg)](https://github.com/eonu/arx/blob/master/LICENSE)
|
8
6
|
|
9
7
|
[![Maintainability](https://api.codeclimate.com/v1/badges/e94073dfa8c3e2442298/maintainability)](https://codeclimate.com/github/eonu/arx/maintainability)
|
10
|
-
[![Documentation](https://img.shields.io/badge/docs-rubydoc.info-blue.svg)](https://www.rubydoc.info/github/eonu/arx/master/toplevel)
|
11
8
|
[![Build Status](https://travis-ci.com/eonu/arx.svg?branch=master)](https://travis-ci.com/eonu/arx)
|
9
|
+
[![Coverage Status](https://coveralls.io/repos/github/eonu/arx/badge.svg?branch=feature%2Fcoveralls)](https://coveralls.io/github/eonu/arx?branch=feature%2Fcoveralls)
|
12
10
|
|
13
11
|
**A Ruby interface for querying academic papers on the arXiv search API.**
|
14
12
|
|
15
|
-
|
13
|
+
[arXiv](https://arxiv.org/) provides an advanced search utility on their website, as well as an extensive [search API](https://arxiv.org/help/api) that allows for the external querying of academic papers hosted on their website.
|
16
14
|
|
17
|
-
|
15
|
+
Although [Scholastica](https://github.com/scholastica) offer a great [Ruby gem](https://github.com/scholastica/arxiv) for retrieving papers from arXiv through the search API, this gem only allows for the retrieval of one paper at a time, and only supports searching for paper by ID.
|
18
16
|
|
19
|
-
|
17
|
+
> Arx is a gem that allows for quick and easy querying of the arXiv search API, without having to worry about manually writing your own search query strings or parsing the resulting XML query response to find the data you need.
|
18
|
+
|
19
|
+
## Examples
|
20
|
+
|
21
|
+
1. Suppose we wish to search for papers in the `cs.FL` (Formal Languages and Automata Theory) category whose title contains `"Buchi Automata"`, not authored by `Tomáš Babiak`, sorted by submission date (latest first).
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
require 'arx'
|
25
|
+
|
26
|
+
papers = Arx(sort_by: :date_submitted) do |query|
|
27
|
+
query.category('cs.FL')
|
28
|
+
query.title('Buchi Automata').and_not.author('Tomáš Babiak')
|
29
|
+
end
|
30
|
+
```
|
20
31
|
|
21
|
-
|
32
|
+
2. Suppose we wish to retrieve the main category of the paper with arXiv ID `1809.09415`, the name of the first author and the date it was published.
|
22
33
|
|
23
|
-
|
34
|
+
```ruby
|
35
|
+
require 'arx'
|
24
36
|
|
25
|
-
|
37
|
+
paper = Arx('1809.09415')
|
38
|
+
paper.authors.first.name
|
39
|
+
#=> "Christof Löding"
|
40
|
+
paper.categories.first.full_name # or paper.primary_category.full_name
|
41
|
+
#=> "Formal Languages and Automata Theory"
|
42
|
+
paper.published_at
|
43
|
+
#=> #<DateTime: 2018-09-25T11:40:39+00:00 ((2458387j,42039s,0n),+0s,2299161j)>
|
44
|
+
```
|
26
45
|
|
27
46
|
## Features
|
28
47
|
|
29
48
|
- Ruby classes `Arx::Paper`, `Arx::Author` and `Arx::Category` that wrap the resulting Atom XML query result from the search API.
|
30
49
|
- Supports querying by a paper's ID, title, author(s), abstract, subject category, comment, journal reference, or report number.
|
31
|
-
- Provides a small
|
50
|
+
- Provides a small DSL for writing queries.
|
32
51
|
- Supports searching fields by exact match.
|
33
52
|
|
34
53
|
## Installation
|
35
54
|
|
36
55
|
To install Arx, run the following in your terminal:
|
37
56
|
|
38
|
-
```
|
39
|
-
|
57
|
+
```console
|
58
|
+
gem install arx
|
40
59
|
```
|
41
60
|
|
42
61
|
## Documentation
|
43
62
|
|
44
63
|
The documentation for Arx is hosted on [![rubydoc.info](https://img.shields.io/badge/docs-rubydoc.info-blue.svg)](https://www.rubydoc.info/github/eonu/arx/master/toplevel).
|
45
64
|
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
All contributions to Arx are greatly appreciated. Contribution guidelines can be found [here](/CONTRIBUTING.md).
|
68
|
+
|
46
69
|
## Usage
|
47
70
|
|
48
71
|
Before you start using Arx, you'll have to ensure that the gem is required (either in your current working file, or shell such as [IRB](https://en.wikipedia.org/wiki/Interactive_Ruby_Shell)):
|
@@ -63,7 +86,7 @@ Obviously writing out queries like this can quickly become time-consuming and te
|
|
63
86
|
|
64
87
|
---
|
65
88
|
|
66
|
-
The `Arx::Query` class provides a small
|
89
|
+
The `Arx::Query` class provides a small DSL for writing these query strings.
|
67
90
|
|
68
91
|
#### Sorting criteria and order
|
69
92
|
|
@@ -178,16 +201,49 @@ q.author('Dominik Edelmann')
|
|
178
201
|
q.category('math.NA')
|
179
202
|
```
|
180
203
|
|
181
|
-
To change the logical connective used to chain subqueries, use the
|
204
|
+
To change the logical connective used to chain subqueries, use the `and`, `or`, `and_not` instance methods between the subquery calls:
|
182
205
|
|
183
206
|
```ruby
|
184
207
|
# Papers authored by "Eleonora Andreotti" in neither the "Numerical Analysis" (math.NA) or "Combinatorics (math.CO)" categories.
|
185
208
|
q = Arx::Query.new
|
186
209
|
q.author('Eleonora Andreotti')
|
187
|
-
q
|
210
|
+
q.and_not
|
188
211
|
q.category('math.NA', 'math.CO', connective: :or)
|
189
212
|
```
|
190
213
|
|
214
|
+
#### Grouping subqueries
|
215
|
+
|
216
|
+
Sometimes you'll have a query that requires nested or grouped logic, using parentheses. This can be done using the `Arx::Query#group` method.
|
217
|
+
|
218
|
+
This method accepts a block and basically parenthesises the result of whichever methods were called within the block.
|
219
|
+
|
220
|
+
For example, this will allow the last query from the previous section to be written as:
|
221
|
+
|
222
|
+
```ruby
|
223
|
+
# Papers authored by "Eleonora Andreotti" in neither the "Numerical Analysis" (math.NA) or "Combinatorics (math.CO)" categories.
|
224
|
+
q = Arx::Query.new
|
225
|
+
q.author('Eleonora Andreotti')
|
226
|
+
q.and_not
|
227
|
+
q.group do
|
228
|
+
q.category('math.NA').or.category('math.CO')
|
229
|
+
end
|
230
|
+
```
|
231
|
+
|
232
|
+
Another more complicated example with two grouped subqueries:
|
233
|
+
|
234
|
+
```ruby
|
235
|
+
# Papers whose title contains "Buchi Automata", either authored by "Tomáš Babiak", or in the "Formal Languages and Automata Theory (cs.FL)" category and not the "Computational Complexity (cs.CC)" category.
|
236
|
+
q = Arx::Query.new
|
237
|
+
q.title('Buchi Automata')
|
238
|
+
q.group do
|
239
|
+
q.author('Tomáš Babiak')
|
240
|
+
q.or
|
241
|
+
q.group do
|
242
|
+
q.category('cs.FL').and_not.category('cs.CC')
|
243
|
+
end
|
244
|
+
end
|
245
|
+
```
|
246
|
+
|
191
247
|
### Running search queries
|
192
248
|
|
193
249
|
Search queries can be executed with the `Arx()` method (alias of `Arx.search`). This method contains the same parameters as the `Arx::Query` initializer - including the list of IDs.
|
@@ -202,9 +258,7 @@ Calling the `Arx()` method with a block allows for the construction and executio
|
|
202
258
|
# Papers in the cs.FL category whose title contains "Buchi Automata", not authored by Tomáš Babiak
|
203
259
|
results = Arx(sort_by: :date_submitted) do |query|
|
204
260
|
query.category('cs.FL')
|
205
|
-
query.title('Buchi Automata')
|
206
|
-
query.!()
|
207
|
-
query.author('Tomáš Babiak')
|
261
|
+
query.title('Buchi Automata').and_not.author('Tomáš Babiak')
|
208
262
|
end
|
209
263
|
|
210
264
|
results.size #=> 18
|
@@ -220,9 +274,7 @@ The `Arx()` method accepts a predefined `Arx::Query` object through the `query`
|
|
220
274
|
# Papers in the cs.FL category whose title contains "Buchi Automata", not authored by Tomáš Babiak
|
221
275
|
q = Arx::Query.new(sort_by: :date_submitted)
|
222
276
|
q.category('cs.FL')
|
223
|
-
q.title('Buchi Automata')
|
224
|
-
q.!()
|
225
|
-
q.author('Tomáš Babiak')
|
277
|
+
q.title('Buchi Automata').and_not.author('Tomáš Babiak')
|
226
278
|
|
227
279
|
results = Arx(query: q)
|
228
280
|
results.size #=> 18
|
@@ -259,9 +311,18 @@ paper = Arx('1809.09415')
|
|
259
311
|
#=> #<Arx::Paper:0x00007fb657b59bd0>
|
260
312
|
|
261
313
|
paper.id
|
314
|
+
#=> "1809.09415"
|
315
|
+
paper.id(true)
|
262
316
|
#=> "1809.09415v1"
|
263
317
|
paper.url
|
318
|
+
#=> "http://arxiv.org/abs/1809.09415"
|
319
|
+
paper.url(true)
|
264
320
|
#=> "http://arxiv.org/abs/1809.09415v1"
|
321
|
+
paper.version
|
322
|
+
#=> 1
|
323
|
+
paper.revision?
|
324
|
+
#=> false
|
325
|
+
|
265
326
|
paper.title
|
266
327
|
#=> "On finitely ambiguous Büchi automata"
|
267
328
|
paper.summary
|
@@ -280,20 +341,18 @@ paper.published_at
|
|
280
341
|
#=> #<DateTime: 2018-09-25T11:40:39+00:00 ((2458387j,42039s,0n),+0s,2299161j)>
|
281
342
|
paper.updated_at
|
282
343
|
#=> #<DateTime: 2018-09-25T11:40:39+00:00 ((2458387j,42039s,0n),+0s,2299161j)>
|
283
|
-
paper.revision?
|
284
|
-
#=> false
|
285
344
|
|
286
345
|
# Paper's comment
|
287
346
|
paper.comment?
|
288
347
|
#=> false
|
289
348
|
paper.comment
|
290
|
-
#=> Arx::Error::MissingField (arXiv paper 1809.
|
349
|
+
#=> Arx::Error::MissingField (arXiv paper 1809.09415 is missing the `comment` metadata field)
|
291
350
|
|
292
351
|
# Paper's journal reference
|
293
352
|
paper.journal?
|
294
353
|
#=> false
|
295
354
|
paper.journal
|
296
|
-
#=> Arx::Error::MissingField (arXiv paper 1809.
|
355
|
+
#=> Arx::Error::MissingField (arXiv paper 1809.09415 is missing the `journal` metadata field)
|
297
356
|
|
298
357
|
# Paper's PDF URL
|
299
358
|
paper.pdf?
|
@@ -339,4 +398,25 @@ category.name
|
|
339
398
|
#=> "cond-mat"
|
340
399
|
category.full_name
|
341
400
|
#=> "Condensed Matter"
|
342
|
-
```
|
401
|
+
```
|
402
|
+
|
403
|
+
# Acknowledgements
|
404
|
+
|
405
|
+
A large portion of this library is based on the brilliant work done by [Scholastica](https://github.com/scholastica) in their [`arxiv`](https://github.com/scholastica/arxiv) gem for retrieving individual papers from arXiv through the search API.
|
406
|
+
|
407
|
+
Arx was created mostly due to the seemingly inactive nature of Scholastica's repository. Additionally, it would have been infeasible to contribute such large changes to an already well-established gem, especially since https://scholasticahq.com/ appears to be dependent upon this gem.
|
408
|
+
|
409
|
+
Nevertheless, a special thanks goes out to Scholastica for providing the influence for Arx.
|
410
|
+
|
411
|
+
---
|
412
|
+
|
413
|
+
<p align="center">
|
414
|
+
<b>Arx</b> © 2019-2020, Edwin Onuonga - Released under the <a href="http://mit-license.org/">MIT</a> License.<br/>
|
415
|
+
<em>Authored and maintained by Edwin Onuonga.</em>
|
416
|
+
|
417
|
+
<p align="center">
|
418
|
+
<a href="https://eonu.net">eonu.net</a> ·
|
419
|
+
GitHub: <a href="https://github.com/eonu">@eonu</a> ·
|
420
|
+
Email: <a href="mailto:ed@eonu.net">ed@eonu.net</a>
|
421
|
+
</p>
|
422
|
+
</p>
|
data/Rakefile
CHANGED
data/arx.gemspec
CHANGED
@@ -6,7 +6,7 @@ Gem::Specification.new do |spec|
|
|
6
6
|
spec.name = 'arx'
|
7
7
|
spec.version = Arx::VERSION
|
8
8
|
spec.authors = ['Edwin Onuonga']
|
9
|
-
spec.email = ['ed@
|
9
|
+
spec.email = ['ed@eonu.net']
|
10
10
|
spec.homepage = 'https://github.com/eonu/arx'
|
11
11
|
|
12
12
|
spec.summary = %q{A Ruby interface for querying academic papers on the arXiv search API.}
|
@@ -16,15 +16,17 @@ Gem::Specification.new do |spec|
|
|
16
16
|
Gemfile LICENSE CHANGELOG.md README.md Rakefile arx.gemspec
|
17
17
|
]
|
18
18
|
|
19
|
-
spec.required_ruby_version = '
|
19
|
+
spec.required_ruby_version = '>= 2.5'
|
20
20
|
|
21
21
|
spec.add_runtime_dependency 'nokogiri', '~> 1.10'
|
22
22
|
spec.add_runtime_dependency 'nokogiri-happymapper', '~> 0.8'
|
23
23
|
|
24
|
-
spec.add_development_dependency 'bundler'
|
25
|
-
spec.add_development_dependency 'rake', '~>
|
26
|
-
spec.add_development_dependency 'thor', '~> 0.20'
|
24
|
+
spec.add_development_dependency 'bundler'
|
25
|
+
spec.add_development_dependency 'rake', '~> 13.0'
|
26
|
+
spec.add_development_dependency 'thor', '~> 0.20.3'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
28
|
+
spec.add_development_dependency 'coveralls', '0.8.23'
|
29
|
+
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.10'
|
28
30
|
|
29
31
|
spec.metadata = {
|
30
32
|
'source_code_uri' => spec.homepage,
|
data/lib/arx.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'cgi'
|
4
|
+
require 'json'
|
4
5
|
require 'nokogiri'
|
5
6
|
require 'open-uri'
|
6
7
|
require 'happymapper'
|
@@ -32,7 +33,7 @@ module Arx
|
|
32
33
|
# 1705.01662v1
|
33
34
|
# 1412.0135
|
34
35
|
# 0706.0001v2
|
35
|
-
NEW_IDENTIFIER_FORMAT =
|
36
|
+
NEW_IDENTIFIER_FORMAT = /^\d{4}\.\d{4,5}(v\d+)?$/
|
36
37
|
|
37
38
|
# The legacy arXiv paper identifier scheme (before 1 April 2007).
|
38
39
|
#
|
@@ -40,7 +41,7 @@ module Arx
|
|
40
41
|
# @example
|
41
42
|
# math/0309136v1
|
42
43
|
# cond-mat/0211034
|
43
|
-
OLD_IDENTIFIER_FORMAT =
|
44
|
+
OLD_IDENTIFIER_FORMAT = /^[a-z]+(\-[a-z]+)?\/\d{7}(v\d+)?$/
|
44
45
|
|
45
46
|
class << self
|
46
47
|
|
@@ -58,13 +59,24 @@ module Arx
|
|
58
59
|
|
59
60
|
yield query if block_given?
|
60
61
|
|
61
|
-
document = Nokogiri::XML(open ENDPOINT + query.to_s + '&max_results=10000').remove_namespaces!
|
62
|
-
results = Paper.parse(document, single:
|
63
|
-
|
64
|
-
|
62
|
+
document = Nokogiri::XML(URI.open ENDPOINT + query.to_s + '&max_results=10000').remove_namespaces!
|
63
|
+
results = Paper.parse(document, single: ids.size == 1)
|
64
|
+
|
65
|
+
if results.is_a? Paper
|
66
|
+
raise Error::MissingPaper.new(ids.first) if results.title.empty?
|
67
|
+
elsif results.is_a? Array
|
68
|
+
results.reject! {|paper| paper.title.empty?}
|
69
|
+
elsif results.nil?
|
70
|
+
if ids.size == 1
|
71
|
+
raise Error::MissingPaper.new(ids.first)
|
72
|
+
else
|
73
|
+
results = []
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
results
|
65
78
|
end
|
66
79
|
|
67
|
-
alias_method :find, :search
|
68
80
|
alias_method :get, :search
|
69
81
|
end
|
70
82
|
end
|