arx 0.1.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9e2022e15b66aaccb897b5596132b924ed9104040f8d090789312636be309eaf
4
- data.tar.gz: 844f3ca659a5e60168f7368db64942f90c4ab035c0d0708d726cf0bed65d6c4b
3
+ metadata.gz: 77d25732b98e3be9492bc5e103c51a2919217510e4b85e4690c1338ece3ef1fd
4
+ data.tar.gz: 0cb9a4134e64581160c079fdd47c3082f39eb72b3069a13c3f6ebd2a74c14eae
5
5
  SHA512:
6
- metadata.gz: 2d95949ba20917ea3f6d570a25011275b56259917fcff040cd1f933f4befe4af1aa037faac82a778b9a62b83c8fc82e618102cfab3e3d5e2c04fdebbbbeef396
7
- data.tar.gz: 9db9805a3328cc2cfb9c63b8c0aed45370f79ac0a6042ad5365f26156c966a43c3e818e3dfad424367350e956d92dbfeacd1bcf2cd1d88d7dcd98f81f40d6c33
6
+ metadata.gz: f91faea3efef98fc048906719b2919267fa78b99ae2e4623b7500a575691af90df5c3a7ed03328f94ebb89f5d17d754e51b6e77548e23b4482d7b603144fcf7c
7
+ data.tar.gz: 898c9c61db65c62852f0b7a097df59a0fccc77f03a1e853a06b92a0edcf31e3d5c912de1a8fde61e6b511c51523cf89bcd902a64a862d7f6f264e2869dbbad35
data/CHANGELOG.md CHANGED
@@ -1,3 +1,21 @@
1
+ # 0.2.0
2
+
3
+ #### Major changes
4
+
5
+ - 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))
6
+ - 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))
7
+
8
+ #### Minor changes
9
+
10
+ - Add `homepage` and `metadata` fields to `arx.gemspec`. ([#1](https://github.com/eonu/arx/pull/1), [#14](https://github.com/eonu/arx/pull/14))
11
+ - Specify required ruby version (`~> 2.5`) in `arx.gemspec`. ([#2](https://github.com/eonu/arx/pull/2))
12
+ - Add badges to `README.md`. ([#3](https://github.com/eonu/arx/pull/3), [#9](https://github.com/eonu/arx/pull/9))
13
+ - Fix documentation for `Arx::Paper`'s field methods `exact` argument. ([#4](https://github.com/eonu/arx/pull/4))
14
+ - Update documentation links in `arx.gemspec` and `README.md`. ([#7](https://github.com/eonu/arx/pull/7))
15
+ - Remove newline from end of `Gemfile`. ([#11](https://github.com/eonu/arx/pull/11))
16
+ - Add ruby-head version to RVM rubies in `.travis.yml`. ([#12](https://github.com/eonu/arx/pull/12))
17
+ - Remove unnecessary git-ignored files. ([#13](https://github.com/eonu/arx/pull/13), [#10](https://github.com/eonu/arx/pull/10))
18
+
1
19
  # 0.1.0
2
20
 
3
21
  Initial commit! 🎉
data/Gemfile CHANGED
@@ -1,2 +1,2 @@
1
1
  source 'https://rubygems.org'
2
- gemspec
2
+ gemspec
data/README.md CHANGED
@@ -1,3 +1,13 @@
1
1
  # Arx
2
2
 
3
+ <img src="https://upload.wikimedia.org/wikipedia/commons/thumb/a/a8/ArXiv_web.svg/1200px-ArXiv_web.svg.png" width="15%" align="right"></img>
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)
6
+ [![Gem](https://img.shields.io/gem/v/arx.svg)](https://rubygems.org/gems/arx)
7
+ [![License](https://img.shields.io/github/license/eonu/arx.svg)](https://github.com/eonu/arx/blob/master/LICENSE)
8
+
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/gems/arx/toplevel)
11
+ [![Build Status](https://travis-ci.com/eonu/arx.svg?branch=master)](https://travis-ci.com/eonu/arx)
12
+
3
13
  A Ruby interface for querying academic papers on the arXiv search API.
data/arx.gemspec CHANGED
@@ -6,7 +6,8 @@ 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 = ['edwinonuonga@gmail.com']
9
+ spec.email = ['ed@mail.eonu.net']
10
+ spec.homepage = 'https://github.com/eonu/arx'
10
11
 
11
12
  spec.summary = %q{A Ruby interface for querying academic papers on the arXiv search API.}
12
13
  spec.license = 'MIT'
@@ -15,10 +16,20 @@ Gem::Specification.new do |spec|
15
16
  Gemfile LICENSE CHANGELOG.md README.md Rakefile arx.gemspec
16
17
  ]
17
18
 
19
+ spec.required_ruby_version = '~> 2.5'
20
+
18
21
  spec.add_runtime_dependency 'nokogiri', '~> 1.10'
19
22
  spec.add_runtime_dependency 'nokogiri-happymapper', '~> 0.8'
20
23
 
21
24
  spec.add_development_dependency 'bundler', '~> 2.0'
22
25
  spec.add_development_dependency 'rake', '~> 12.3'
23
26
  spec.add_development_dependency 'rspec', '~> 3.7'
27
+
28
+ spec.metadata = {
29
+ 'source_code_uri' => spec.homepage,
30
+ 'homepage_uri' => spec.homepage,
31
+ 'documentation_uri' => 'https://www.rubydoc.info/gems/arx/toplevel',
32
+ 'bug_tracker_uri' => "#{spec.homepage}/issues",
33
+ 'changelog_uri' => "#{spec.homepage}/blob/master/CHANGELOG.md"
34
+ }
24
35
  end
data/lib/arx.rb CHANGED
@@ -16,23 +16,29 @@ module Arx
16
16
  # The arXiv search API endpoint.
17
17
  ENDPOINT = 'http://export.arxiv.org/api/query?'
18
18
 
19
- # Performs a search query for papers on the arXiv search API.
20
- #
21
- # @param ids [Array<String>] The IDs of the arXiv papers to restrict the query to.
22
- # @param sort_by [Symbol] The sorting criteria for the returned results (see {Query::SORT_BY}).
23
- # @param sort_order [Symbol] The sorting order for the returned results (see {Query::SORT_ORDER}).
24
- # @return [Array<Paper>, Paper] The {Paper}(s) found by the search query.
25
- def self.search(*ids, sort_by: :relevance, sort_order: :descending)
26
- query = Query.new(*ids, sort_by: sort_by, sort_order: sort_order)
27
-
28
- yield query if block_given?
29
-
30
- document = Nokogiri::XML open(ENDPOINT + query.to_s + '&max_results=10000')
31
- document.remove_namespaces!
32
-
33
- results = Paper.parse(document, single: false).reject {|paper| paper.id.empty?}
34
- raise MissingPaper.new(ids.first) if results.empty? && ids.size == 1
35
- ids.size == 1 && results.size == 1 ? results.first : results
19
+ class << self
20
+
21
+ # Performs a search query for papers on the arXiv search API.
22
+ #
23
+ # @param ids [Array<String>] The IDs of the arXiv papers to restrict the query to.
24
+ # @param sort_by [Symbol] The sorting criteria for the returned results (see {Query::SORT_BY}).
25
+ # @param sort_order [Symbol] The sorting order for the returned results (see {Query::SORT_ORDER}).
26
+ # @return [Array<Paper>, Paper] The {Paper}(s) found by the search query.
27
+ def search(*ids, sort_by: :relevance, sort_order: :descending)
28
+ query = Query.new(*ids, sort_by: sort_by, sort_order: sort_order)
29
+
30
+ yield query if block_given?
31
+
32
+ document = Nokogiri::XML open(ENDPOINT + query.to_s + '&max_results=10000')
33
+ document.remove_namespaces!
34
+
35
+ results = Paper.parse(document, single: false).reject {|paper| paper.id.empty?}
36
+ raise MissingPaper.new(ids.first) if results.empty? && ids.size == 1
37
+ ids.size == 1 && results.size == 1 ? results.first : results
38
+ end
39
+
40
+ alias_method :find, :search
41
+ alias_method :get, :search
36
42
  end
37
43
  end
38
44
 
@@ -103,35 +103,35 @@ module Arx
103
103
  define_method(symbol) { add_connective connective }
104
104
  end
105
105
 
106
- # @!method title(*values, exact: false, connective: :and)
106
+ # @!method title(*values, exact: true, connective: :and)
107
107
  # Search for papers by {https://arxiv.org/help/prep#title title}.
108
108
  # @param values [Array<String>] Title(s) of papers to search for.
109
109
  # @param exact [Boolean] Whether to search for an exact match of the title(s).
110
110
  # @param connective [Symbol] The logical connective to use (see {CONNECTIVES}). Only applies if there are multiple values.
111
111
  # @return [self]
112
112
 
113
- # @!method author(*values, exact: false, connective: :and)
113
+ # @!method author(*values, exact: true, connective: :and)
114
114
  # Search for papers by {https://arxiv.org/help/prep#author author}.
115
115
  # @param values [Array<String>] Author(s) of papers to search for.
116
116
  # @param exact [Boolean] Whether to search for an exact match of the author's name(s).
117
117
  # @param connective [Symbol] The logical connective to use (see {CONNECTIVES}). Only applies if there are multiple values.
118
118
  # @return [self]
119
119
 
120
- # @!method abstract(*values, exact: false, connective: :and)
120
+ # @!method abstract(*values, exact: true, connective: :and)
121
121
  # Search for papers by {https://arxiv.org/help/prep#abstract abstract}.
122
122
  # @param values [Array<String>] Abstract(s) of papers to search for.
123
123
  # @param exact [Boolean] Whether to search for an exact match of the abstract(s).
124
124
  # @param connective [Symbol] The logical connective to use (see {CONNECTIVES}). Only applies if there are multiple values.
125
125
  # @return [self]
126
126
 
127
- # @!method comment(*values, exact: false, connective: :and)
127
+ # @!method comment(*values, exact: true, connective: :and)
128
128
  # Search for papers by {https://arxiv.org/help/prep#comments comment}.
129
129
  # @param values [Array<String>] Comment(s) of papers to search for.
130
130
  # @param exact [Boolean] Whether to search for an exact match of the comment(s).
131
131
  # @param connective [Symbol] The logical connective to use (see {CONNECTIVES}). Only applies if there are multiple values.
132
132
  # @return [self]
133
133
 
134
- # @!method journal(*values, exact: false, connective: :and)
134
+ # @!method journal(*values, exact: true, connective: :and)
135
135
  # Search for papers by {https://arxiv.org/help/prep#journal journal reference}.
136
136
  # @param values [Array<String>] Journal reference(s) of papers to search for.
137
137
  # @param exact [Boolean] Whether to search for an exact match of the journal refernece(s).
@@ -161,6 +161,8 @@ module Arx
161
161
  define_method(name) do |*values, exact: true, connective: :and|
162
162
  return if values.empty?
163
163
 
164
+ values.flatten!
165
+
164
166
  Validate.values values
165
167
  Validate.categories values if name == :category
166
168
  Validate.exact exact
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: 0,
8
- minor: 1,
8
+ minor: 2,
9
9
  patch: 0,
10
10
  meta: nil
11
11
  }.compact.values.join('.').freeze
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: 0.1.0
4
+ version: 0.2.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-03-24 00:00:00.000000000 Z
11
+ date: 2019-03-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nokogiri
@@ -82,7 +82,7 @@ dependencies:
82
82
  version: '3.7'
83
83
  description:
84
84
  email:
85
- - edwinonuonga@gmail.com
85
+ - ed@mail.eonu.net
86
86
  executables: []
87
87
  extensions: []
88
88
  extra_rdoc_files: []
@@ -104,19 +104,24 @@ files:
104
104
  - lib/arx/query/query.rb
105
105
  - lib/arx/query/validate.rb
106
106
  - lib/arx/version.rb
107
- homepage:
107
+ homepage: https://github.com/eonu/arx
108
108
  licenses:
109
109
  - MIT
110
- metadata: {}
110
+ metadata:
111
+ source_code_uri: https://github.com/eonu/arx
112
+ homepage_uri: https://github.com/eonu/arx
113
+ documentation_uri: https://www.rubydoc.info/gems/arx/toplevel
114
+ bug_tracker_uri: https://github.com/eonu/arx/issues
115
+ changelog_uri: https://github.com/eonu/arx/blob/master/CHANGELOG.md
111
116
  post_install_message:
112
117
  rdoc_options: []
113
118
  require_paths:
114
119
  - lib
115
120
  required_ruby_version: !ruby/object:Gem::Requirement
116
121
  requirements:
117
- - - ">="
122
+ - - "~>"
118
123
  - !ruby/object:Gem::Version
119
- version: '0'
124
+ version: '2.5'
120
125
  required_rubygems_version: !ruby/object:Gem::Requirement
121
126
  requirements:
122
127
  - - ">="