arx 1.0.0 → 1.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b23b9ea5d15ed9ed58108f69176cebe48f6d5ce44f7fd4f4bd6e2937d36e8a20
4
- data.tar.gz: 0f0928e5737bbd6d5a0c2f058e4fc198b75f5968f94630d0648755616d2085a8
3
+ metadata.gz: 71eb1bee2ff468ea9327736e613e40b414c2b630d4f21b148da648500af3a47e
4
+ data.tar.gz: 8592a476d3abbeedfe2bef11637498b551fd478d643c5985a7c6a119aa79ca80
5
5
  SHA512:
6
- metadata.gz: edf64375f0efffb2722afb5746d5fd5e7ce150c88f2a8ebecdf58db3ca8b1de9c24cb950630e33f418db54d98c7cc351d5ee370e3fc481de55a4b3da59b658bd
7
- data.tar.gz: bdb9966e13ede3888ff707c8c5c1350cb74af45b276b392242985adc9e6f48ab41ca5ecc1b5f53289ac862adadcaabdd58f509932d930feac75aefc47a8ba6e1
6
+ metadata.gz: c9d708bd3f7d244f8557da0c9dba42d66c9a344a8f0316463879e76cc385fcf895c4c4089a5340543e166d771958d975fac685d27908755be0575e97f70625c2
7
+ data.tar.gz: 382f4ec892499c9e3b062693755aaa4af6c86790a830aaee39a2435d8af902d7e6bdcfc91712eaa539ef3e066c6a6ae04c151327951477194b0ca722848b0d2c
data/CHANGELOG.md CHANGED
@@ -1,3 +1,44 @@
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
+
26
+ # 1.0.1
27
+
28
+ #### Major changes
29
+
30
+ - Add cases to handle `nil` query returns. ([#45](https://github.com/eonu/arx/pull/45))
31
+ - Add support for the `coveralls` gem (`.coveralls.yml` configuration file). ([#42](https://github.com/eonu/arx/pull/42))
32
+
33
+ #### Minor changes
34
+
35
+ - Add code coverage badge to `README.md`. ([#42](https://github.com/eonu/arx/pull/42))
36
+ - Remove documentation badge from top of `README.md`. ([#42](https://github.com/eonu/arx/pull/42))
37
+ - Change author email from `ed@mail.eonu.net` to `ed@eonu.net`. ([#43](https://github.com/eonu/arx/pull/43))
38
+ - Change `ends_with_connective?` to `end_with_connective?` to follow typical Ruby patterns. ([#44](https://github.com/eonu/arx/pull/44))
39
+ - Add `/coverage/` directory to `.gitignore`. ([#45](https://github.com/eonu/arx/pull/45))
40
+ - Remove version numbers from paper identifiers in error message in `README.md`. ([#46](https://github.com/eonu/arx/pull/46))
41
+
1
42
  # 1.0.0
2
43
 
3
44
  #### Major changes
data/README.md CHANGED
@@ -7,8 +7,8 @@
7
7
  [![License](https://img.shields.io/github/license/eonu/arx.svg)](https://github.com/eonu/arx/blob/master/LICENSE)
8
8
 
9
9
  [![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
10
  [![Build Status](https://travis-ci.com/eonu/arx.svg?branch=master)](https://travis-ci.com/eonu/arx)
11
+ [![Coverage Status](https://coveralls.io/repos/github/eonu/arx/badge.svg?branch=feature%2Fcoveralls)](https://coveralls.io/github/eonu/arx?branch=feature%2Fcoveralls)
12
12
 
13
13
  **A Ruby interface for querying academic papers on the arXiv search API.**
14
14
 
@@ -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.
@@ -307,13 +344,13 @@ paper.updated_at
307
344
  paper.comment?
308
345
  #=> false
309
346
  paper.comment
310
- #=> Arx::Error::MissingField (arXiv paper 1809.09415v1 is missing the `comment` metadata field)
347
+ #=> Arx::Error::MissingField (arXiv paper 1809.09415 is missing the `comment` metadata field)
311
348
 
312
349
  # Paper's journal reference
313
350
  paper.journal?
314
351
  #=> false
315
352
  paper.journal
316
- #=> Arx::Error::MissingField (arXiv paper 1809.09415v1 is missing the `journal` metadata field)
353
+ #=> Arx::Error::MissingField (arXiv paper 1809.09415 is missing the `journal` metadata field)
317
354
 
318
355
  # Paper's PDF URL
319
356
  paper.pdf?
@@ -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
@@ -13,7 +13,7 @@ namespace :gem do
13
13
 
14
14
  desc 'Debug the gem (load into IRB)'
15
15
  task :debug do
16
- exec 'bundle exec rake install && irb -I lib/arx.rb -r arx'
16
+ exec 'bin/console'
17
17
  end
18
18
 
19
19
  desc 'Prepare a new gem release'
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@mail.eonu.net']
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.}
@@ -21,10 +21,11 @@ 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', '~> 2.0'
24
+ spec.add_development_dependency 'bundler', '>= 1.17'
25
25
  spec.add_development_dependency 'rake', '~> 12.3'
26
- spec.add_development_dependency 'thor', '~> 0.20'
26
+ spec.add_development_dependency 'thor', '~> 0.19.4'
27
27
  spec.add_development_dependency 'rspec', '~> 3.7'
28
+ spec.add_development_dependency 'coveralls', '0.8.22'
28
29
 
29
30
  spec.metadata = {
30
31
  'source_code_uri' => spec.homepage,
@@ -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 ends_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
- add_connective :and unless ends_with_connective?
203
- @query << "+#{subquery}"
218
+ @query << (start_of_group? ? "#{subquery}" : "+#{subquery}")
204
219
  else
205
220
  @query << "&#{PARAMS[:search_query]}=#{subquery}"
206
221
  end
@@ -218,10 +233,17 @@ module Arx
218
233
  #
219
234
  # @see CONNECTIVES
220
235
  # @return [Boolean]
221
- def ends_with_connective?
236
+ def end_with_connective?
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
@@ -5,7 +5,7 @@ module Arx
5
5
  # The current version of Arx.
6
6
  VERSION = {
7
7
  major: 1,
8
- minor: 0,
8
+ minor: 1,
9
9
  patch: 0,
10
10
  meta: nil,
11
11
  }.compact.values.join('.').freeze
data/lib/arx.rb CHANGED
@@ -65,12 +65,17 @@ module Arx
65
65
  raise Error::MissingPaper.new(ids.first) if results.title.empty?
66
66
  elsif results.is_a? Array
67
67
  results.reject! {|paper| paper.title.empty?}
68
+ elsif results.nil?
69
+ if ids.size == 1
70
+ raise Error::MissingPaper.new(ids.first)
71
+ else
72
+ results = []
73
+ end
68
74
  end
69
75
 
70
76
  results
71
77
  end
72
78
 
73
- alias_method :find, :search
74
79
  alias_method :get, :search
75
80
  end
76
81
  end
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.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-08 00:00:00.000000000 Z
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: '2.0'
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: '2.0'
54
+ version: '1.17'
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rake
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.20'
75
+ version: 0.19.4
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.20'
82
+ version: 0.19.4
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: rspec
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -94,9 +94,23 @@ dependencies:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '3.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: coveralls
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 0.8.22
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 0.8.22
97
111
  description:
98
112
  email:
99
- - ed@mail.eonu.net
113
+ - ed@eonu.net
100
114
  executables: []
101
115
  extensions: []
102
116
  extra_rdoc_files: []