arx 1.0.0 → 1.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +138 -17
- data/LICENSE +1 -1
- data/README.md +153 -45
- data/Rakefile +1 -1
- data/arx.gemspec +7 -5
- data/lib/arx.rb +29 -7
- data/lib/arx/categories.rb +30 -0
- data/lib/arx/cleaner.rb +2 -0
- data/lib/arx/entities/author.rb +48 -1
- data/lib/arx/entities/category.rb +46 -1
- data/lib/arx/entities/link.rb +1 -0
- data/lib/arx/entities/paper.rb +104 -13
- data/lib/arx/inspector.rb +2 -0
- data/lib/arx/query/query.rb +76 -18
- data/lib/arx/query/validate.rb +13 -0
- data/lib/arx/version.rb +1 -1
- 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: 6530eb98d35658cacb54768f8a310e1c8f0ca7ecaf20fd816624e25ef69bd92a
|
4
|
+
data.tar.gz: 0e62e301e3c5eee07403f99c9b0cd0503716afc59b45b1a92404286ccbf58ce5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d287f54c864acb1e03e9993e76f5b726ac1e3a382b3543b13f3bff8fb762464018d289c7645fbf2ac7047670f232e0e5580addcb06bf9fa5dbc92ec75e21872d
|
7
|
+
data.tar.gz: 8b4909da8e6fa1966b7acc78cef78164da9efda370cff81fbbbd90a49f525d496dd1a0a598b085c61fd4158aa077ba341106d35e937c748fc90c0f081d2b9766
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,127 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
1
|
+
## 1.3.0
|
2
|
+
|
3
|
+
### Major changes
|
4
|
+
|
5
|
+
- Add support for paging. ([#92](https://github.com/eonu/arx/pull/92) by @xuanxu)
|
6
|
+
- Allow searching by `last_updated_date`. ([#93](https://github.com/eonu/arx/pull/93) by @xuanxu)
|
7
|
+
- Add `submitted_at` for submission date querying. ([#97](https://github.com/eonu/arx/pull/97))<br/>
|
8
|
+
This also changes `last_updated_date` from #93 to `updated_at`, and similarly for the `last_updated` and `date_submitted` [sort-by criteria](https://github.com/eonu/arx/blob/3d093658579fb2d99b92f0feedb2aa790a22e2c8/lib/arx/query/query.rb#L43).
|
9
|
+
|
10
|
+
### Minor changes
|
11
|
+
|
12
|
+
- Update `Arx()` to match new `Arx.search` signature (from #92). ([#94](https://github.com/eonu/arx/pull/94))
|
13
|
+
- Change incorrect `lastUpdated` sort-by criterion to `lastUpdatedDate`. ([#96](https://github.com/eonu/arx/pull/96))
|
14
|
+
- Add `to_s` methods for `Arx::Paper`, `Arx::Author` and `Arx::Category`. ([#99](https://github.com/eonu/arx/pull/99))
|
15
|
+
- Add fix for JSON warning in Ruby >=2.7. ([#101](https://github.com/eonu/arx/pull/101))
|
16
|
+
- Add contributors section to `README.md`. ([#102](https://github.com/eonu/arx/pull/102))
|
17
|
+
|
18
|
+
## 1.2.1
|
19
|
+
|
20
|
+
### Major changes
|
21
|
+
|
22
|
+
- Add support for saving PDFs with `Paper#save` (see #81). ([#90](https://github.com/eonu/arx/pull/90))
|
23
|
+
- Change gem Ruby version specifier from `~> 2.5` to `>= 2.5`. ([#86](https://github.com/eonu/arx/pull/86))
|
24
|
+
|
25
|
+
### Minor changes
|
26
|
+
|
27
|
+
- Remove arXiv logo from `README.md`. ([#87](https://github.com/eonu/arx/pull/87))
|
28
|
+
- Use `URI.open` instead of `Kernel.open` (see #82). ([#86](https://github.com/eonu/arx/pull/86))
|
29
|
+
- Add CI rubies `2.7` and `3.0` (see #84). ([#86](https://github.com/eonu/arx/pull/86))
|
30
|
+
- Remove unnecessary arXiv information from `README.md` (see #83). ([#86](https://github.com/eonu/arx/pull/86))
|
31
|
+
- Remove system gem update directive in `.travis.yml`. ([#78](https://github.com/eonu/arx/pull/78))
|
32
|
+
- Remove version specifier for `bundler` gem in `arx.gemspec`. ([#77](https://github.com/eonu/arx/pull/77))
|
33
|
+
- Update specs using paper `1710.02185` to account for revision and acceptance by journal (_congratulations!_). ([#76](https://github.com/eonu/arx/pull/76))
|
34
|
+
- Update email address in `LICENSE.md`. ([#73](https://github.com/eonu/arx/pull/73))
|
35
|
+
|
36
|
+
## 1.2.0
|
37
|
+
|
38
|
+
### Major changes
|
39
|
+
|
40
|
+
- Adds serialization support through the following methods ([#63](https://github.com/eonu/arx/pull/63)):
|
41
|
+
- `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`).
|
42
|
+
- `as_json`: Serialize into a Ruby hash which is also a valid JSON hash.
|
43
|
+
- `to_json`: Serialize into a valid JSON string.
|
44
|
+
- Remove version filter from query ID list. ([#69](https://github.com/eonu/arx/pull/69))
|
45
|
+
> Previously, all of the following would return the latest paper, `1807.06918v2`:
|
46
|
+
> ```ruby
|
47
|
+
> Arx.get('1807.06918').version #=> 2
|
48
|
+
> Arx.get('1807.06918v1').version #=> 2
|
49
|
+
> Arx.get('1807.06918v2').version #=> 2
|
50
|
+
> ```
|
51
|
+
|
52
|
+
- 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))
|
53
|
+
- Remove key-word arguments from `Paper#id` and `Paper#url`. ([#70](https://github.com/eonu/arx/pull/70))
|
54
|
+
> 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.
|
55
|
+
>
|
56
|
+
> This has now been changed to a regular argument, which still defaults to `false`.
|
57
|
+
> ```ruby
|
58
|
+
> paper = Arx.get('cond-mat/9609089')
|
59
|
+
>
|
60
|
+
> # Old (no longer works)
|
61
|
+
> paper.id(version: true)
|
62
|
+
> paper.url(version: true)
|
63
|
+
>
|
64
|
+
> # New
|
65
|
+
> paper.id(true) #=> "cond-mat/9609089v1"
|
66
|
+
> paper.url(true) #=> "http://arxiv.org/abs/cond-mat/9609089v1"
|
67
|
+
> ```
|
68
|
+
|
69
|
+
- Add equality operator (`==`) to entities. ([#68](https://github.com/eonu/arx/pull/68))
|
70
|
+
|
71
|
+
### Minor changes
|
72
|
+
|
73
|
+
- Add more category mappings to `CATEGORIES`. ([#71](https://github.com/eonu/arx/pull/71))
|
74
|
+
- Add licensing information to `README.md` under the *Acknowledgements* section. ([#66](https://github.com/eonu/arx/pull/66))
|
75
|
+
- Add `yard` development dependency for documentation. ([#65](https://github.com/eonu/arx/pull/65))
|
76
|
+
- Make documentation spacing uniform. ([#64](https://github.com/eonu/arx/pull/64))
|
77
|
+
- Coveralls:
|
78
|
+
- `coveralls` [`= 0.8.22` to `= 0.8.23`] ([#62](https://github.com/eonu/arx/pull/62))
|
79
|
+
- `thor` [`~> 0.19.4` to `~> 0.20.3`] ([#67](https://github.com/eonu/arx/pull/67))
|
80
|
+
|
81
|
+
## 1.1.0
|
82
|
+
|
83
|
+
### Major changes
|
84
|
+
|
85
|
+
- Change `bundler` requirement to `>= 1.17` in `arx.gemspec`. ([#53](https://github.com/eonu/arx/pull/53))
|
86
|
+
- Remove `Arx.find` alias of `Arx.search`. ([#57](https://github.com/eonu/arx/pull/57))
|
87
|
+
- Add `Query#group` for subquery grouping support. ([#59](https://github.com/eonu/arx/pull/59))
|
88
|
+
|
89
|
+
### Minor changes
|
90
|
+
|
91
|
+
- Add contributing guidelines (`CONTRIBUTING.md`). ([#48](https://github.com/eonu/arx/pull/48))
|
92
|
+
- 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)):
|
93
|
+
- **Error or warning**<br>For reporting an error or warning generated by Arx.
|
94
|
+
- **Unexpected or incorrect functionality**<br>For reporting something that doesn't seem to be working correctly or is unexpected.
|
95
|
+
- **Improvement to an existing feature**<br>For suggesting an improvement to a feature already offered by Arx.
|
96
|
+
- **Suggesting a new feature**<br>For proposing a new feature to Arx that would be beneficial.
|
97
|
+
- Add a pull request template at `./github/PULL_REQUEST_TEMPLATE.md`. ([#49](https://github.com/eonu/arx/pull/49))
|
98
|
+
- Remove issue templates from `CONTRIBUTING.md`. ([#49](https://github.com/eonu/arx/pull/49))
|
99
|
+
- Remove `LICENSE` from YARD documentation (remove from `.yardopts`). ([#50](https://github.com/eonu/arx/pull/50))
|
100
|
+
- Add RVM ruby version `2.6` to `.travis.yml`. ([#53](https://github.com/eonu/arx/pull/53))
|
101
|
+
- Add contributor code-of-conduct (`CODE_OF_CONDUCT.md`). ([#56](https://github.com/eonu/arx/pull/56))
|
102
|
+
- Thank Scholastica in `README.md`. ([#58](https://github.com/eonu/arx/pull/58))
|
103
|
+
- Add `bin/console` for gem debugging. ([#60](https://github.com/eonu/arx/pull/60))
|
104
|
+
- Modify `gem:debug` rake task to run `bin/console`. ([#60](https://github.com/eonu/arx/pull/60))
|
105
|
+
|
106
|
+
## 1.0.1
|
107
|
+
|
108
|
+
### Major changes
|
109
|
+
|
110
|
+
- Add cases to handle `nil` query returns. ([#45](https://github.com/eonu/arx/pull/45))
|
111
|
+
- Add support for the `coveralls` gem (`.coveralls.yml` configuration file). ([#42](https://github.com/eonu/arx/pull/42))
|
112
|
+
|
113
|
+
### Minor changes
|
114
|
+
|
115
|
+
- Add code coverage badge to `README.md`. ([#42](https://github.com/eonu/arx/pull/42))
|
116
|
+
- Remove documentation badge from top of `README.md`. ([#42](https://github.com/eonu/arx/pull/42))
|
117
|
+
- Change author email from `ed@mail.eonu.net` to `ed@eonu.net`. ([#43](https://github.com/eonu/arx/pull/43))
|
118
|
+
- Change `ends_with_connective?` to `end_with_connective?` to follow typical Ruby patterns. ([#44](https://github.com/eonu/arx/pull/44))
|
119
|
+
- Add `/coverage/` directory to `.gitignore`. ([#45](https://github.com/eonu/arx/pull/45))
|
120
|
+
- Remove version numbers from paper identifiers in error message in `README.md`. ([#46](https://github.com/eonu/arx/pull/46))
|
121
|
+
|
122
|
+
## 1.0.0
|
123
|
+
|
124
|
+
### Major changes
|
4
125
|
|
5
126
|
- Change `Query` connective instance methods ([#38](https://github.com/eonu/arx/pull/38)):
|
6
127
|
- `#&` -> `#and`
|
@@ -12,15 +133,15 @@
|
|
12
133
|
- Redefine `Arx.search` to user `Paper.parse`'s `search` key-word argument. ([#40](https://github.com/eonu/arx/pull/40))
|
13
134
|
- Implement all tests. ([#40](https://github.com/eonu/arx/pull/40))
|
14
135
|
|
15
|
-
|
136
|
+
### Minor changes
|
16
137
|
|
17
138
|
- Change declared regular expression literals from `%r""` to standard `//`. ([#39](https://github.com/eonu/arx/pull/39))
|
18
139
|
- Remove `#extract_id` from `Query` and use `Cleaner.extract_id` instead. ([#39](https://github.com/eonu/arx/pull/39))
|
19
140
|
- Redefine `Paper#revision?` to use the new `#version` instead of `#updated_at` and`#published_at`. ([#39](https://github.com/eonu/arx/pull/39))
|
20
141
|
|
21
|
-
|
142
|
+
## 0.3.2
|
22
143
|
|
23
|
-
|
144
|
+
### Major changes
|
24
145
|
|
25
146
|
- Add `Paper#category` alias for `Paper#primary_category`. ([#34](https://github.com/eonu/arx/pull/34))
|
26
147
|
- Change `Author#affiliations?` to `Author#affiliated?`. ([#34](https://github.com/eonu/arx/pull/34))
|
@@ -31,47 +152,47 @@
|
|
31
152
|
- Add `gem:release` rake task for preparing gem releases. ([#36](https://github.com/eonu/arx/pull/36))
|
32
153
|
- Add `thor` gem development dependency. ([#36](https://github.com/eonu/arx/pull/36))
|
33
154
|
|
34
|
-
|
155
|
+
### Minor changes
|
35
156
|
|
36
157
|
- Update documentation links to `rubydoc.info`'s GitHub service. ([#30](https://github.com/eonu/arx/pull/30))
|
37
158
|
- Add email address to `LICENSE`. ([#31](https://github.com/eonu/arx/pull/31))
|
38
159
|
- Improve `Error::MissingField` and `Error::MissingLink` error messages. ([#35](https://github.com/eonu/arx/pull/35))
|
39
160
|
|
40
|
-
|
161
|
+
## 0.3.1
|
41
162
|
|
42
|
-
|
163
|
+
### Major changes
|
43
164
|
|
44
165
|
- Add `.yardopts` for document generation configuration. ([#26](https://github.com/eonu/arx/pull/26))
|
45
166
|
- Namespace errors in `Arx::Error` module and remove `Error` prefix from error classes. ([#26](https://github.com/eonu/arx/pull/26))
|
46
167
|
- Move identifier format regular expression constant definitions from `Arx::Validate` to top-level namespace `Arx`. ([#26](https://github.com/eonu/arx/pull/26))
|
47
168
|
|
48
|
-
|
169
|
+
### Minor changes
|
49
170
|
|
50
171
|
- Rename `lib/arx/exceptions.rb` to `lib/arx/errors.rb`. ([#26](https://github.com/eonu/arx/pull/26))
|
51
172
|
- Make `Arx::Cleaner`, `Arx::Validate`, `Arx::Inspector`, `Arx::Link` private (hidden from `yard` documentation). ([#26](https://github.com/eonu/arx/pull/26))
|
52
173
|
|
53
|
-
|
174
|
+
## 0.3.0
|
54
175
|
|
55
|
-
|
176
|
+
### Major changes
|
56
177
|
|
57
178
|
- Add documentation, images, installation and usage instructions to `README.md`. ([#22](https://github.com/eonu/arx/pull/22), [#17](https://github.com/eonu/arx/pull/17))
|
58
179
|
- Allow prior construction of a search query in `Arx.search`. ([#18](https://github.com/eonu/arx/pull/18))
|
59
180
|
- Fix `Arx.search` query object yielding. ([#20](https://github.com/eonu/arx/pull/20))
|
60
181
|
|
61
|
-
|
182
|
+
### Minor changes
|
62
183
|
|
63
184
|
- Remove conditional with `block_given?` in `Arx()` method. ([#16](https://github.com/eonu/arx/pull/16))
|
64
185
|
- Remove leading ampersand (&) from search query string. ([#19](https://github.com/eonu/arx/pull/19))
|
65
186
|
- Add base paper categories and more aliases. ([#21](https://github.com/eonu/arx/pull/21))
|
66
187
|
|
67
|
-
|
188
|
+
## 0.2.0
|
68
189
|
|
69
|
-
|
190
|
+
### Major changes
|
70
191
|
|
71
192
|
- Flatten provided values in `Arx::Paper`'s field instance methods (allow an array as the `values` splat parameter). ([#5](https://github.com/eonu/arx/pull/5))
|
72
193
|
- Add `Arx.find` and `Arx.get` as aliases for `Arx.search`. ([#6](https://github.com/eonu/arx/pull/6), [#8](https://github.com/eonu/arx/pull/8))
|
73
194
|
|
74
|
-
|
195
|
+
### Minor changes
|
75
196
|
|
76
197
|
- Add `homepage` and `metadata` fields to `arx.gemspec`. ([#1](https://github.com/eonu/arx/pull/1), [#14](https://github.com/eonu/arx/pull/14))
|
77
198
|
- Specify required ruby version (`~> 2.5`) in `arx.gemspec`. ([#2](https://github.com/eonu/arx/pull/2))
|
@@ -82,6 +203,6 @@
|
|
82
203
|
- Add ruby-head version to RVM rubies in `.travis.yml`. ([#12](https://github.com/eonu/arx/pull/12))
|
83
204
|
- Remove unnecessary git-ignored files. ([#13](https://github.com/eonu/arx/pull/13), [#10](https://github.com/eonu/arx/pull/10))
|
84
205
|
|
85
|
-
|
206
|
+
## 0.1.0
|
86
207
|
|
87
208
|
Initial commit! 🎉
|
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,65 +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
|
-
|
16
|
-
|
17
|
-
> arXiv is an e-print service in the fields of physics, mathematics, non-linear science, computer science, quantitative biology, quantitative finance and statistics.
|
18
|
-
|
19
|
-
---
|
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.
|
20
14
|
|
21
|
-
[
|
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.
|
22
16
|
|
23
|
-
|
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.
|
24
18
|
|
25
|
-
|
19
|
+
## Examples
|
26
20
|
|
27
|
-
|
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).
|
28
22
|
|
29
|
-
|
23
|
+
```ruby
|
24
|
+
require 'arx'
|
30
25
|
|
31
|
-
|
26
|
+
papers = Arx(sort_by: :submitted_at) do |query|
|
27
|
+
query.category('cs.FL')
|
28
|
+
query.title('Buchi Automata').and_not.author('Tomáš Babiak')
|
29
|
+
end
|
30
|
+
```
|
32
31
|
|
33
|
-
|
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.
|
34
33
|
|
35
|
-
```ruby
|
36
|
-
require 'arx'
|
34
|
+
```ruby
|
35
|
+
require 'arx'
|
37
36
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
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
|
+
```
|
43
45
|
|
44
46
|
## Features
|
45
47
|
|
46
48
|
- Ruby classes `Arx::Paper`, `Arx::Author` and `Arx::Category` that wrap the resulting Atom XML query result from the search API.
|
47
|
-
- Supports querying by a paper's ID, title, author(s), abstract, subject category, comment, journal reference, or
|
48
|
-
- Provides a small
|
49
|
+
- Supports querying by a paper's ID, title, author(s), abstract, subject category, comment, journal reference, report number or last updated date.
|
50
|
+
- Provides a small DSL for writing queries.
|
49
51
|
- Supports searching fields by exact match.
|
50
52
|
|
51
53
|
## Installation
|
52
54
|
|
53
55
|
To install Arx, run the following in your terminal:
|
54
56
|
|
55
|
-
```
|
56
|
-
|
57
|
+
```console
|
58
|
+
gem install arx
|
57
59
|
```
|
58
60
|
|
59
61
|
## Documentation
|
60
62
|
|
61
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).
|
62
64
|
|
65
|
+
## Contributing
|
66
|
+
|
67
|
+
All contributions to Arx are greatly appreciated. Contribution guidelines can be found [here](/CONTRIBUTING.md).
|
68
|
+
|
63
69
|
## Usage
|
64
70
|
|
65
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)):
|
@@ -80,19 +86,19 @@ Obviously writing out queries like this can quickly become time-consuming and te
|
|
80
86
|
|
81
87
|
---
|
82
88
|
|
83
|
-
The `Arx::Query` class provides a small
|
89
|
+
The `Arx::Query` class provides a small DSL for writing these query strings.
|
84
90
|
|
85
91
|
#### Sorting criteria and order
|
86
92
|
|
87
93
|
The order in which search results are returned can be modified through the `sort_by` and `sort_order` keyword arguments (in the `Arx::Query` initializer):
|
88
94
|
|
89
|
-
- `sort_by` accepts the symbols: `:relevance`, `:
|
95
|
+
- `sort_by` accepts the symbols: `:relevance`, `:updated_at` or `:submitted_at`
|
90
96
|
|
91
97
|
- `sort_order` accepts the symbols: `:ascending` or `:descending`
|
92
98
|
|
93
99
|
```ruby
|
94
100
|
# Sort by submission date in ascending order (earliest first)
|
95
|
-
Arx::Query.new(sort_by: :
|
101
|
+
Arx::Query.new(sort_by: :submitted_at, sort_order: :ascending)
|
96
102
|
#=> sortBy=submittedDate&sortOrder=ascending
|
97
103
|
```
|
98
104
|
|
@@ -102,6 +108,26 @@ Arx::Query.new(sort_by: :date_submitted, sort_order: :ascending)
|
|
102
108
|
Arx::Query.new #=> sortBy=relevance&sortOrder=descending
|
103
109
|
```
|
104
110
|
|
111
|
+
#### Paging
|
112
|
+
|
113
|
+
The arXiv API offers a paging mechanism that allows you to get chucks of the result set at a time. It can be used through the `start` and `max_results` keyword arguments (in the `Arx::Query` initializer):
|
114
|
+
|
115
|
+
- `start` is the index of the first returned result (using 0-based indexing)
|
116
|
+
|
117
|
+
- `max_results` is the number of results returned by the query
|
118
|
+
|
119
|
+
```ruby
|
120
|
+
# Get results 10-29
|
121
|
+
Arx::Query.new(start: 10, max_results: 20)
|
122
|
+
#=> start=10&max_results=20
|
123
|
+
```
|
124
|
+
|
125
|
+
**Note**: The default values are those of the arXiv API: `start` defaults to `0` and `max_results` defaults to `10`:
|
126
|
+
|
127
|
+
```ruby
|
128
|
+
Arx::Query.new #=> start=0&max_results=10
|
129
|
+
```
|
130
|
+
|
105
131
|
#### Searching by ID
|
106
132
|
|
107
133
|
The arXiv search API doesn't only support searching for papers by metadata fields, but also by ID. When searching by ID, a different URL query string parameter `id_list` is used (instead of `search_query` as seen before).
|
@@ -127,14 +153,16 @@ The arXiv search API supports searches for the following paper metadata fields:
|
|
127
153
|
|
128
154
|
```ruby
|
129
155
|
FIELDS = {
|
130
|
-
title: 'ti',
|
131
|
-
author: 'au',
|
132
|
-
abstract: 'abs',
|
133
|
-
comment: 'co',
|
134
|
-
journal: 'jr',
|
135
|
-
category: 'cat',
|
136
|
-
report: 'rn',
|
137
|
-
|
156
|
+
title: 'ti', # Title
|
157
|
+
author: 'au', # Author
|
158
|
+
abstract: 'abs', # Abstract
|
159
|
+
comment: 'co', # Comment
|
160
|
+
journal: 'jr', # Journal reference
|
161
|
+
category: 'cat', # Subject category
|
162
|
+
report: 'rn', # Report number
|
163
|
+
updated_at: 'lastUpdatedDate', # Last updated date
|
164
|
+
submitted_at: 'submittedDate', # Submission date
|
165
|
+
all: 'all' # All (of the above)
|
138
166
|
}
|
139
167
|
```
|
140
168
|
|
@@ -205,6 +233,39 @@ q.and_not
|
|
205
233
|
q.category('math.NA', 'math.CO', connective: :or)
|
206
234
|
```
|
207
235
|
|
236
|
+
#### Grouping subqueries
|
237
|
+
|
238
|
+
Sometimes you'll have a query that requires nested or grouped logic, using parentheses. This can be done using the `Arx::Query#group` method.
|
239
|
+
|
240
|
+
This method accepts a block and basically parenthesises the result of whichever methods were called within the block.
|
241
|
+
|
242
|
+
For example, this will allow the last query from the previous section to be written as:
|
243
|
+
|
244
|
+
```ruby
|
245
|
+
# Papers authored by "Eleonora Andreotti" in neither the "Numerical Analysis" (math.NA) or "Combinatorics (math.CO)" categories.
|
246
|
+
q = Arx::Query.new
|
247
|
+
q.author('Eleonora Andreotti')
|
248
|
+
q.and_not
|
249
|
+
q.group do
|
250
|
+
q.category('math.NA').or.category('math.CO')
|
251
|
+
end
|
252
|
+
```
|
253
|
+
|
254
|
+
Another more complicated example with two grouped subqueries:
|
255
|
+
|
256
|
+
```ruby
|
257
|
+
# 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.
|
258
|
+
q = Arx::Query.new
|
259
|
+
q.title('Buchi Automata')
|
260
|
+
q.group do
|
261
|
+
q.author('Tomáš Babiak')
|
262
|
+
q.or
|
263
|
+
q.group do
|
264
|
+
q.category('cs.FL').and_not.category('cs.CC')
|
265
|
+
end
|
266
|
+
end
|
267
|
+
```
|
268
|
+
|
208
269
|
### Running search queries
|
209
270
|
|
210
271
|
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.
|
@@ -217,7 +278,7 @@ Calling the `Arx()` method with a block allows for the construction and executio
|
|
217
278
|
|
218
279
|
```ruby
|
219
280
|
# Papers in the cs.FL category whose title contains "Buchi Automata", not authored by Tomáš Babiak
|
220
|
-
results = Arx(sort_by: :
|
281
|
+
results = Arx(sort_by: :submitted_at) do |query|
|
221
282
|
query.category('cs.FL')
|
222
283
|
query.title('Buchi Automata').and_not.author('Tomáš Babiak')
|
223
284
|
end
|
@@ -233,7 +294,7 @@ The `Arx()` method accepts a predefined `Arx::Query` object through the `query`
|
|
233
294
|
|
234
295
|
```ruby
|
235
296
|
# Papers in the cs.FL category whose title contains "Buchi Automata", not authored by Tomáš Babiak
|
236
|
-
q = Arx::Query.new(sort_by: :
|
297
|
+
q = Arx::Query.new(sort_by: :submitted_at)
|
237
298
|
q.category('cs.FL')
|
238
299
|
q.title('Buchi Automata').and_not.author('Tomáš Babiak')
|
239
300
|
|
@@ -273,11 +334,11 @@ paper = Arx('1809.09415')
|
|
273
334
|
|
274
335
|
paper.id
|
275
336
|
#=> "1809.09415"
|
276
|
-
paper.id(
|
337
|
+
paper.id(true)
|
277
338
|
#=> "1809.09415v1"
|
278
339
|
paper.url
|
279
340
|
#=> "http://arxiv.org/abs/1809.09415"
|
280
|
-
paper.url(
|
341
|
+
paper.url(true)
|
281
342
|
#=> "http://arxiv.org/abs/1809.09415v1"
|
282
343
|
paper.version
|
283
344
|
#=> 1
|
@@ -307,13 +368,13 @@ paper.updated_at
|
|
307
368
|
paper.comment?
|
308
369
|
#=> false
|
309
370
|
paper.comment
|
310
|
-
#=> Arx::Error::MissingField (arXiv paper 1809.
|
371
|
+
#=> Arx::Error::MissingField (arXiv paper 1809.09415 is missing the `comment` metadata field)
|
311
372
|
|
312
373
|
# Paper's journal reference
|
313
374
|
paper.journal?
|
314
375
|
#=> false
|
315
376
|
paper.journal
|
316
|
-
#=> Arx::Error::MissingField (arXiv paper 1809.
|
377
|
+
#=> Arx::Error::MissingField (arXiv paper 1809.09415 is missing the `journal` metadata field)
|
317
378
|
|
318
379
|
# Paper's PDF URL
|
319
380
|
paper.pdf?
|
@@ -359,4 +420,51 @@ category.name
|
|
359
420
|
#=> "cond-mat"
|
360
421
|
category.full_name
|
361
422
|
#=> "Condensed Matter"
|
362
|
-
```
|
423
|
+
```
|
424
|
+
|
425
|
+
## Acknowledgements
|
426
|
+
|
427
|
+
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.
|
428
|
+
|
429
|
+
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.
|
430
|
+
|
431
|
+
Nevertheless, a special thanks goes out to Scholastica for providing the influence for Arx.
|
432
|
+
|
433
|
+
## Contributors
|
434
|
+
|
435
|
+
All contributions to this repository are greatly appreciated. Contribution guidelines can be found [here](/CONTRIBUTING.md).
|
436
|
+
|
437
|
+
<table>
|
438
|
+
<thead>
|
439
|
+
<tr>
|
440
|
+
<th align="center">
|
441
|
+
<a href="https://github.com/eonu">
|
442
|
+
<img src="https://avatars0.githubusercontent.com/u/24795571?s=460&v=4" alt="Edwin Onuonga" width="60px">
|
443
|
+
<br/>eonu
|
444
|
+
<br/><sub>(Edwin Onuonga)</sub>
|
445
|
+
</a>
|
446
|
+
<br/>
|
447
|
+
<a href="mailto:ed@eonu.net">✉️</a>
|
448
|
+
<a href="https://eonu.net">🌍</a>
|
449
|
+
</th>
|
450
|
+
<th align="center">
|
451
|
+
<a href="https://github.com/xuanxu">
|
452
|
+
<img src="https://avatars.githubusercontent.com/u/6528?v=4" alt="xuanxu" width="60px">
|
453
|
+
<br/>xuanxu
|
454
|
+
<br/><sub>(Juanjo Bazán)</sub>
|
455
|
+
</a>
|
456
|
+
<br/>
|
457
|
+
<a href="jjbazan@gmail.com">✉️</a>
|
458
|
+
<a href="http://juanjobazan.com/">🌍</a>
|
459
|
+
</th>
|
460
|
+
<!-- Add more <th></th> blocks for more contributors -->
|
461
|
+
</tr>
|
462
|
+
</thead>
|
463
|
+
</table>
|
464
|
+
|
465
|
+
---
|
466
|
+
|
467
|
+
<p align="center">
|
468
|
+
<b>Arx</b> © 2019-2020, Edwin Onuonga - Released under the <a href="http://mit-license.org/">MIT</a> License.<br/>
|
469
|
+
<em>Authored and maintained by Edwin Onuonga.</em>
|
470
|
+
</p>
|