serrano 0.0.7 → 0.1.1
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/.gitignore +3 -1
- data/CHANGELOG.md +12 -0
- data/CONDUCT.md +6 -6
- data/Gemfile.lock +1 -1
- data/README.md +10 -5
- data/Rakefile +1 -1
- data/bin/serrano +444 -0
- data/lib/serrano.rb +86 -50
- data/lib/serrano/version.rb +1 -1
- data/serrano.gemspec +4 -1
- metadata +6 -4
- data/NEWS.md +0 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7fa7f1bc525d14c6f53869ed4288b8579158ce73
|
4
|
+
data.tar.gz: ab896db087318532f052e43a930ba1e1be3f3943
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 934c68640bfabef4df7e91898406a0948a395c1ef3f0cf1c5d04aa8e32108836a909e90427d2e93ff0a75767fcade878f4119c1f6ee8d15012473664a6aa85bb
|
7
|
+
data.tar.gz: 45437444480642e2b48cb6b11a33b9dbc60277f62eb50cfc48aab90a5847aa21dc1fdb4e71a8fac870ca4fc9b541d0a118406fb30a3d033d784537dd63af9a92
|
data/.gitignore
CHANGED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
## 0.1.0 (2015-11-17)
|
2
|
+
|
3
|
+
* Improved documentation
|
4
|
+
* `licenses()` loses `ids` param as it doesn't accept IDs
|
5
|
+
* `agency()` method changed to `registration_agency()`
|
6
|
+
* `cn()` method changed to `content_negotiation()`
|
7
|
+
* `random_dois()` gains default value of `sample = 10`
|
8
|
+
* New method `get_styles()` to get CSL styles
|
9
|
+
|
10
|
+
## 0.0.7 (2015-11-04)
|
11
|
+
|
12
|
+
* First version to Rubygems
|
data/CONDUCT.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# Contributor Code of Conduct
|
2
2
|
|
3
|
-
As contributors and maintainers of this project, we pledge to respect all people who
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who
|
4
4
|
contribute through reporting issues, posting feature requests, updating documentation,
|
5
5
|
submitting pull requests or patches, and other activities.
|
6
6
|
|
@@ -13,13 +13,13 @@ imagery, derogatory comments or personal attacks, trolling, public or private ha
|
|
13
13
|
insults, or other unprofessional conduct.
|
14
14
|
|
15
15
|
Project maintainers have the right and responsibility to remove, edit, or reject comments,
|
16
|
-
commits, code, wiki edits, issues, and other contributions that are not aligned to this
|
17
|
-
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
|
16
|
+
commits, code, wiki edits, issues, and other contributions that are not aligned to this
|
17
|
+
Code of Conduct. Project maintainers who do not follow the Code of Conduct may be removed
|
18
18
|
from the project team.
|
19
19
|
|
20
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
|
20
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
|
21
21
|
opening an issue or contacting one or more of the project maintainers.
|
22
22
|
|
23
|
-
This Code of Conduct is adapted from the Contributor Covenant
|
24
|
-
(http:contributor-covenant.org), version 1.0.0, available at
|
23
|
+
This Code of Conduct is adapted from the Contributor Covenant
|
24
|
+
(http:contributor-covenant.org), version 1.0.0, available at
|
25
25
|
http://contributor-covenant.org/version/1/0/0/
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
serrano
|
2
2
|
=========
|
3
3
|
|
4
|
+
[](https://rubygems.org/gems/serrano)
|
4
5
|
[](https://travis-ci.org/sckott/serrano)
|
5
6
|
[](http://codecov.io/github/sckott/serrano?branch=master)
|
6
7
|
|
7
8
|
`serrano` is a low level client for Crossref APIs
|
8
9
|
|
9
|
-
Docs: http://
|
10
|
+
Docs: http://www.rubydoc.info/gems/serrano
|
10
11
|
|
11
12
|
Other Crossref API clients:
|
12
13
|
|
@@ -15,7 +16,7 @@ Other Crossref API clients:
|
|
15
16
|
|
16
17
|
## Changes
|
17
18
|
|
18
|
-
For changes see the [
|
19
|
+
For changes see the [Changelog](CHANGELOG.md)
|
19
20
|
|
20
21
|
## API
|
21
22
|
|
@@ -31,13 +32,15 @@ Methods in relation to [Crossref search API][crapi] routes
|
|
31
32
|
|
32
33
|
Additional methods built on top of the Crossref search API:
|
33
34
|
|
34
|
-
* DOI minting agency - `Serrano.
|
35
|
+
* DOI minting agency - `Serrano.registration_agency()`
|
35
36
|
* Get random DOIs - `Serrano.random_dois()`
|
36
37
|
|
37
38
|
Other methods:
|
38
39
|
|
39
|
-
* [Conent negotiation][cn] - `Serrano.
|
40
|
+
* [Conent negotiation][cn] - `Serrano.content_negotiation()`
|
40
41
|
* [Text and data mining][tdm] - `Serrano.text()`
|
42
|
+
* [Citation count][ccount] - `Serrano.citation_count()`
|
43
|
+
* [get CSL styles][csl] - `Serrano.csl_styles()`
|
41
44
|
|
42
45
|
## Install
|
43
46
|
|
@@ -97,7 +100,7 @@ Serrano.funders(ids: ['10.13039/100000001','10.13039/100000015'])
|
|
97
100
|
Get agency for a set of DOIs
|
98
101
|
|
99
102
|
```ruby
|
100
|
-
Serrano.
|
103
|
+
Serrano.registration_agency(ids: ['10.1007/12080.1874-1746','10.1007/10452.1573-5125'])
|
101
104
|
```
|
102
105
|
|
103
106
|
Get random set of DOIs
|
@@ -126,3 +129,5 @@ res = Serrano.text(url: 'http://...');
|
|
126
129
|
[crapi]: https://github.com/CrossRef/rest-api-doc/blob/master/rest_api.md
|
127
130
|
[cn]: http://www.crosscite.org/cn/
|
128
131
|
[tdm]: http://www.crossref.org/tdm/
|
132
|
+
[ccount]: http://labs.crossref.org/openurl/
|
133
|
+
[csl]: https://github.com/citation-style-language/styles
|
data/Rakefile
CHANGED
data/bin/serrano
ADDED
@@ -0,0 +1,444 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "serrano"
|
5
|
+
require "multi_json"
|
6
|
+
|
7
|
+
class Sr < Thor
|
8
|
+
include Thor::Actions
|
9
|
+
# class_option :json, :type => :boolean, :default => false
|
10
|
+
|
11
|
+
desc "works [DOIs]", "Get works by DOIs"
|
12
|
+
long_desc <<-LONGDESC
|
13
|
+
`serrano works` accepts one or more DOIs to search for works
|
14
|
+
|
15
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
16
|
+
|
17
|
+
# A single DOI
|
18
|
+
\x5$ serrano works 10.1371/journal.pone.0033693
|
19
|
+
|
20
|
+
DOI: 10.1371/journal.pone.0033693
|
21
|
+
\x5type: journal-article
|
22
|
+
\x5title: Methylphenidate Exposure Induces Dopamine Neuron Loss and Activation of Microglia in the Basal Ganglia of Mice
|
23
|
+
|
24
|
+
# Many DOIs
|
25
|
+
\x5$ serrano works "10.1007/12080.1874-1746,10.1007/10452.1573-5125"
|
26
|
+
|
27
|
+
DOI: 10.1007/12080.1874-1746
|
28
|
+
\x5type: journal
|
29
|
+
\x5title: Theoretical Ecology
|
30
|
+
|
31
|
+
DOI: 10.1007/10452.1573-5125
|
32
|
+
\x5type: journal
|
33
|
+
\x5title: Aquatic Ecology
|
34
|
+
|
35
|
+
# Verbose output gives JSON, pipe onwards, e.g., parse with jq
|
36
|
+
\x5$ serrano works "10.1371/journal.pone.0033693,10.1007/12080.1874-1746,10.1007/10452.1573-5125" --json=true | jq .[].message.member
|
37
|
+
|
38
|
+
"http://id.crossref.org/member/340"
|
39
|
+
\x5"http://id.crossref.org/member/297"
|
40
|
+
\x5"http://id.crossref.org/member/297"
|
41
|
+
LONGDESC
|
42
|
+
option :json, :type => :boolean, :default => false
|
43
|
+
def works(*dois)
|
44
|
+
out = Serrano.works(ids: dois)
|
45
|
+
if !options[:json]
|
46
|
+
out = out.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
|
47
|
+
out.each do |x|
|
48
|
+
puts 'DOI: ' + x['DOI'].to_s
|
49
|
+
puts 'type: ' + x['type']
|
50
|
+
puts 'title: ' + x['title'][0]
|
51
|
+
puts
|
52
|
+
end
|
53
|
+
else
|
54
|
+
puts MultiJson.encode(out)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
desc "members [member IDs]", "Get members by id"
|
59
|
+
long_desc <<-LONGDESC
|
60
|
+
`serrano members` accepts one or more Crossref member IDs
|
61
|
+
|
62
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
63
|
+
|
64
|
+
$ serrano members 98
|
65
|
+
|
66
|
+
id: 98
|
67
|
+
\x5title: Hindawi Publishing Corporation
|
68
|
+
|
69
|
+
$ serrano members "98,340"
|
70
|
+
|
71
|
+
id: 98
|
72
|
+
\x5title: Hindawi Publishing Corporation
|
73
|
+
|
74
|
+
id: 340
|
75
|
+
\x5title: Public Library of Science (PLoS)
|
76
|
+
|
77
|
+
$ serrano members "98,340,45,311,78" --json=true | jq .[].message.coverage.\"resource-links-current\"
|
78
|
+
|
79
|
+
1 0 0 0.8311812281608582 0.985091507434845
|
80
|
+
|
81
|
+
$ serrano members 98 --works=true --json=true | jq .[].message.items[].\"reference-count\"
|
82
|
+
|
83
|
+
24 7 45 31 22 67 72 17 53 75 0 68 12 16 50 79 40 18 40 195
|
84
|
+
LONGDESC
|
85
|
+
option :json, :type => :boolean, :default => false
|
86
|
+
option :query, :type => :string, :default => nil
|
87
|
+
option :limit, :type => :numeric, :default => nil
|
88
|
+
option :works, :type => :boolean, :default => false
|
89
|
+
def members(ids=nil)
|
90
|
+
if ids.nil?
|
91
|
+
out = Serrano.members(query: options[:query], limit: options[:limit],
|
92
|
+
works: options[:works])
|
93
|
+
else
|
94
|
+
out = Serrano.members(ids: ids.split(","), query: options[:query], limit: options[:limit],
|
95
|
+
works: options[:works])
|
96
|
+
end
|
97
|
+
|
98
|
+
if !options[:json]
|
99
|
+
if !options[:works]
|
100
|
+
if out.class == Hash
|
101
|
+
out = out['message']['items']
|
102
|
+
else
|
103
|
+
out = out.collect { |x| x['message'] }
|
104
|
+
end
|
105
|
+
|
106
|
+
# out = out.collect { |x| x['message'].select { |k,v| k[/id|primary-name/] } }
|
107
|
+
out.each do |x|
|
108
|
+
puts 'id: ' + x['id'].to_s
|
109
|
+
puts 'title: ' + x['primary-name']
|
110
|
+
puts
|
111
|
+
end
|
112
|
+
else
|
113
|
+
print_works(out)
|
114
|
+
end
|
115
|
+
else
|
116
|
+
puts MultiJson.encode(out)
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
desc "prefixes [DOI prefixes]", "Search for prefixes by DOI prefix"
|
122
|
+
long_desc <<-LONGDESC
|
123
|
+
`serrano prefixes` accepts one or more Crossref member IDs
|
124
|
+
|
125
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
126
|
+
|
127
|
+
$ serrano prefixes 10.1016
|
128
|
+
|
129
|
+
member: http://id.crossref.org/member/78
|
130
|
+
\x5name: Elsevier BV
|
131
|
+
\x5prefix: http://id.crossref.org/prefix/10.1016
|
132
|
+
|
133
|
+
$ serrano prefixes "10.1016,10.1371"
|
134
|
+
|
135
|
+
member: http://id.crossref.org/member/78
|
136
|
+
\x5name: Elsevier BV
|
137
|
+
\x5prefix: http://id.crossref.org/prefix/10.1016
|
138
|
+
|
139
|
+
member: http://id.crossref.org/member/340
|
140
|
+
\x5name: Public Library of Science (PLoS)
|
141
|
+
\x5prefix: http://id.crossref.org/prefix/10.1371
|
142
|
+
|
143
|
+
$ serrano prefixes "10.1016,10.1371,10.1023,10.4176,10.1093" --json=true | jq .[].message.name
|
144
|
+
|
145
|
+
"Elsevier BV"
|
146
|
+
\x5"Public Library of Science (PLoS)"
|
147
|
+
\x5"Springer Science + Business Media"
|
148
|
+
\x5"Co-Action Publishing"
|
149
|
+
\x5"Oxford University Press (OUP)"
|
150
|
+
LONGDESC
|
151
|
+
option :json, :type => :boolean, :default => false
|
152
|
+
option :limit, :type => :numeric, :default => nil
|
153
|
+
option :works, :type => :boolean, :default => false
|
154
|
+
def prefixes(ids=nil)
|
155
|
+
if ids.nil?
|
156
|
+
out = Serrano.prefixes(limit: options[:limit], works: options[:works])
|
157
|
+
else
|
158
|
+
out = Serrano.prefixes(ids: ids.split(","), limit: options[:limit],
|
159
|
+
works: options[:works])
|
160
|
+
end
|
161
|
+
|
162
|
+
if !options[:json]
|
163
|
+
if !options[:works]
|
164
|
+
if out.class == Hash
|
165
|
+
out = out['message']['items']
|
166
|
+
else
|
167
|
+
out = out.collect { |x| x['message'] }
|
168
|
+
end
|
169
|
+
|
170
|
+
out.each do |x|
|
171
|
+
puts 'member: ' + x['member']
|
172
|
+
puts 'name: ' + x['name']
|
173
|
+
puts 'prefix: ' + x['prefix']
|
174
|
+
puts
|
175
|
+
end
|
176
|
+
else
|
177
|
+
print_works(out)
|
178
|
+
end
|
179
|
+
else
|
180
|
+
puts MultiJson.encode(out)
|
181
|
+
end
|
182
|
+
end
|
183
|
+
|
184
|
+
desc "funders [funder IDs]", "Search for funders by DOI prefix"
|
185
|
+
long_desc <<-LONGDESC
|
186
|
+
`serrano funders` accepts one or more Crossref funder IDs
|
187
|
+
|
188
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
189
|
+
|
190
|
+
$ serrano funders 100004410
|
191
|
+
|
192
|
+
id: 100004410
|
193
|
+
\x5name: European Molecular Biology Organization
|
194
|
+
\x5location: Germany
|
195
|
+
|
196
|
+
$ serrano funders "10.13039/100000001,10.13039/100000015"
|
197
|
+
|
198
|
+
id: 100000001
|
199
|
+
\x5name: National Science Foundation
|
200
|
+
\x5location: United States
|
201
|
+
|
202
|
+
id: 100000015
|
203
|
+
\x5name: U.S. Department of Energy
|
204
|
+
\x5location: United States
|
205
|
+
|
206
|
+
$ serrano funders "10.13039/100000001,10.13039/100000015" --json=true | jq .[].message.name
|
207
|
+
|
208
|
+
"National Science Foundation"
|
209
|
+
\x5"U.S. Department of Energy"
|
210
|
+
|
211
|
+
$ serrano funders --query=NSF --limit=2
|
212
|
+
|
213
|
+
$ serrano funders 10.13039/100000001 --works=true --limit=2
|
214
|
+
LONGDESC
|
215
|
+
option :json, :type => :boolean, :default => false
|
216
|
+
option :query, :type => :string, :default => nil
|
217
|
+
option :limit, :type => :numeric, :default => nil
|
218
|
+
option :works, :type => :boolean, :default => false
|
219
|
+
def funders(ids=nil)
|
220
|
+
if ids.nil?
|
221
|
+
out = Serrano.funders(query: options[:query], limit: options[:limit],
|
222
|
+
works: options[:works])
|
223
|
+
else
|
224
|
+
out = Serrano.funders(ids: ids.split(","), query: options[:query], limit: options[:limit],
|
225
|
+
works: options[:works])
|
226
|
+
end
|
227
|
+
|
228
|
+
if !options[:json]
|
229
|
+
if !options[:works]
|
230
|
+
if out.class == Hash
|
231
|
+
out = out['message']['items']
|
232
|
+
else
|
233
|
+
out = out.collect { |x| x['message'] }
|
234
|
+
end
|
235
|
+
|
236
|
+
out.each do |x|
|
237
|
+
puts 'id: ' + x['id']
|
238
|
+
puts 'name: ' + x['name']
|
239
|
+
puts 'location: ' + x['location']
|
240
|
+
puts
|
241
|
+
end
|
242
|
+
else
|
243
|
+
print_works(out)
|
244
|
+
end
|
245
|
+
else
|
246
|
+
puts MultiJson.encode(out)
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
|
251
|
+
desc "journals [journal ISSNs]", "Search for journals by ISSNs"
|
252
|
+
long_desc <<-LONGDESC
|
253
|
+
`serrano journals` accepts one or more journal ISSNs
|
254
|
+
|
255
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
256
|
+
|
257
|
+
$ serrano journals 2167-8359
|
258
|
+
|
259
|
+
id: 100004410
|
260
|
+
\x5name: European Molecular Biology Organization
|
261
|
+
\x5location: Germany
|
262
|
+
|
263
|
+
$ serrano journals "1803-2427,2326-4225"
|
264
|
+
|
265
|
+
id: 100000001
|
266
|
+
\x5name: National Science Foundation
|
267
|
+
\x5location: United States
|
268
|
+
|
269
|
+
id: 100000015
|
270
|
+
\x5name: U.S. Department of Energy
|
271
|
+
\x5location: United States
|
272
|
+
|
273
|
+
$ serrano journals "1803-2427,2326-4225" --json=true | jq .[].message.title
|
274
|
+
|
275
|
+
"National Science Foundation"
|
276
|
+
\x5"U.S. Department of Energy"
|
277
|
+
|
278
|
+
$ serrano journals --query=ecology --limit=2
|
279
|
+
|
280
|
+
$ serrano journals 2167-8359 --query=ecology --works=true --limit=2
|
281
|
+
LONGDESC
|
282
|
+
option :json, :type => :boolean, :default => false
|
283
|
+
option :query, :type => :string, :default => nil
|
284
|
+
option :limit, :type => :numeric, :default => nil
|
285
|
+
option :works, :type => :boolean, :default => false
|
286
|
+
def journals(ids=nil)
|
287
|
+
if ids.nil?
|
288
|
+
out = Serrano.journals(query: options[:query], limit: options[:limit],
|
289
|
+
works: options[:works])
|
290
|
+
else
|
291
|
+
out = Serrano.journals(ids: ids.split(","), query: options[:query], limit: options[:limit],
|
292
|
+
works: options[:works])
|
293
|
+
end
|
294
|
+
|
295
|
+
if !options[:json]
|
296
|
+
if !options[:works]
|
297
|
+
if out.class == Hash
|
298
|
+
out = out['message']['items']
|
299
|
+
else
|
300
|
+
out = out.collect { |x| x['message'] }
|
301
|
+
end
|
302
|
+
|
303
|
+
out.each do |x|
|
304
|
+
puts 'ISSN: ' + x['ISSN'][0]
|
305
|
+
puts 'title: ' + x['title']
|
306
|
+
puts 'publisher: ' + x['publisher']
|
307
|
+
puts
|
308
|
+
end
|
309
|
+
else
|
310
|
+
print_works(out)
|
311
|
+
end
|
312
|
+
else
|
313
|
+
puts MultiJson.encode(out)
|
314
|
+
end
|
315
|
+
end
|
316
|
+
|
317
|
+
desc "types [type name]", "Search for types by name"
|
318
|
+
long_desc <<-LONGDESC
|
319
|
+
`serrano types` accepts one or more type names
|
320
|
+
|
321
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
322
|
+
|
323
|
+
$ serrano types journal
|
324
|
+
|
325
|
+
id: 100004410
|
326
|
+
\x5name: European Molecular Biology Organization
|
327
|
+
\x5location: Germany
|
328
|
+
|
329
|
+
$ serrano types journal dissertation
|
330
|
+
|
331
|
+
id: 100000001
|
332
|
+
\x5name: National Science Foundation
|
333
|
+
\x5location: United States
|
334
|
+
|
335
|
+
id: 100000015
|
336
|
+
\x5name: U.S. Department of Energy
|
337
|
+
\x5location: United States
|
338
|
+
|
339
|
+
$ serrano types journal dissertation --json=true | jq .[].message
|
340
|
+
|
341
|
+
"National Science Foundation"
|
342
|
+
\x5"U.S. Department of Energy"
|
343
|
+
|
344
|
+
$ serrano types dissertation --works
|
345
|
+
|
346
|
+
$ serrano types dissertation --works --limit=2
|
347
|
+
LONGDESC
|
348
|
+
option :json, :type => :boolean, :default => false
|
349
|
+
option :works, :type => :boolean, :default => false
|
350
|
+
option :limit, :type => :numeric, :default => nil
|
351
|
+
def types(*ids)
|
352
|
+
out = Serrano.types(ids: ids, limit: options[:limit],
|
353
|
+
works: options[:works])
|
354
|
+
|
355
|
+
if !options[:json]
|
356
|
+
if !options[:works]
|
357
|
+
if out.class == Hash
|
358
|
+
out = out['message']['items']
|
359
|
+
else
|
360
|
+
out = out.collect { |x| x['message'] }
|
361
|
+
end
|
362
|
+
|
363
|
+
out.each do |x|
|
364
|
+
puts 'id: ' + x['id']
|
365
|
+
puts 'label: ' + x['label']
|
366
|
+
puts
|
367
|
+
end
|
368
|
+
else
|
369
|
+
print_works(out)
|
370
|
+
end
|
371
|
+
else
|
372
|
+
puts MultiJson.encode(out)
|
373
|
+
end
|
374
|
+
end
|
375
|
+
|
376
|
+
desc "licenses", "Search for licenses by name"
|
377
|
+
long_desc <<-LONGDESC
|
378
|
+
`serrano licenses` accepts one or more type names
|
379
|
+
|
380
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
381
|
+
|
382
|
+
$ serrano licenses
|
383
|
+
|
384
|
+
url: http://avs.org
|
385
|
+
\x5work-count: 1
|
386
|
+
|
387
|
+
url: http://creativecommons.org/LICENSEs/by/3.0/
|
388
|
+
\x5work-count: 14
|
389
|
+
|
390
|
+
$ serrano licenses --query=creative
|
391
|
+
|
392
|
+
id: 100000001
|
393
|
+
\x5name: National Science Foundation
|
394
|
+
\x5location: United States
|
395
|
+
|
396
|
+
id: 100000015
|
397
|
+
\x5name: U.S. Department of Energy
|
398
|
+
\x5location: United States
|
399
|
+
|
400
|
+
$ serrano licenses --json=true | jq .[].message.items.work-count
|
401
|
+
|
402
|
+
"National Science Foundation"
|
403
|
+
\x5"U.S. Department of Energy"
|
404
|
+
LONGDESC
|
405
|
+
option :json, :type => :boolean, :default => false
|
406
|
+
option :query, :type => :string, :default => nil
|
407
|
+
def licenses
|
408
|
+
out = Serrano.licenses(query: options[:query])
|
409
|
+
if !options[:json]
|
410
|
+
out = out['message']['items']
|
411
|
+
out.each do |x|
|
412
|
+
puts 'url: ' + x['URL']
|
413
|
+
puts 'work-count: ' + x['work-count'].to_s
|
414
|
+
puts
|
415
|
+
end
|
416
|
+
else
|
417
|
+
puts MultiJson.encode(out)
|
418
|
+
end
|
419
|
+
end
|
420
|
+
|
421
|
+
desc "version", "Get serrano version"
|
422
|
+
def version
|
423
|
+
puts Serrano::VERSION
|
424
|
+
end
|
425
|
+
|
426
|
+
private
|
427
|
+
|
428
|
+
def print_works(data)
|
429
|
+
if data.is_a? Array
|
430
|
+
data = data[0]['message']['items']
|
431
|
+
else
|
432
|
+
data = data.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
|
433
|
+
end
|
434
|
+
data.each do |x|
|
435
|
+
puts 'DOI: ' + x['DOI']
|
436
|
+
puts 'type: ' + x['type']
|
437
|
+
puts 'title: ' + x['title'][0]
|
438
|
+
puts
|
439
|
+
end
|
440
|
+
end
|
441
|
+
|
442
|
+
end
|
443
|
+
|
444
|
+
Sr.start(ARGV)
|
data/lib/serrano.rb
CHANGED
@@ -9,7 +9,6 @@ require 'rexml/document'
|
|
9
9
|
require 'rexml/xpath'
|
10
10
|
|
11
11
|
# @!macro serrano_params
|
12
|
-
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
13
12
|
# @param offset [Fixnum] Number of record to start at, from 1 to infinity.
|
14
13
|
# @param limit [Fixnum] Number of results to return. Not relavant when searching with specific dois. Default: 20. Max: 1000
|
15
14
|
# @param sample [Fixnum] Number of random results to return. when you use the sample parameter,
|
@@ -22,6 +21,9 @@ require 'rexml/xpath'
|
|
22
21
|
# will be by DOI update date.
|
23
22
|
# @param order [String] Sort order, one of 'asc' or 'desc'
|
24
23
|
# @param facet [Boolean] Include facet results. Default: false
|
24
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
25
|
+
|
26
|
+
# @!macro serrano_options
|
25
27
|
# @param options [Hash] Hash of options for configuring the request, passed on to Faraday.new
|
26
28
|
# :timeout - [Fixnum] open/read timeout Integer in seconds
|
27
29
|
# :open_timeout - [Fixnum] read timeout Integer in seconds
|
@@ -33,23 +35,26 @@ require 'rexml/xpath'
|
|
33
35
|
# :bind - [Hash] A hash with host and port values
|
34
36
|
# :boundary - [String] of the boundary value
|
35
37
|
# :oauth - [Hash] A hash with OAuth details
|
36
|
-
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
37
38
|
|
38
39
|
##
|
39
40
|
# Serrano - The top level module for using methods
|
40
41
|
# to access Serrano APIs
|
41
42
|
#
|
42
43
|
# The following methods, matching the main Crossref API routes, are available:
|
43
|
-
# * works - Use the /works endpoint
|
44
|
-
# * members - Use the /members endpoint
|
45
|
-
# * prefixes - Use the /prefixes endpoint
|
46
|
-
# * funders - Use the /funders endpoint
|
47
|
-
# * journals - Use the /journals endpoint
|
48
|
-
# * types - Use the /types endpoint
|
49
|
-
# * licenses - Use the /licenses endpoint
|
44
|
+
# * `Serrano.works` - Use the /works endpoint
|
45
|
+
# * `Serrano.members` - Use the /members endpoint
|
46
|
+
# * `Serrano.prefixes` - Use the /prefixes endpoint
|
47
|
+
# * `Serrano.funders` - Use the /funders endpoint
|
48
|
+
# * `Serrano.journals` - Use the /journals endpoint
|
49
|
+
# * `Serrano.types` - Use the /types endpoint
|
50
|
+
# * `Serrano.licenses` - Use the /licenses endpoint
|
50
51
|
#
|
51
52
|
# Additional methods
|
52
|
-
# * agency - test the registration agency for a DOI
|
53
|
+
# * `Serrano.agency` - test the registration agency for a DOI
|
54
|
+
# * `Serrano.content_negotiation` - Conent negotiation
|
55
|
+
# * `Serrano.text` - Text and data mining
|
56
|
+
# * `Serrano.citation_count` - Citation count
|
57
|
+
# * `Serrano.csl_styles` - get CSL styles
|
53
58
|
#
|
54
59
|
# All routes return an array of hashes
|
55
60
|
# For example, if you want to inspect headers returned from the HTTP request,
|
@@ -69,6 +74,8 @@ module Serrano
|
|
69
74
|
# Search the works route
|
70
75
|
#
|
71
76
|
# @!macro serrano_params
|
77
|
+
# @!macro serrano_options
|
78
|
+
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
72
79
|
# @param query [String] A query string
|
73
80
|
# @param filter [Hash] Filter options. See ...
|
74
81
|
# @return [Array] An array of hashes
|
@@ -106,6 +113,8 @@ module Serrano
|
|
106
113
|
# Search the members route
|
107
114
|
#
|
108
115
|
# @!macro serrano_params
|
116
|
+
# @!macro serrano_options
|
117
|
+
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
109
118
|
# @param query [String] A query string
|
110
119
|
# @param filter [Hash] Filter options. See ...
|
111
120
|
# @param works [Boolean] If true, works returned as well. Default: false
|
@@ -136,6 +145,8 @@ module Serrano
|
|
136
145
|
# Search the prefixes route
|
137
146
|
#
|
138
147
|
# @!macro serrano_params
|
148
|
+
# @!macro serrano_options
|
149
|
+
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
139
150
|
# @param filter [Hash] Filter options. See ...
|
140
151
|
# @param works [Boolean] If true, works returned as well. Default: false
|
141
152
|
# @return [Array] An array of hashes
|
@@ -163,6 +174,8 @@ module Serrano
|
|
163
174
|
# Search the funders route
|
164
175
|
#
|
165
176
|
# @!macro serrano_params
|
177
|
+
# @!macro serrano_options
|
178
|
+
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
166
179
|
# @param query [String] A query string
|
167
180
|
# @param filter [Hash] Filter options. See ...
|
168
181
|
# @param works [Boolean] If true, works returned as well. Default: false
|
@@ -171,7 +184,7 @@ module Serrano
|
|
171
184
|
# @example
|
172
185
|
# require 'serrano'
|
173
186
|
# # Search by DOI, one or more
|
174
|
-
# Serrano.funders(ids:
|
187
|
+
# Serrano.funders(ids: 100004410)
|
175
188
|
# Serrano.funders(ids: ['10.13039/100000001','10.13039/100000015'])
|
176
189
|
# # query
|
177
190
|
# Serrano.funders(query: "NSF")
|
@@ -193,6 +206,8 @@ module Serrano
|
|
193
206
|
# Search the journals route
|
194
207
|
#
|
195
208
|
# @!macro serrano_params
|
209
|
+
# @!macro serrano_options
|
210
|
+
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
196
211
|
# @param query [String] A query string
|
197
212
|
# @param filter [Hash] Filter options. See ...
|
198
213
|
# @param works [Boolean] If true, works returned as well. Default: false
|
@@ -224,6 +239,7 @@ module Serrano
|
|
224
239
|
##
|
225
240
|
# Search the types route
|
226
241
|
#
|
242
|
+
# @!macro serrano_options
|
227
243
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
228
244
|
# @param works [Boolean] If true, works returned as well. Default: false
|
229
245
|
# @return [Array] An array of hashes
|
@@ -234,16 +250,18 @@ module Serrano
|
|
234
250
|
# Serrano.types(ids: "journal")
|
235
251
|
# Serrano.types(ids: ["journal", "dissertation"])
|
236
252
|
# Serrano.types(ids: "journal", works: true)
|
237
|
-
def self.types(ids: nil,
|
253
|
+
def self.types(ids: nil, offset: nil,
|
254
|
+
limit: nil, works: false, options: nil, verbose: false)
|
238
255
|
|
239
|
-
Request.new('types', ids, nil, nil,
|
240
|
-
|
256
|
+
Request.new('types', ids, nil, nil, offset,
|
257
|
+
limit, nil, nil, nil, nil, works, nil, options, verbose).perform
|
241
258
|
end
|
242
259
|
|
243
260
|
##
|
244
261
|
# Search the licenses route
|
245
262
|
#
|
246
263
|
# @!macro serrano_params
|
264
|
+
# @!macro serrano_options
|
247
265
|
# @param query [String] A query string
|
248
266
|
# @return [Array] An array of hashes
|
249
267
|
#
|
@@ -252,25 +270,26 @@ module Serrano
|
|
252
270
|
# Serrano.licenses(query: "creative")
|
253
271
|
# Serrano.licenses()
|
254
272
|
# Serrano.licenses(limit: 3)
|
255
|
-
def self.licenses(
|
273
|
+
def self.licenses(query: nil, offset: nil,
|
256
274
|
limit: nil, sample: nil, sort: nil, order: nil,
|
257
275
|
facet: nil, options: nil, verbose: false)
|
258
276
|
|
259
|
-
Request.new('licenses',
|
277
|
+
Request.new('licenses', nil, query, nil, offset,
|
260
278
|
limit, sample, sort, order, facet, nil, nil, options, verbose).perform
|
261
279
|
end
|
262
280
|
|
263
281
|
##
|
264
282
|
# Determine registration agency for DOIs
|
265
283
|
#
|
284
|
+
# @!macro serrano_options
|
266
285
|
# @param ids [Array] DOIs (digital object identifier) or other identifiers
|
267
286
|
# @return [Array] An array of hashes
|
268
287
|
#
|
269
288
|
# @example
|
270
289
|
# require 'serrano'
|
271
|
-
# Serrano.
|
272
|
-
# Serrano.
|
273
|
-
def self.
|
290
|
+
# Serrano.registration_agency(ids: '10.1371/journal.pone.0033693')
|
291
|
+
# Serrano.registration_agency(ids: ['10.1007/12080.1874-1746','10.1007/10452.1573-5125', '10.1111/(issn)1442-9993'])
|
292
|
+
def self.registration_agency(ids:, options: nil, verbose: false)
|
274
293
|
|
275
294
|
Request.new('works', ids, nil, nil, nil,
|
276
295
|
nil, nil, nil, nil, nil, false, true, options, verbose).perform
|
@@ -279,17 +298,21 @@ module Serrano
|
|
279
298
|
##
|
280
299
|
# Get a random set of DOI's
|
281
300
|
#
|
301
|
+
# @!macro serrano_options
|
282
302
|
# @param sample [Fixnum] Number of random DOIs to return
|
303
|
+
# @param verbose [Boolean] Print request headers to stdout. Default: false
|
283
304
|
# @return [Array] A list of strings, each a DOI
|
284
305
|
# @note This method uses {Serrano.works} internally, but doesn't allow you to pass on
|
285
306
|
# arguments to that method.
|
286
307
|
#
|
287
308
|
# @example
|
288
309
|
# require 'serrano'
|
310
|
+
# # by default, gives 10
|
311
|
+
# Serrano.random_dois()
|
289
312
|
# Serrano.random_dois(sample: 1)
|
290
313
|
# Serrano.random_dois(sample: 10)
|
291
314
|
# Serrano.random_dois(sample: 100)
|
292
|
-
def self.random_dois(sample
|
315
|
+
def self.random_dois(sample: 10, options: nil, verbose: false)
|
293
316
|
|
294
317
|
tmp = Request.new('works', nil, nil, nil, nil,
|
295
318
|
nil, sample, nil, nil, nil, false, nil, options, verbose).perform
|
@@ -308,52 +331,54 @@ module Serrano
|
|
308
331
|
# @example
|
309
332
|
# require 'serrano'
|
310
333
|
# # By default, you get bibtex, apa format, in en-US locale
|
311
|
-
# Serrano.
|
334
|
+
# Serrano.content_negotiation(ids: '10.1126/science.169.3946.635')
|
312
335
|
#
|
313
336
|
# # get citeproc-json
|
314
|
-
# Serrano.
|
315
|
-
# Serrano.
|
316
|
-
#
|
317
|
-
#
|
318
|
-
# Serrano.
|
337
|
+
# Serrano.content_negotiation(ids: '10.1126/science.169.3946.635', format: "citeproc-json")
|
338
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "citeproc-json")
|
339
|
+
#
|
340
|
+
# # some other formats
|
341
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "rdf-xml")
|
342
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "crossref-xml")
|
343
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text")
|
319
344
|
#
|
320
345
|
# # return an R bibentry type
|
321
|
-
# Serrano.
|
322
|
-
# Serrano.
|
346
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "bibentry")
|
347
|
+
# Serrano.content_negotiation(ids: "10.6084/m9.figshare.97218", format: "bibentry")
|
323
348
|
#
|
324
349
|
# # return an apa style citation
|
325
|
-
# Serrano.
|
326
|
-
# Serrano.
|
327
|
-
# Serrano.
|
328
|
-
# Serrano.
|
329
|
-
# Serrano.
|
330
|
-
# Serrano.
|
350
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text", style: "apa")
|
351
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text", style: "harvard3")
|
352
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text", style: "elsevier-harvard")
|
353
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text", style: "ecoscience")
|
354
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text", style: "heredity")
|
355
|
+
# Serrano.content_negotiation(ids: "10.1126/science.169.3946.635", format: "text", style: "oikos")
|
331
356
|
#
|
332
357
|
# # example with many DOIs
|
333
|
-
# dois
|
334
|
-
# Serrano.
|
358
|
+
# dois = cr_r(2)
|
359
|
+
# Serrano.content_negotiation(dois, format: "text", style: "apa")
|
335
360
|
#
|
336
361
|
# # Using DataCite DOIs
|
337
362
|
# ## some formats don't work
|
338
|
-
# # Serrano.
|
339
|
-
# # Serrano.
|
340
|
-
# # Serrano.
|
363
|
+
# # Serrano.content_negotiation(ids: "10.5284/1011335", format: "text")
|
364
|
+
# # Serrano.content_negotiation(ids: "10.5284/1011335", format: "crossref-xml")
|
365
|
+
# # Serrano.content_negotiation(ids: "10.5284/1011335", format: "crossref-tdm")
|
341
366
|
#
|
342
367
|
# ## But most do work
|
343
|
-
# Serrano.
|
344
|
-
# Serrano.
|
345
|
-
# Serrano.
|
346
|
-
# Serrano.
|
347
|
-
# Serrano.
|
348
|
-
# Serrano.
|
349
|
-
# Serrano.
|
350
|
-
# Serrano.
|
368
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "datacite-xml")
|
369
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "rdf-xml")
|
370
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "turtle")
|
371
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "citeproc-json")
|
372
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "ris")
|
373
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "bibtex")
|
374
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "bibentry")
|
375
|
+
# Serrano.content_negotiation(ids: "10.5284/1011335", format: "bibtex")
|
351
376
|
#
|
352
377
|
# # many DOIs
|
353
378
|
# dois = ['10.5167/UZH-30455','10.5167/UZH-49216','10.5167/UZH-503', '10.5167/UZH-38402','10.5167/UZH-41217']
|
354
|
-
# x = Serrano.
|
379
|
+
# x = Serrano.content_negotiation(ids: dois)
|
355
380
|
# puts x
|
356
|
-
def self.
|
381
|
+
def self.content_negotiation(ids:, format: "bibtex", style: 'apa', locale: "en-US")
|
357
382
|
CNRequest.new(ids, format, style, locale).perform
|
358
383
|
end
|
359
384
|
|
@@ -410,8 +435,9 @@ module Serrano
|
|
410
435
|
Miner.new(url, type).perform
|
411
436
|
end
|
412
437
|
|
413
|
-
#
|
438
|
+
# Get a citation count with a DOI
|
414
439
|
#
|
440
|
+
# @!macro serrano_options
|
415
441
|
# @param doi [String] DOI, digital object identifier
|
416
442
|
# @param url [String] the API url for the function (should be left to default)
|
417
443
|
# @param key [String] your API key
|
@@ -437,4 +463,14 @@ module Serrano
|
|
437
463
|
return value
|
438
464
|
end
|
439
465
|
|
466
|
+
# Get csl styles
|
467
|
+
#
|
468
|
+
# @see https://github.com/citation-style-language/styles
|
469
|
+
#
|
470
|
+
# @example
|
471
|
+
# Serrano.csl_styles
|
472
|
+
def self.csl_styles
|
473
|
+
get_styles()
|
474
|
+
end
|
475
|
+
|
440
476
|
end
|
data/lib/serrano/version.rb
CHANGED
data/serrano.gemspec
CHANGED
@@ -8,7 +8,7 @@ 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 = '2015-11-
|
11
|
+
s.date = '2015-11-17'
|
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"
|
@@ -19,6 +19,9 @@ Gem::Specification.new do |s|
|
|
19
19
|
s.files = `git ls-files -z`.split("\x0").reject {|f| f.match(%r{^(test|spec|features)/}) }
|
20
20
|
s.require_paths = ["lib"]
|
21
21
|
|
22
|
+
s.bindir = 'bin'
|
23
|
+
s.executables = ['serrano']
|
24
|
+
|
22
25
|
s.add_development_dependency "bundler", '~> 1.6'
|
23
26
|
s.add_development_dependency "rake", '~> 10.4'
|
24
27
|
s.add_development_dependency "test-unit", '~> 3.1'
|
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.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Scott Chamberlain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-11-
|
11
|
+
date: 2015-11-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -198,19 +198,21 @@ dependencies:
|
|
198
198
|
version: 2.1.5
|
199
199
|
description: Low Level Ruby Client for the Crossref Search API
|
200
200
|
email: myrmecocystus@gmail.com
|
201
|
-
executables:
|
201
|
+
executables:
|
202
|
+
- serrano
|
202
203
|
extensions: []
|
203
204
|
extra_rdoc_files: []
|
204
205
|
files:
|
205
206
|
- ".gitignore"
|
206
207
|
- ".travis.yml"
|
208
|
+
- CHANGELOG.md
|
207
209
|
- CONDUCT.md
|
208
210
|
- Gemfile
|
209
211
|
- Gemfile.lock
|
210
212
|
- LICENSE
|
211
|
-
- NEWS.md
|
212
213
|
- README.md
|
213
214
|
- Rakefile
|
215
|
+
- bin/serrano
|
214
216
|
- lib/serrano.rb
|
215
217
|
- lib/serrano/cn.rb
|
216
218
|
- lib/serrano/cnrequest.rb
|
data/NEWS.md
DELETED