arx 1.0.1 → 1.1.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 +25 -0
- data/README.md +48 -1
- data/Rakefile +1 -1
- data/arx.gemspec +1 -1
- data/lib/arx.rb +0 -1
- data/lib/arx/query/query.rb +25 -3
- data/lib/arx/version.rb +2 -2
- 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: 71eb1bee2ff468ea9327736e613e40b414c2b630d4f21b148da648500af3a47e
|
4
|
+
data.tar.gz: 8592a476d3abbeedfe2bef11637498b551fd478d643c5985a7c6a119aa79ca80
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c9d708bd3f7d244f8557da0c9dba42d66c9a344a8f0316463879e76cc385fcf895c4c4089a5340543e166d771958d975fac685d27908755be0575e97f70625c2
|
7
|
+
data.tar.gz: 382f4ec892499c9e3b062693755aaa4af6c86790a830aaee39a2435d8af902d7e6bdcfc91712eaa539ef3e066c6a6ae04c151327951477194b0ca722848b0d2c
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,28 @@
|
|
1
|
+
# 1.1.0
|
2
|
+
|
3
|
+
#### Major changes
|
4
|
+
|
5
|
+
- Change `bundler` requirement to `>= 1.17` in `arx.gemspec`. ([#53](https://github.com/eonu/arx/pull/53))
|
6
|
+
- Remove `Arx.find` alias of `Arx.search`. ([#57](https://github.com/eonu/arx/pull/57))
|
7
|
+
- Add `Query#group` for subquery grouping support. ([#59](https://github.com/eonu/arx/pull/59))
|
8
|
+
|
9
|
+
#### Minor changes
|
10
|
+
|
11
|
+
- Add contributing guidelines (`CONTRIBUTING.md`). ([#48](https://github.com/eonu/arx/pull/48))
|
12
|
+
- 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)):
|
13
|
+
- **Error or warning**<br>For reporting an error or warning generated by Arx.
|
14
|
+
- **Unexpected or incorrect functionality**<br>For reporting something that doesn't seem to be working correctly or is unexpected.
|
15
|
+
- **Improvement to an existing feature**<br>For suggesting an improvement to a feature already offered by Arx.
|
16
|
+
- **Suggesting a new feature**<br>For proposing a new feature to Arx that would be beneficial.
|
17
|
+
- Add a pull request template at `./github/PULL_REQUEST_TEMPLATE.md`. ([#49](https://github.com/eonu/arx/pull/49))
|
18
|
+
- Remove issue templates from `CONTRIBUTING.md`. ([#49](https://github.com/eonu/arx/pull/49))
|
19
|
+
- Remove `LICENSE` from YARD documentation (remove from `.yardopts`). ([#50](https://github.com/eonu/arx/pull/50))
|
20
|
+
- Add RVM ruby version `2.6` to `.travis.yml`. ([#53](https://github.com/eonu/arx/pull/53))
|
21
|
+
- Add contributor code-of-conduct (`CODE_OF_CONDUCT.md`). ([#56](https://github.com/eonu/arx/pull/56))
|
22
|
+
- Thank Scholastica in `README.md`. ([#58](https://github.com/eonu/arx/pull/58))
|
23
|
+
- Add `bin/console` for gem debugging. ([#60](https://github.com/eonu/arx/pull/60))
|
24
|
+
- Modify `gem:debug` rake task to run `bin/console`. ([#60](https://github.com/eonu/arx/pull/60))
|
25
|
+
|
1
26
|
# 1.0.1
|
2
27
|
|
3
28
|
#### Major changes
|
data/README.md
CHANGED
@@ -60,6 +60,10 @@ $ gem install arx
|
|
60
60
|
|
61
61
|
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
62
|
|
63
|
+
## Contributing
|
64
|
+
|
65
|
+
All contributions to Arx are greatly appreciated. Contribution guidelines can be found [here](/CONTRIBUTING.md).
|
66
|
+
|
63
67
|
## Usage
|
64
68
|
|
65
69
|
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)):
|
@@ -205,6 +209,39 @@ q.and_not
|
|
205
209
|
q.category('math.NA', 'math.CO', connective: :or)
|
206
210
|
```
|
207
211
|
|
212
|
+
#### Grouping subqueries
|
213
|
+
|
214
|
+
Sometimes you'll have a query that requires nested or grouped logic, using parentheses. This can be done using the `Arx::Query#group` method.
|
215
|
+
|
216
|
+
This method accepts a block and basically parenthesises the result of whichever methods were called within the block.
|
217
|
+
|
218
|
+
For example, this will allow the last query from the previous section to be written as:
|
219
|
+
|
220
|
+
```ruby
|
221
|
+
# Papers authored by "Eleonora Andreotti" in neither the "Numerical Analysis" (math.NA) or "Combinatorics (math.CO)" categories.
|
222
|
+
q = Arx::Query.new
|
223
|
+
q.author('Eleonora Andreotti')
|
224
|
+
q.and_not
|
225
|
+
q.group do
|
226
|
+
q.category('math.NA').or.category('math.CO')
|
227
|
+
end
|
228
|
+
```
|
229
|
+
|
230
|
+
Another more complicated example with two grouped subqueries:
|
231
|
+
|
232
|
+
```ruby
|
233
|
+
# 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.
|
234
|
+
q = Arx::Query.new
|
235
|
+
q.title('Buchi Automata')
|
236
|
+
q.group do
|
237
|
+
q.author('Tomáš Babiak')
|
238
|
+
q.or
|
239
|
+
q.group do
|
240
|
+
q.category('cs.FL').and_not.category('cs.CC')
|
241
|
+
end
|
242
|
+
end
|
243
|
+
```
|
244
|
+
|
208
245
|
### Running search queries
|
209
246
|
|
210
247
|
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.
|
@@ -359,4 +396,14 @@ category.name
|
|
359
396
|
#=> "cond-mat"
|
360
397
|
category.full_name
|
361
398
|
#=> "Condensed Matter"
|
362
|
-
```
|
399
|
+
```
|
400
|
+
|
401
|
+
# Thanks
|
402
|
+
|
403
|
+
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.
|
404
|
+
|
405
|
+
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.
|
406
|
+
|
407
|
+
---
|
408
|
+
|
409
|
+
Nevertheless, a special thanks goes out to Scholastica for providing the influence for Arx.
|
data/Rakefile
CHANGED
data/arx.gemspec
CHANGED
@@ -21,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
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', '
|
24
|
+
spec.add_development_dependency 'bundler', '>= 1.17'
|
25
25
|
spec.add_development_dependency 'rake', '~> 12.3'
|
26
26
|
spec.add_development_dependency 'thor', '~> 0.19.4'
|
27
27
|
spec.add_development_dependency 'rspec', '~> 3.7'
|
data/lib/arx.rb
CHANGED
data/lib/arx/query/query.rb
CHANGED
@@ -173,6 +173,20 @@ module Arx
|
|
173
173
|
end
|
174
174
|
end
|
175
175
|
|
176
|
+
# Creates a nested subquery (grouped statements with parentheses).
|
177
|
+
#
|
178
|
+
# @return [self]
|
179
|
+
def group
|
180
|
+
add_connective :and unless end_with_connective?
|
181
|
+
@query << (search_query? ? '+' : "&#{PARAMS[:search_query]}=")
|
182
|
+
|
183
|
+
@query << CGI.escape('(')
|
184
|
+
yield
|
185
|
+
@query << CGI.escape(')')
|
186
|
+
|
187
|
+
self
|
188
|
+
end
|
189
|
+
|
176
190
|
# Returns the query string.
|
177
191
|
#
|
178
192
|
# @return [String]
|
@@ -189,7 +203,7 @@ module Arx
|
|
189
203
|
# @return [self]
|
190
204
|
def add_connective(connective)
|
191
205
|
if search_query?
|
192
|
-
@query << "+#{CONNECTIVES[connective]}" unless end_with_connective?
|
206
|
+
@query << "+#{CONNECTIVES[connective]}" unless end_with_connective? || start_of_group?
|
193
207
|
end
|
194
208
|
self
|
195
209
|
end
|
@@ -198,9 +212,10 @@ module Arx
|
|
198
212
|
#
|
199
213
|
# @param subquery [String] The subquery to add.
|
200
214
|
def add_subquery(subquery)
|
215
|
+
add_connective :and unless end_with_connective?
|
216
|
+
|
201
217
|
if search_query?
|
202
|
-
|
203
|
-
@query << "+#{subquery}"
|
218
|
+
@query << (start_of_group? ? "#{subquery}" : "+#{subquery}")
|
204
219
|
else
|
205
220
|
@query << "&#{PARAMS[:search_query]}=#{subquery}"
|
206
221
|
end
|
@@ -222,6 +237,13 @@ module Arx
|
|
222
237
|
CONNECTIVES.values.any? &@query.method(:end_with?)
|
223
238
|
end
|
224
239
|
|
240
|
+
# Whether the query string ends in a start-of-group character '('.
|
241
|
+
#
|
242
|
+
# @return [Boolean]
|
243
|
+
def start_of_group?
|
244
|
+
@query.end_with? CGI.escape('(')
|
245
|
+
end
|
246
|
+
|
225
247
|
# Parenthesizes a string with CGI-escaped parentheses.
|
226
248
|
#
|
227
249
|
# @param string [String] The string to parenthesize.
|
data/lib/arx/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: arx
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edwin Onuonga
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-04-
|
11
|
+
date: 2019-04-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -42,16 +42,16 @@ dependencies:
|
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.17'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.17'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|