serrano 0.2.2 → 0.3.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 +4 -4
- data/CHANGELOG.md +12 -0
- data/Gemfile.lock +16 -16
- data/lib/serrano.rb +65 -13
- data/lib/serrano/filterhandler.rb +7 -7
- data/lib/serrano/filters.rb +5 -2
- data/lib/serrano/request_cursor.rb +9 -4
- data/lib/serrano/utils.rb +24 -0
- data/lib/serrano/version.rb +1 -1
- data/serrano.gemspec +9 -9
- metadata +36 -18
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17e8d485b799d87d73a32f1b1324a004647407fa
|
4
|
+
data.tar.gz: cbba210bf1dbb7df00ef98b8e6824294a00472cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65b752d0ab2e82da21b73569217a630affc64faa25947050311c30925f8eedd55469ae622d6bd19734929b4fb791c6e146f32d7c627300bd65ff5b9dd7eb4875
|
7
|
+
data.tar.gz: bdd2dbe1a0e6b6c21ce71d404efdf0b97b61b02387f9363519821bd570eddc819bdcb545e375a7a794f186f9fb34cacc4a7fa800cf7634b3dd2b203e9d82b7ad
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,15 @@
|
|
1
|
+
## 0.3.0 (2016-10-20)
|
2
|
+
|
3
|
+
* Field queries now supported in appropriate methods:
|
4
|
+
`Serrano.works`, `Serrano.members`, `Serrano.prefixes`, `Serrano.funders`,
|
5
|
+
`Serrano.journals`, and `Serrano.types` (#27)
|
6
|
+
* Caching bundler on Travis for faster build time (#28)
|
7
|
+
* `sample` parameter now has a max of 100, where it was
|
8
|
+
1000 previously (#30)
|
9
|
+
* Two new filters are available: `has-clinical-trial-number` and `has-abstract`.
|
10
|
+
Both are added to the filter helper functions and can be used in queries (#31)
|
11
|
+
* Updated (dev) dependency versions
|
12
|
+
|
1
13
|
## 0.2.2 (2016-06-07)
|
2
14
|
|
3
15
|
* Fixed bug in `content_negotation` in which a length 1 array of DOIs was
|
data/Gemfile.lock
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
serrano (0.
|
4
|
+
serrano (0.3.0)
|
5
5
|
faraday (~> 0.9.2)
|
6
6
|
faraday_middleware (~> 0.10.0)
|
7
|
-
multi_json (~> 1.12.1)
|
7
|
+
multi_json (~> 1.12, >= 1.12.1)
|
8
8
|
thor (~> 0.19.1)
|
9
9
|
|
10
10
|
GEM
|
11
11
|
remote: https://rubygems.org/
|
12
12
|
specs:
|
13
|
-
codecov (0.1.
|
13
|
+
codecov (0.1.6)
|
14
14
|
json
|
15
15
|
simplecov
|
16
16
|
url
|
@@ -19,17 +19,17 @@ GEM
|
|
19
19
|
multipart-post (>= 1.2, < 3)
|
20
20
|
faraday_middleware (0.10.0)
|
21
21
|
faraday (>= 0.7.4, < 0.10)
|
22
|
-
json (
|
22
|
+
json (2.0.2)
|
23
23
|
multi_json (1.12.1)
|
24
24
|
multipart-post (2.0.0)
|
25
|
-
power_assert (0.3.
|
26
|
-
rake (11.
|
27
|
-
simplecov (0.
|
25
|
+
power_assert (0.3.1)
|
26
|
+
rake (11.3.0)
|
27
|
+
simplecov (0.12.0)
|
28
28
|
docile (~> 1.1.0)
|
29
|
-
json (
|
29
|
+
json (>= 1.8, < 3)
|
30
30
|
simplecov-html (~> 0.10.0)
|
31
31
|
simplecov-html (0.10.0)
|
32
|
-
test-unit (3.1
|
32
|
+
test-unit (3.2.1)
|
33
33
|
power_assert
|
34
34
|
thor (0.19.1)
|
35
35
|
url (0.3.2)
|
@@ -38,13 +38,13 @@ PLATFORMS
|
|
38
38
|
ruby
|
39
39
|
|
40
40
|
DEPENDENCIES
|
41
|
-
bundler (~> 1.
|
42
|
-
codecov (~> 0.1.
|
43
|
-
json (~>
|
44
|
-
rake (~> 11.
|
41
|
+
bundler (~> 1.13, >= 1.13.5)
|
42
|
+
codecov (~> 0.1.6)
|
43
|
+
json (~> 2.0, >= 2.0.2)
|
44
|
+
rake (~> 11.3)
|
45
45
|
serrano!
|
46
|
-
simplecov (~> 0.
|
47
|
-
test-unit (~> 3.1
|
46
|
+
simplecov (~> 0.12.0)
|
47
|
+
test-unit (~> 3.2, >= 3.2.1)
|
48
48
|
|
49
49
|
BUNDLED WITH
|
50
|
-
1.
|
50
|
+
1.13.5
|
data/lib/serrano.rb
CHANGED
@@ -14,6 +14,7 @@ require 'rexml/xpath'
|
|
14
14
|
# @param limit [Fixnum] Number of results to return. Not relavant when searching with specific dois. Default: 20. Max: 1000
|
15
15
|
# @param sample [Fixnum] Number of random results to return. when you use the sample parameter,
|
16
16
|
# the limit and offset parameters are ignored. This parameter only used when works requested.
|
17
|
+
# Max: 100.
|
17
18
|
# @param sort [String] Field to sort on, one of score, relevance,
|
18
19
|
# updated (date of most recent change to metadata - currently the same as deposited),
|
19
20
|
# deposited (time of most recent deposit), indexed (time of most recent index), or
|
@@ -48,6 +49,12 @@ require 'rexml/xpath'
|
|
48
49
|
# - boundary [String] of the boundary value
|
49
50
|
# - oauth [Hash] A hash with OAuth details
|
50
51
|
|
52
|
+
# @!macro field_queries
|
53
|
+
# @param [Hash<Object>] args Field queries, as named parameters.
|
54
|
+
# See https://github.com/CrossRef/rest-api-doc/blob/master/rest_api.md#field-queries
|
55
|
+
# Field query parameters mut be named, and must start with `query_`. Any dashes or
|
56
|
+
# periods should be replaced with underscores.
|
57
|
+
|
51
58
|
##
|
52
59
|
# Serrano - The top level module for using methods
|
53
60
|
# to access Serrano APIs
|
@@ -97,6 +104,7 @@ module Serrano
|
|
97
104
|
# @!macro serrano_params
|
98
105
|
# @!macro serrano_options
|
99
106
|
# @!macro cursor_params
|
107
|
+
# @!macro field_queries
|
100
108
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
101
109
|
# @param query [String] A query string
|
102
110
|
# @param filter [Hash] Filter options. See ...
|
@@ -109,16 +117,21 @@ module Serrano
|
|
109
117
|
# Serrano.works(ids: '10.1371/journal.pone.0033693')
|
110
118
|
# Serrano.works(ids: ['10.1007/12080.1874-1746','10.1007/10452.1573-5125', '10.1111/(issn)1442-9993'])
|
111
119
|
# Serrano.works(ids: ["10.1016/0304-4009(81)90025-5", "10.1016/0304-4009(83)90036-0"])
|
120
|
+
#
|
112
121
|
# # query
|
113
122
|
# Serrano.works(query: "ecology")
|
114
123
|
# Serrano.works(query: "renear+-ontologies")
|
124
|
+
#
|
115
125
|
# # Sort
|
116
126
|
# Serrano.works(query: "ecology", sort: 'relevance', order: "asc")
|
127
|
+
#
|
117
128
|
# # Filters
|
118
129
|
# Serrano.works(filter: {has_full_text: true})
|
119
130
|
# res = Serrano.works(filter: {has_full_text: true})
|
120
131
|
# Serrano.works(filter: {has_funder: true, has_full_text: true})
|
121
132
|
# Serrano.works(filter: {award_number: 'CBET-0756451', award_funder: '10.13039/100000001'})
|
133
|
+
# Serrano.works(filter: {has_abstract: true})
|
134
|
+
# Serrano.works(filter: {has_clinical_trial_number: true})
|
122
135
|
#
|
123
136
|
# # Curl options
|
124
137
|
# ## set a request timeout and an open timeout
|
@@ -142,13 +155,22 @@ module Serrano
|
|
142
155
|
# res.collect { |x| x['message']['items'].length }.reduce(0, :+)
|
143
156
|
# items = res.collect {|x| x['message']['items']}.flatten
|
144
157
|
# items.collect { |x| x['DOI'] }[0,20]
|
158
|
+
#
|
159
|
+
# # field queries
|
160
|
+
# ## query.author
|
161
|
+
# res = Serrano.works(query: "ecology", query_author: 'Boettiger')
|
162
|
+
# res['message']['items'].collect { |x| x['author'][0]['family'] }
|
163
|
+
#
|
164
|
+
# ## query.container-title
|
165
|
+
# res = Serrano.works(query: "ecology", query_container_title: 'Ecology')
|
166
|
+
# res['message']['items'].collect { |x| x['container-title'] }
|
145
167
|
def self.works(ids: nil, query: nil, filter: nil, offset: nil,
|
146
168
|
limit: nil, sample: nil, sort: nil, order: nil, facet: nil,
|
147
|
-
options: nil, verbose: false, cursor: nil, cursor_max: 5000)
|
169
|
+
options: nil, verbose: false, cursor: nil, cursor_max: 5000, **args)
|
148
170
|
|
149
171
|
RequestCursor.new('works', ids, query, filter, offset,
|
150
172
|
limit, sample, sort, order, facet, nil, nil, options,
|
151
|
-
verbose, cursor, cursor_max).perform
|
173
|
+
verbose, cursor, cursor_max, args).perform
|
152
174
|
end
|
153
175
|
|
154
176
|
##
|
@@ -157,6 +179,7 @@ module Serrano
|
|
157
179
|
# @!macro serrano_params
|
158
180
|
# @!macro serrano_options
|
159
181
|
# @!macro cursor_params
|
182
|
+
# @!macro field_queries
|
160
183
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
161
184
|
# @param query [String] A query string
|
162
185
|
# @param filter [Hash] Filter options. See ...
|
@@ -188,14 +211,19 @@ module Serrano
|
|
188
211
|
# res[0].collect { |x| x['message']['items'].length }.reduce(0, :+)
|
189
212
|
# items = res[0].collect { |x| x['message']['items'] }.flatten
|
190
213
|
# items.collect{ |z| z['DOI'] }[0,50]
|
214
|
+
#
|
215
|
+
# # field queries
|
216
|
+
# ## query.title
|
217
|
+
# res = Serrano.members(ids: 221, works: true, query_container_title: 'Advances')
|
218
|
+
# res[0]['message']['items'].collect { |x| x['container-title'] }
|
191
219
|
def self.members(ids: nil, query: nil, filter: nil, offset: nil,
|
192
220
|
limit: nil, sample: nil, sort: nil, order: nil, facet: nil,
|
193
221
|
works: false, options: nil, verbose: false,
|
194
|
-
cursor: nil, cursor_max: 5000)
|
222
|
+
cursor: nil, cursor_max: 5000, **args)
|
195
223
|
|
196
224
|
RequestCursor.new('members', ids, query, filter, offset,
|
197
225
|
limit, sample, sort, order, facet, works, nil, options,
|
198
|
-
verbose, cursor, cursor_max).perform
|
226
|
+
verbose, cursor, cursor_max, args).perform
|
199
227
|
end
|
200
228
|
|
201
229
|
##
|
@@ -204,6 +232,7 @@ module Serrano
|
|
204
232
|
# @!macro serrano_params
|
205
233
|
# @!macro serrano_options
|
206
234
|
# @!macro cursor_params
|
235
|
+
# @!macro field_queries
|
207
236
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
208
237
|
# @param filter [Hash] Filter options. See ...
|
209
238
|
# @param works [Boolean] If true, works returned as well. Default: false
|
@@ -226,14 +255,19 @@ module Serrano
|
|
226
255
|
# res[0].collect { |x| x['message']['items'].length }.reduce(0, :+)
|
227
256
|
# items = res[0].collect { |x| x['message']['items'] }.flatten;
|
228
257
|
# items.collect{ |z| z['DOI'] }[0,50]
|
258
|
+
#
|
259
|
+
# # field queries
|
260
|
+
# ## query.title
|
261
|
+
# res = Serrano.prefixes(ids: "10.1016", works: true, query_title: 'cell biology')
|
262
|
+
# res[0]['message']['items'].collect { |x| x['title'] }
|
229
263
|
def self.prefixes(ids:, filter: nil, offset: nil,
|
230
264
|
limit: nil, sample: nil, sort: nil, order: nil, facet: nil,
|
231
265
|
works: false, options: nil, verbose: false,
|
232
|
-
cursor: nil, cursor_max: 5000)
|
266
|
+
cursor: nil, cursor_max: 5000, **args)
|
233
267
|
|
234
268
|
RequestCursor.new('prefixes', ids, nil, filter, offset,
|
235
269
|
limit, sample, sort, order, facet, works, nil, options,
|
236
|
-
verbose, cursor, cursor_max).perform
|
270
|
+
verbose, cursor, cursor_max, args).perform
|
237
271
|
end
|
238
272
|
|
239
273
|
##
|
@@ -242,6 +276,7 @@ module Serrano
|
|
242
276
|
# @!macro serrano_params
|
243
277
|
# @!macro serrano_options
|
244
278
|
# @!macro cursor_params
|
279
|
+
# @!macro field_queries
|
245
280
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
246
281
|
# @param query [String] A query string
|
247
282
|
# @param filter [Hash] Filter options. See ...
|
@@ -269,14 +304,19 @@ module Serrano
|
|
269
304
|
# res[0].collect { |x| x['message']['items'].length }.reduce(0, :+)
|
270
305
|
# items = res[0].collect { |x| x['message']['items'] }.flatten;
|
271
306
|
# items.collect{ |z| z['DOI'] }[0,50]
|
307
|
+
#
|
308
|
+
# # field queries
|
309
|
+
# ## query.title
|
310
|
+
# res = Serrano.funders(ids: "10.13039/100000001", works: true, query_author: 'Simon')
|
311
|
+
# res[0]['message']['items'].collect { |x| x['author'][0]['family'] }
|
272
312
|
def self.funders(ids: nil, query: nil, filter: nil, offset: nil,
|
273
313
|
limit: nil, sample: nil, sort: nil, order: nil, facet: nil,
|
274
314
|
works: false, options: nil, verbose: false,
|
275
|
-
cursor: nil, cursor_max: 5000)
|
315
|
+
cursor: nil, cursor_max: 5000, **args)
|
276
316
|
|
277
317
|
RequestCursor.new('funders', ids, query, filter, offset,
|
278
318
|
limit, sample, sort, order, facet, works, nil, options,
|
279
|
-
verbose, cursor, cursor_max).perform
|
319
|
+
verbose, cursor, cursor_max, args).perform
|
280
320
|
end
|
281
321
|
|
282
322
|
##
|
@@ -285,6 +325,7 @@ module Serrano
|
|
285
325
|
# @!macro serrano_params
|
286
326
|
# @!macro serrano_options
|
287
327
|
# @!macro cursor_params
|
328
|
+
# @!macro field_queries
|
288
329
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
289
330
|
# @param query [String] A query string
|
290
331
|
# @param filter [Hash] Filter options. See ...
|
@@ -312,14 +353,19 @@ module Serrano
|
|
312
353
|
# res[0].collect { |x| x['message']['items'].length }.reduce(0, :+)
|
313
354
|
# items = res[0].collect { |x| x['message']['items'] }.flatten;
|
314
355
|
# items.collect{ |z| z['DOI'] }[0,50]
|
356
|
+
#
|
357
|
+
# # field queries
|
358
|
+
# ## query.title
|
359
|
+
# res = Serrano.journals(ids: "2167-8359", works: true, query_container_title: 'Advances')
|
360
|
+
# res[0]['message']['items'].collect { |x| x['container-title'] }
|
315
361
|
def self.journals(ids: nil, query: nil, filter: nil, offset: nil,
|
316
362
|
limit: nil, sample: nil, sort: nil, order: nil, facet: nil,
|
317
363
|
works: false, options: nil, verbose: false,
|
318
|
-
cursor: nil, cursor_max: 5000)
|
364
|
+
cursor: nil, cursor_max: 5000, **args)
|
319
365
|
|
320
366
|
RequestCursor.new('journals', ids, query, filter, offset,
|
321
367
|
limit, sample, sort, order, facet, works, nil, options,
|
322
|
-
verbose, cursor, cursor_max).perform
|
368
|
+
verbose, cursor, cursor_max, args).perform
|
323
369
|
end
|
324
370
|
|
325
371
|
##
|
@@ -327,6 +373,7 @@ module Serrano
|
|
327
373
|
#
|
328
374
|
# @!macro serrano_options
|
329
375
|
# @!macro cursor_params
|
376
|
+
# @!macro field_queries
|
330
377
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
331
378
|
# @param works [Boolean] If true, works returned as well. Default: false
|
332
379
|
# @return [Array] An array of hashes
|
@@ -343,12 +390,17 @@ module Serrano
|
|
343
390
|
# res[0].collect { |x| x['message']['items'].length }.reduce(0, :+)
|
344
391
|
# items = res[0].collect { |x| x['message']['items'] }.flatten;
|
345
392
|
# items.collect{ |z| z['DOI'] }[0,50]
|
393
|
+
#
|
394
|
+
# # field queries
|
395
|
+
# ## query.title
|
396
|
+
# res = Serrano.types(ids: "journal", works: true, query_container_title: 'Advances')
|
397
|
+
# res[0]['message']['items'].collect { |x| x['container-title'] }
|
346
398
|
def self.types(ids: nil, offset: nil, limit: nil, works: false,
|
347
|
-
options: nil, verbose: false, cursor: nil, cursor_max: 5000)
|
399
|
+
options: nil, verbose: false, cursor: nil, cursor_max: 5000, **args)
|
348
400
|
|
349
401
|
RequestCursor.new('types', ids, nil, nil, offset,
|
350
402
|
limit, nil, nil, nil, nil, works, nil, options,
|
351
|
-
verbose, cursor, cursor_max).perform
|
403
|
+
verbose, cursor, cursor_max, args).perform
|
352
404
|
end
|
353
405
|
|
354
406
|
##
|
@@ -393,7 +445,7 @@ module Serrano
|
|
393
445
|
# Get a random set of DOI's
|
394
446
|
#
|
395
447
|
# @!macro serrano_options
|
396
|
-
# @param sample [Fixnum] Number of random DOIs to return
|
448
|
+
# @param sample [Fixnum] Number of random DOIs to return. Max: 100. Default: 10
|
397
449
|
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
398
450
|
# @return [Array] A list of strings, each a DOI
|
399
451
|
# @note This method uses {Serrano.works} internally, but doesn't allow you to pass on
|
@@ -9,11 +9,11 @@ module Helpers
|
|
9
9
|
nil
|
10
10
|
else
|
11
11
|
x = stringify(x)
|
12
|
-
nn = x.keys.collect{ |
|
13
|
-
if nn.collect{ |
|
14
|
-
nn = nn.collect{ |
|
15
|
-
if $others.include?
|
16
|
-
case
|
12
|
+
nn = x.keys.collect{ |z| z.to_s }
|
13
|
+
if nn.collect{ |w| $others.include? w }.any?
|
14
|
+
nn = nn.collect{ |b|
|
15
|
+
if $others.include? b
|
16
|
+
case b
|
17
17
|
when 'license_url'
|
18
18
|
'license.url'
|
19
19
|
when 'license_version'
|
@@ -30,12 +30,12 @@ module Helpers
|
|
30
30
|
'award.funder'
|
31
31
|
end
|
32
32
|
else
|
33
|
-
|
33
|
+
b
|
34
34
|
end
|
35
35
|
}
|
36
36
|
end
|
37
37
|
|
38
|
-
newnn = nn.collect{ |
|
38
|
+
newnn = nn.collect{ |m| m.gsub("_", "-") }
|
39
39
|
x = rename_keys(x, newnn)
|
40
40
|
x = x.collect{ |k,v| [k, v].join(":") }.join(',')
|
41
41
|
return x
|
data/lib/serrano/filters.rb
CHANGED
@@ -31,7 +31,8 @@ $filter_list = [
|
|
31
31
|
'archive','has_orcid','orcid','issn','type','directory','doi','updates','is_update',
|
32
32
|
'has_update_policy','container_title','publisher_name','category_name','type_name',
|
33
33
|
'from_created_date', 'until_created_date', 'affiliation', 'has_affiliation',
|
34
|
-
'assertion_group', 'assertion', 'article_number', 'alternative_id'
|
34
|
+
'assertion_group', 'assertion', 'article_number', 'alternative_id',
|
35
|
+
'has_clinical_trial_number', 'has_abstract'
|
35
36
|
]
|
36
37
|
|
37
38
|
$filter_details = {
|
@@ -80,5 +81,7 @@ $filter_details = {
|
|
80
81
|
"affiliation" => { "possible_values" => nil, "description" => "metadata for records with at least one contributor with the given affiliation" },
|
81
82
|
"has_affiliation" => { "possible_values" => nil, "description" => "metadata for records that have any affiliation information" },
|
82
83
|
"alternative_id" => { "possible_values" => nil, "description" => "metadata for records with the given alternative ID, which may be a publisher_specific ID, or any other identifier a publisher may have provided" },
|
83
|
-
"article_number" => { "possible_values" => nil, "description" => "metadata for records with a given article number" }
|
84
|
+
"article_number" => { "possible_values" => nil, "description" => "metadata for records with a given article number" },
|
85
|
+
"has_clinical_trial_number" => { "possible_values" => nil, "description" => "metadata for records which include a clinical trial number" },
|
86
|
+
"has_abstract" => { "possible_values" => nil, "description" => "metadata for records which include an abstract" }
|
84
87
|
}
|
@@ -7,6 +7,7 @@ require 'serrano/helpers/configuration'
|
|
7
7
|
require 'serrano/filterhandler'
|
8
8
|
require 'serrano/error'
|
9
9
|
require 'serrano/faraday'
|
10
|
+
require 'serrano/utils'
|
10
11
|
|
11
12
|
##
|
12
13
|
# Serrano::RequestCursor
|
@@ -31,10 +32,11 @@ module Serrano
|
|
31
32
|
attr_accessor :verbose
|
32
33
|
attr_accessor :cursor
|
33
34
|
attr_accessor :cursor_max
|
35
|
+
attr_accessor :args
|
34
36
|
|
35
37
|
def initialize(endpt, id, query, filter, offset,
|
36
38
|
limit, sample, sort, order, facet, works, agency,
|
37
|
-
options, verbose, cursor, cursor_max)
|
39
|
+
options, verbose, cursor, cursor_max, args)
|
38
40
|
|
39
41
|
self.endpt = endpt
|
40
42
|
self.id = id
|
@@ -52,10 +54,12 @@ module Serrano
|
|
52
54
|
self.verbose = verbose
|
53
55
|
self.cursor = cursor
|
54
56
|
self.cursor_max = cursor_max
|
57
|
+
self.args = args
|
55
58
|
end
|
56
59
|
|
57
60
|
def perform
|
58
61
|
filt = filter_handler(self.filter)
|
62
|
+
fieldqueries = field_query_handler(self.args)
|
59
63
|
|
60
64
|
if self.cursor_max.class != nil
|
61
65
|
if self.cursor_max.class != Fixnum
|
@@ -63,10 +67,11 @@ module Serrano
|
|
63
67
|
end
|
64
68
|
end
|
65
69
|
|
66
|
-
|
70
|
+
arguments = { query: self.query, filter: filt, offset: self.offset,
|
67
71
|
rows: self.limit, sample: self.sample, sort: self.sort,
|
68
|
-
order: self.order, facet: self.facet, cursor: self.cursor }
|
69
|
-
|
72
|
+
order: self.order, facet: self.facet, cursor: self.cursor }.tostrings
|
73
|
+
arguments = arguments.merge(fieldqueries)
|
74
|
+
opts = arguments.delete_if { |k, v| v.nil? }
|
70
75
|
|
71
76
|
if verbose
|
72
77
|
$conn = Faraday.new(:url => Serrano.base_url, :request => options) do |f|
|
data/lib/serrano/utils.rb
CHANGED
@@ -3,3 +3,27 @@ def make_ua
|
|
3
3
|
habua = 'Serrano/v' + Serrano::VERSION
|
4
4
|
return requa + ' ' + habua
|
5
5
|
end
|
6
|
+
|
7
|
+
def field_query_handler(x)
|
8
|
+
tmp = x.keep_if { |z| z.match(/query_/) }
|
9
|
+
return rename_query_filters(tmp)
|
10
|
+
end
|
11
|
+
|
12
|
+
def rename_query_filters(foo)
|
13
|
+
foo = foo.tostrings
|
14
|
+
foo = foo.map { |x,y| [x.to_s.sub('container_title', 'container-title'), y] }.to_h
|
15
|
+
foo = foo.map { |x,y| [x.to_s.sub('query_', 'query.'), y] }.to_h
|
16
|
+
return foo
|
17
|
+
end
|
18
|
+
|
19
|
+
class Hash
|
20
|
+
def tostrings
|
21
|
+
Hash[self.map{|(k,v)| [k.to_s,v]}]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class Hash
|
26
|
+
def tosymbols
|
27
|
+
Hash[self.map{|(k,v)| [k.to_sym,v]}]
|
28
|
+
end
|
29
|
+
end
|
data/lib/serrano/version.rb
CHANGED
data/serrano.gemspec
CHANGED
@@ -8,12 +8,12 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.version = Serrano::VERSION
|
9
9
|
s.platform = Gem::Platform::RUBY
|
10
10
|
s.required_ruby_version = '>= 2.0'
|
11
|
-
s.date = '2016-
|
11
|
+
s.date = '2016-10-20'
|
12
12
|
s.summary = "Crossref Client"
|
13
13
|
s.description = "Low Level Ruby Client for the Crossref Search API"
|
14
14
|
s.authors = "Scott Chamberlain"
|
15
15
|
s.email = 'myrmecocystus@gmail.com'
|
16
|
-
s.homepage = '
|
16
|
+
s.homepage = 'https://github.com/sckott/serrano'
|
17
17
|
s.licenses = 'MIT'
|
18
18
|
|
19
19
|
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
@@ -22,15 +22,15 @@ Gem::Specification.new do |s|
|
|
22
22
|
s.bindir = 'bin'
|
23
23
|
s.executables = ['serrano']
|
24
24
|
|
25
|
-
s.add_development_dependency
|
26
|
-
s.add_development_dependency
|
27
|
-
s.add_development_dependency
|
28
|
-
s.add_development_dependency
|
29
|
-
s.add_development_dependency
|
30
|
-
s.add_development_dependency 'json', '~>
|
25
|
+
s.add_development_dependency 'bundler', '~> 1.13', '>= 1.13.5'
|
26
|
+
s.add_development_dependency 'rake', '~> 11.3'
|
27
|
+
s.add_development_dependency 'test-unit', '~> 3.2', '>= 3.2.1'
|
28
|
+
s.add_development_dependency 'simplecov', '~> 0.12.0'
|
29
|
+
s.add_development_dependency 'codecov', '~> 0.1.6'
|
30
|
+
s.add_development_dependency 'json', '~> 2.0', '>= 2.0.2'
|
31
31
|
|
32
32
|
s.add_runtime_dependency 'faraday', '~> 0.9.2'
|
33
33
|
s.add_runtime_dependency 'faraday_middleware', '~> 0.10.0'
|
34
34
|
s.add_runtime_dependency 'thor', '~> 0.19.1'
|
35
|
-
s.add_runtime_dependency 'multi_json', '~> 1.12.1'
|
35
|
+
s.add_runtime_dependency 'multi_json', '~> 1.12', '>= 1.12.1'
|
36
36
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: serrano
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chamberlain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-10-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -16,90 +16,102 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 1.
|
19
|
+
version: '1.13'
|
20
|
+
- - ">="
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: 1.13.5
|
20
23
|
type: :development
|
21
24
|
prerelease: false
|
22
25
|
version_requirements: !ruby/object:Gem::Requirement
|
23
26
|
requirements:
|
24
27
|
- - "~>"
|
25
28
|
- !ruby/object:Gem::Version
|
26
|
-
version: 1.
|
29
|
+
version: '1.13'
|
30
|
+
- - ">="
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: 1.13.5
|
27
33
|
- !ruby/object:Gem::Dependency
|
28
34
|
name: rake
|
29
35
|
requirement: !ruby/object:Gem::Requirement
|
30
36
|
requirements:
|
31
37
|
- - "~>"
|
32
38
|
- !ruby/object:Gem::Version
|
33
|
-
version: 11.
|
39
|
+
version: '11.3'
|
34
40
|
type: :development
|
35
41
|
prerelease: false
|
36
42
|
version_requirements: !ruby/object:Gem::Requirement
|
37
43
|
requirements:
|
38
44
|
- - "~>"
|
39
45
|
- !ruby/object:Gem::Version
|
40
|
-
version: 11.
|
46
|
+
version: '11.3'
|
41
47
|
- !ruby/object:Gem::Dependency
|
42
48
|
name: test-unit
|
43
49
|
requirement: !ruby/object:Gem::Requirement
|
44
50
|
requirements:
|
45
51
|
- - "~>"
|
46
52
|
- !ruby/object:Gem::Version
|
47
|
-
version: 3.
|
53
|
+
version: '3.2'
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: 3.2.1
|
48
57
|
type: :development
|
49
58
|
prerelease: false
|
50
59
|
version_requirements: !ruby/object:Gem::Requirement
|
51
60
|
requirements:
|
52
61
|
- - "~>"
|
53
62
|
- !ruby/object:Gem::Version
|
54
|
-
version: 3.
|
63
|
+
version: '3.2'
|
64
|
+
- - ">="
|
65
|
+
- !ruby/object:Gem::Version
|
66
|
+
version: 3.2.1
|
55
67
|
- !ruby/object:Gem::Dependency
|
56
68
|
name: simplecov
|
57
69
|
requirement: !ruby/object:Gem::Requirement
|
58
70
|
requirements:
|
59
71
|
- - "~>"
|
60
72
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
73
|
+
version: 0.12.0
|
62
74
|
type: :development
|
63
75
|
prerelease: false
|
64
76
|
version_requirements: !ruby/object:Gem::Requirement
|
65
77
|
requirements:
|
66
78
|
- - "~>"
|
67
79
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
80
|
+
version: 0.12.0
|
69
81
|
- !ruby/object:Gem::Dependency
|
70
82
|
name: codecov
|
71
83
|
requirement: !ruby/object:Gem::Requirement
|
72
84
|
requirements:
|
73
85
|
- - "~>"
|
74
86
|
- !ruby/object:Gem::Version
|
75
|
-
version: 0.1.
|
87
|
+
version: 0.1.6
|
76
88
|
type: :development
|
77
89
|
prerelease: false
|
78
90
|
version_requirements: !ruby/object:Gem::Requirement
|
79
91
|
requirements:
|
80
92
|
- - "~>"
|
81
93
|
- !ruby/object:Gem::Version
|
82
|
-
version: 0.1.
|
94
|
+
version: 0.1.6
|
83
95
|
- !ruby/object:Gem::Dependency
|
84
96
|
name: json
|
85
97
|
requirement: !ruby/object:Gem::Requirement
|
86
98
|
requirements:
|
87
99
|
- - "~>"
|
88
100
|
- !ruby/object:Gem::Version
|
89
|
-
version: '
|
101
|
+
version: '2.0'
|
90
102
|
- - ">="
|
91
103
|
- !ruby/object:Gem::Version
|
92
|
-
version:
|
104
|
+
version: 2.0.2
|
93
105
|
type: :development
|
94
106
|
prerelease: false
|
95
107
|
version_requirements: !ruby/object:Gem::Requirement
|
96
108
|
requirements:
|
97
109
|
- - "~>"
|
98
110
|
- !ruby/object:Gem::Version
|
99
|
-
version: '
|
111
|
+
version: '2.0'
|
100
112
|
- - ">="
|
101
113
|
- !ruby/object:Gem::Version
|
102
|
-
version:
|
114
|
+
version: 2.0.2
|
103
115
|
- !ruby/object:Gem::Dependency
|
104
116
|
name: faraday
|
105
117
|
requirement: !ruby/object:Gem::Requirement
|
@@ -147,6 +159,9 @@ dependencies:
|
|
147
159
|
requirement: !ruby/object:Gem::Requirement
|
148
160
|
requirements:
|
149
161
|
- - "~>"
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
version: '1.12'
|
164
|
+
- - ">="
|
150
165
|
- !ruby/object:Gem::Version
|
151
166
|
version: 1.12.1
|
152
167
|
type: :runtime
|
@@ -154,6 +169,9 @@ dependencies:
|
|
154
169
|
version_requirements: !ruby/object:Gem::Requirement
|
155
170
|
requirements:
|
156
171
|
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '1.12'
|
174
|
+
- - ">="
|
157
175
|
- !ruby/object:Gem::Version
|
158
176
|
version: 1.12.1
|
159
177
|
description: Low Level Ruby Client for the Crossref Search API
|
@@ -189,7 +207,7 @@ files:
|
|
189
207
|
- lib/serrano/utils.rb
|
190
208
|
- lib/serrano/version.rb
|
191
209
|
- serrano.gemspec
|
192
|
-
homepage:
|
210
|
+
homepage: https://github.com/sckott/serrano
|
193
211
|
licenses:
|
194
212
|
- MIT
|
195
213
|
metadata: {}
|
@@ -209,7 +227,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
209
227
|
version: '0'
|
210
228
|
requirements: []
|
211
229
|
rubyforge_project:
|
212
|
-
rubygems_version: 2.6.
|
230
|
+
rubygems_version: 2.6.6
|
213
231
|
signing_key:
|
214
232
|
specification_version: 4
|
215
233
|
summary: Crossref Client
|