veyor 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +48 -0
- data/.travis.yml +10 -0
- data/CHANGELOG.md +3 -0
- data/CONDUCT.md +25 -0
- data/Gemfile +3 -0
- data/LICENSE +7 -0
- data/README.md +101 -0
- data/Rakefile +41 -0
- data/bin/veyor +478 -0
- data/lib/veyor.rb +206 -0
- data/lib/veyor/error.rb +22 -0
- data/lib/veyor/faraday.rb +71 -0
- data/lib/veyor/helpers/configuration.rb +26 -0
- data/lib/veyor/request.rb +105 -0
- data/lib/veyor/utils.rb +32 -0
- data/lib/veyor/version.rb +3 -0
- data/veyor.gemspec +35 -0
- metadata +213 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 9af12a8a2d696ef54f31265eeff38030f78342fe
|
4
|
+
data.tar.gz: 4edd49130565355ca0a2895a6726b7a17c8e49ee
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: d0b9078a92d929b742606e178f3a459fd9cdfcec3906ea59e8e8e55791607eb5e17fd1a5929f77c9cb628a203504f01731f3599fdc5bd4e8487606ac897b0d3b
|
7
|
+
data.tar.gz: 151a1791a78a89ceb31f6f2dd939a052996baffbe2f76356212bdf7e23a48371c588fd494492e10bbcdc3cf319efeceee22fd9efc65f48f12019257447a7077a
|
data/.gitignore
ADDED
@@ -0,0 +1,48 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
/.config
|
4
|
+
/coverage/
|
5
|
+
/InstalledFiles
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/test/tmp/
|
9
|
+
/test/version_tmp/
|
10
|
+
/tmp/
|
11
|
+
|
12
|
+
## Specific to RubyMotion:
|
13
|
+
.dat*
|
14
|
+
.repl_history
|
15
|
+
build/
|
16
|
+
|
17
|
+
## Documentation cache and generated files:
|
18
|
+
/.yardoc/
|
19
|
+
/.yardopts
|
20
|
+
/_yardoc/
|
21
|
+
/doc/
|
22
|
+
/rdoc/
|
23
|
+
|
24
|
+
## Environment normalisation:
|
25
|
+
/.bundle/
|
26
|
+
/lib/bundler/man/
|
27
|
+
|
28
|
+
# for a library or gem, you might want to ignore these files since the code is
|
29
|
+
# intended to run in multiple environments; otherwise, check them in:
|
30
|
+
#Gemfile.lock
|
31
|
+
.ruby-version
|
32
|
+
.ruby-gemset
|
33
|
+
|
34
|
+
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
35
|
+
.rvmrc
|
36
|
+
|
37
|
+
cache/
|
38
|
+
=======
|
39
|
+
/.bundle/
|
40
|
+
/.yardoc
|
41
|
+
/Gemfile.lock
|
42
|
+
/_yardoc/
|
43
|
+
/coverage/
|
44
|
+
/doc/
|
45
|
+
/pkg/
|
46
|
+
/spec/reports/
|
47
|
+
/tmp/
|
48
|
+
*.gem
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/CONDUCT.md
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
# Contributor Code of Conduct
|
2
|
+
|
3
|
+
As contributors and maintainers of this project, we pledge to respect all people who
|
4
|
+
contribute through reporting issues, posting feature requests, updating documentation,
|
5
|
+
submitting pull requests or patches, and other activities.
|
6
|
+
|
7
|
+
We are committed to making participation in this project a harassment-free experience for
|
8
|
+
everyone, regardless of level of experience, gender, gender identity and expression,
|
9
|
+
sexual orientation, disability, personal appearance, body size, race, ethnicity, age, or religion.
|
10
|
+
|
11
|
+
Examples of unacceptable behavior by participants include the use of sexual language or
|
12
|
+
imagery, derogatory comments or personal attacks, trolling, public or private harassment,
|
13
|
+
insults, or other unprofessional conduct.
|
14
|
+
|
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
|
18
|
+
from the project team.
|
19
|
+
|
20
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by
|
21
|
+
opening an issue or contacting one or more of the project maintainers.
|
22
|
+
|
23
|
+
This Code of Conduct is adapted from the Contributor Covenant
|
24
|
+
(http:contributor-covenant.org), version 1.0.0, available at
|
25
|
+
http://contributor-covenant.org/version/1/0/0/
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (C) 2016 Scott Chamberlain
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,101 @@
|
|
1
|
+
veyor
|
2
|
+
=====
|
3
|
+
|
4
|
+
[![Build Status](https://travis-ci.org/sckott/veyor.svg?branch=master)](https://travis-ci.org/sckott/veyor)
|
5
|
+
[![codecov.io](http://codecov.io/github/sckott/veyor/coverage.svg?branch=master)](http://codecov.io/github/sckott/veyor?branch=master)
|
6
|
+
[![gem version](https://img.shields.io/gem/v/veyor.svg)](https://rubygems.org/gems/veyor)
|
7
|
+
|
8
|
+
`veyor` is a low level client for the [Appveyor API](https://www.appveyor.com/docs/api)
|
9
|
+
|
10
|
+
API docs: <https://www.appveyor.com/docs/api>
|
11
|
+
|
12
|
+
## Installation
|
13
|
+
|
14
|
+
Stable version
|
15
|
+
|
16
|
+
```
|
17
|
+
gem install veyor
|
18
|
+
```
|
19
|
+
|
20
|
+
Development version
|
21
|
+
|
22
|
+
```
|
23
|
+
git clone https://github.com/sckott/veyor.git
|
24
|
+
cd veyor
|
25
|
+
rake install
|
26
|
+
```
|
27
|
+
|
28
|
+
## veyor API
|
29
|
+
|
30
|
+
* `Veyor.project` - get project by name, branch, or build version
|
31
|
+
* `Veyor.projects` - get all projects
|
32
|
+
* `Veyor.project_history` - get project history
|
33
|
+
* `Veyor.project_deployments` - get project deployments
|
34
|
+
* `Veyor.project_settings` - get project settings
|
35
|
+
* `Veyor.build_start` - start a build
|
36
|
+
* `Veyor.build_cancel` - cancel a build
|
37
|
+
|
38
|
+
More to come in future `veyor` versions
|
39
|
+
|
40
|
+
## Changes
|
41
|
+
|
42
|
+
For changes see the [Changelog](https://github.com/sckott/veyor/blob/master/CHANGELOG.md)
|
43
|
+
|
44
|
+
## Usage
|
45
|
+
|
46
|
+
```ruby
|
47
|
+
require 'veyor'
|
48
|
+
```
|
49
|
+
|
50
|
+
### setup
|
51
|
+
|
52
|
+
```ruby
|
53
|
+
Veyor.configuration do |config|
|
54
|
+
config.account_name = "janedoe"
|
55
|
+
config.account_token = "<your token>"
|
56
|
+
end
|
57
|
+
```
|
58
|
+
|
59
|
+
Or store those in env var keys like
|
60
|
+
|
61
|
+
* `ENV['APPVEYOR_ACCOUNT_NAME']`
|
62
|
+
* `ENV['APPVEYOR_API_TOKEN']`
|
63
|
+
|
64
|
+
### get projects
|
65
|
+
|
66
|
+
```ruby
|
67
|
+
Veyor.projects()
|
68
|
+
```
|
69
|
+
|
70
|
+
### get a project by name
|
71
|
+
|
72
|
+
```ruby
|
73
|
+
Veyor.project(project: 'cowsay')
|
74
|
+
```
|
75
|
+
|
76
|
+
### get project history
|
77
|
+
|
78
|
+
```ruby
|
79
|
+
Veyor.project_history(project: 'cowsay')
|
80
|
+
```
|
81
|
+
|
82
|
+
### start a build
|
83
|
+
|
84
|
+
```ruby
|
85
|
+
Veyor.build_start(project: 'cowsay')
|
86
|
+
```
|
87
|
+
|
88
|
+
### cancel a build
|
89
|
+
|
90
|
+
```ruby
|
91
|
+
Veyor.build_cancel(project: 'cowsay', version: '1.0.697')
|
92
|
+
```
|
93
|
+
|
94
|
+
## Contributing
|
95
|
+
|
96
|
+
Bug reports and pull requests are welcome. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Code of Conduct][CONDUCT.md].
|
97
|
+
|
98
|
+
|
99
|
+
## License
|
100
|
+
|
101
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
data/Rakefile
ADDED
@@ -0,0 +1,41 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require 'rake/testtask'
|
3
|
+
|
4
|
+
Rake::TestTask.new do |t|
|
5
|
+
t.libs << "test"
|
6
|
+
t.test_files = FileList['test/test-*.rb']
|
7
|
+
t.verbose = true
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "Run tests"
|
11
|
+
task :default => :test
|
12
|
+
|
13
|
+
desc "Build veyor docs"
|
14
|
+
task :docs do
|
15
|
+
system "yardoc"
|
16
|
+
end
|
17
|
+
|
18
|
+
desc "bundle install"
|
19
|
+
task :bundle do
|
20
|
+
system "bundle install"
|
21
|
+
end
|
22
|
+
|
23
|
+
desc "clean out builds"
|
24
|
+
task :clean do
|
25
|
+
system "ls | grep [0-9].gem | xargs rm"
|
26
|
+
end
|
27
|
+
|
28
|
+
desc "Build veyor"
|
29
|
+
task :build do
|
30
|
+
system "gem build veyor.gemspec"
|
31
|
+
end
|
32
|
+
|
33
|
+
desc "Install veyor"
|
34
|
+
task :install => [:bundle, :build] do
|
35
|
+
system "gem install veyor-#{Veyor::VERSION}.gem"
|
36
|
+
end
|
37
|
+
|
38
|
+
desc "Release to Rubygems"
|
39
|
+
task :release => :build do
|
40
|
+
system "gem push veyor-#{Veyor::VERSION}.gem"
|
41
|
+
end
|
data/bin/veyor
ADDED
@@ -0,0 +1,478 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "thor"
|
4
|
+
require "veyor"
|
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
|
+
`veyor 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$ veyor 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$ veyor 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$ veyor 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
|
+
|
42
|
+
# Filter usage
|
43
|
+
\x5$ veyor works --filter=has_orcid:true --json --limit=4 | jq '.message.items[].author[].ORCID | select(. != null)'
|
44
|
+
|
45
|
+
"http://orcid.org/0000-0003-4087-8021"
|
46
|
+
\x5"http://orcid.org/0000-0002-2076-5452"
|
47
|
+
\x5"http://orcid.org/0000-0003-4087-8021"
|
48
|
+
\x5"http://orcid.org/0000-0002-2076-5452"
|
49
|
+
LONGDESC
|
50
|
+
option :json, :type => :boolean, :default => false
|
51
|
+
option :filter, :type => :hash, :default => nil
|
52
|
+
option :limit, :type => :numeric, :default => nil
|
53
|
+
def works(ids=nil)
|
54
|
+
if ids.nil?
|
55
|
+
out = veyor.works(filter: options[:filter], limit: options[:limit])
|
56
|
+
else
|
57
|
+
out = veyor.works(ids: ids.split(","), filter: options[:filter])
|
58
|
+
end
|
59
|
+
if !options[:json]
|
60
|
+
out = out.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
|
61
|
+
out.each do |x|
|
62
|
+
puts 'DOI: ' + x['DOI'].to_s
|
63
|
+
puts 'type: ' + x['type']
|
64
|
+
puts 'title: ' + x['title'][0]
|
65
|
+
puts
|
66
|
+
end
|
67
|
+
else
|
68
|
+
puts MultiJson.encode(out)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
desc "members [member IDs]", "Get members by id"
|
73
|
+
long_desc <<-LONGDESC
|
74
|
+
`veyor members` accepts one or more Crossref member IDs
|
75
|
+
|
76
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
77
|
+
|
78
|
+
$ veyor members 98
|
79
|
+
|
80
|
+
id: 98
|
81
|
+
\x5title: Hindawi Publishing Corporation
|
82
|
+
|
83
|
+
$ veyor members "98,340"
|
84
|
+
|
85
|
+
id: 98
|
86
|
+
\x5title: Hindawi Publishing Corporation
|
87
|
+
|
88
|
+
id: 340
|
89
|
+
\x5title: Public Library of Science (PLoS)
|
90
|
+
|
91
|
+
$ veyor members "98,340,45,311,78" --json=true | jq .[].message.coverage.\"resource-links-current\"
|
92
|
+
|
93
|
+
1 0 0 0.8311812281608582 0.985091507434845
|
94
|
+
|
95
|
+
$ veyor members 98 --works=true --json=true | jq .[].message.items[].\"reference-count\"
|
96
|
+
|
97
|
+
24 7 45 31 22 67 72 17 53 75 0 68 12 16 50 79 40 18 40 195
|
98
|
+
LONGDESC
|
99
|
+
option :json, :type => :boolean, :default => false
|
100
|
+
option :query, :type => :string, :default => nil
|
101
|
+
option :limit, :type => :numeric, :default => nil
|
102
|
+
option :works, :type => :boolean, :default => false
|
103
|
+
def members(ids=nil)
|
104
|
+
if ids.nil?
|
105
|
+
out = veyor.members(query: options[:query], limit: options[:limit],
|
106
|
+
works: options[:works])
|
107
|
+
else
|
108
|
+
out = veyor.members(ids: ids.split(","), query: options[:query], limit: options[:limit],
|
109
|
+
works: options[:works])
|
110
|
+
end
|
111
|
+
|
112
|
+
if !options[:json]
|
113
|
+
if !options[:works]
|
114
|
+
if out.class == Hash
|
115
|
+
out = out['message']['items']
|
116
|
+
else
|
117
|
+
out = out.collect { |x| x['message'] }
|
118
|
+
end
|
119
|
+
|
120
|
+
# out = out.collect { |x| x['message'].select { |k,v| k[/id|primary-name/] } }
|
121
|
+
out.each do |x|
|
122
|
+
puts 'id: ' + x['id'].to_s
|
123
|
+
puts 'title: ' + x['primary-name']
|
124
|
+
puts
|
125
|
+
end
|
126
|
+
else
|
127
|
+
print_works(out)
|
128
|
+
end
|
129
|
+
else
|
130
|
+
puts MultiJson.encode(out)
|
131
|
+
end
|
132
|
+
end
|
133
|
+
|
134
|
+
|
135
|
+
desc "prefixes [DOI prefixes]", "Search for prefixes by DOI prefix"
|
136
|
+
long_desc <<-LONGDESC
|
137
|
+
`veyor prefixes` accepts one or more Crossref member IDs
|
138
|
+
|
139
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
140
|
+
|
141
|
+
$ veyor prefixes 10.1016
|
142
|
+
|
143
|
+
member: http://id.crossref.org/member/78
|
144
|
+
\x5name: Elsevier BV
|
145
|
+
\x5prefix: http://id.crossref.org/prefix/10.1016
|
146
|
+
|
147
|
+
$ veyor prefixes "10.1016,10.1371"
|
148
|
+
|
149
|
+
member: http://id.crossref.org/member/78
|
150
|
+
\x5name: Elsevier BV
|
151
|
+
\x5prefix: http://id.crossref.org/prefix/10.1016
|
152
|
+
|
153
|
+
member: http://id.crossref.org/member/340
|
154
|
+
\x5name: Public Library of Science (PLoS)
|
155
|
+
\x5prefix: http://id.crossref.org/prefix/10.1371
|
156
|
+
|
157
|
+
$ veyor prefixes "10.1016,10.1371,10.1023,10.4176,10.1093" --json=true | jq .[].message.name
|
158
|
+
|
159
|
+
"Elsevier BV"
|
160
|
+
\x5"Public Library of Science (PLoS)"
|
161
|
+
\x5"Springer Science + Business Media"
|
162
|
+
\x5"Co-Action Publishing"
|
163
|
+
\x5"Oxford University Press (OUP)"
|
164
|
+
LONGDESC
|
165
|
+
option :json, :type => :boolean, :default => false
|
166
|
+
option :limit, :type => :numeric, :default => nil
|
167
|
+
option :works, :type => :boolean, :default => false
|
168
|
+
def prefixes(ids=nil)
|
169
|
+
if ids.nil?
|
170
|
+
out = veyor.prefixes(limit: options[:limit], works: options[:works])
|
171
|
+
else
|
172
|
+
out = veyor.prefixes(ids: ids.split(","), limit: options[:limit],
|
173
|
+
works: options[:works])
|
174
|
+
end
|
175
|
+
|
176
|
+
if !options[:json]
|
177
|
+
if !options[:works]
|
178
|
+
if out.class == Hash
|
179
|
+
out = out['message']['items']
|
180
|
+
else
|
181
|
+
out = out.collect { |x| x['message'] }
|
182
|
+
end
|
183
|
+
|
184
|
+
out.each do |x|
|
185
|
+
puts 'member: ' + x['member']
|
186
|
+
puts 'name: ' + x['name']
|
187
|
+
puts 'prefix: ' + x['prefix']
|
188
|
+
puts
|
189
|
+
end
|
190
|
+
else
|
191
|
+
print_works(out)
|
192
|
+
end
|
193
|
+
else
|
194
|
+
puts MultiJson.encode(out)
|
195
|
+
end
|
196
|
+
end
|
197
|
+
|
198
|
+
desc "funders [funder IDs]", "Search for funders by DOI prefix"
|
199
|
+
long_desc <<-LONGDESC
|
200
|
+
`veyor funders` accepts one or more Crossref funder IDs
|
201
|
+
|
202
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
203
|
+
|
204
|
+
$ veyor funders 100004410
|
205
|
+
|
206
|
+
id: 100004410
|
207
|
+
\x5name: European Molecular Biology Organization
|
208
|
+
\x5location: Germany
|
209
|
+
|
210
|
+
$ veyor funders "10.13039/100000001,10.13039/100000015"
|
211
|
+
|
212
|
+
id: 100000001
|
213
|
+
\x5name: National Science Foundation
|
214
|
+
\x5location: United States
|
215
|
+
|
216
|
+
id: 100000015
|
217
|
+
\x5name: U.S. Department of Energy
|
218
|
+
\x5location: United States
|
219
|
+
|
220
|
+
$ veyor funders "10.13039/100000001,10.13039/100000015" --json=true | jq .[].message.name
|
221
|
+
|
222
|
+
"National Science Foundation"
|
223
|
+
\x5"U.S. Department of Energy"
|
224
|
+
|
225
|
+
$ veyor funders --query=NSF --limit=2
|
226
|
+
|
227
|
+
$ veyor funders 10.13039/100000001 --works=true --limit=2
|
228
|
+
LONGDESC
|
229
|
+
option :json, :type => :boolean, :default => false
|
230
|
+
option :query, :type => :string, :default => nil
|
231
|
+
option :limit, :type => :numeric, :default => nil
|
232
|
+
option :works, :type => :boolean, :default => false
|
233
|
+
def funders(ids=nil)
|
234
|
+
if ids.nil?
|
235
|
+
out = veyor.funders(query: options[:query], limit: options[:limit],
|
236
|
+
works: options[:works])
|
237
|
+
else
|
238
|
+
out = veyor.funders(ids: ids.split(","), query: options[:query], limit: options[:limit],
|
239
|
+
works: options[:works])
|
240
|
+
end
|
241
|
+
|
242
|
+
if !options[:json]
|
243
|
+
if !options[:works]
|
244
|
+
if out.class == Hash
|
245
|
+
out = out['message']['items']
|
246
|
+
else
|
247
|
+
out = out.collect { |x| x['message'] }
|
248
|
+
end
|
249
|
+
|
250
|
+
out.each do |x|
|
251
|
+
puts 'id: ' + x['id']
|
252
|
+
puts 'name: ' + x['name']
|
253
|
+
puts 'location: ' + x['location']
|
254
|
+
puts
|
255
|
+
end
|
256
|
+
else
|
257
|
+
print_works(out)
|
258
|
+
end
|
259
|
+
else
|
260
|
+
puts MultiJson.encode(out)
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
|
265
|
+
desc "journals [journal ISSNs]", "Search for journals by ISSNs"
|
266
|
+
long_desc <<-LONGDESC
|
267
|
+
`veyor journals` accepts one or more journal ISSNs
|
268
|
+
|
269
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
270
|
+
|
271
|
+
$ veyor journals 2167-8359
|
272
|
+
|
273
|
+
id: 100004410
|
274
|
+
\x5name: European Molecular Biology Organization
|
275
|
+
\x5location: Germany
|
276
|
+
|
277
|
+
$ veyor journals "1803-2427,2326-4225"
|
278
|
+
|
279
|
+
id: 100000001
|
280
|
+
\x5name: National Science Foundation
|
281
|
+
\x5location: United States
|
282
|
+
|
283
|
+
id: 100000015
|
284
|
+
\x5name: U.S. Department of Energy
|
285
|
+
\x5location: United States
|
286
|
+
|
287
|
+
$ veyor journals "1803-2427,2326-4225" --json=true | jq .[].message.title
|
288
|
+
|
289
|
+
"National Science Foundation"
|
290
|
+
\x5"U.S. Department of Energy"
|
291
|
+
|
292
|
+
$ veyor journals --query=ecology --limit=2
|
293
|
+
|
294
|
+
$ veyor journals 2167-8359 --query=ecology --works=true --limit=2
|
295
|
+
LONGDESC
|
296
|
+
option :json, :type => :boolean, :default => false
|
297
|
+
option :query, :type => :string, :default => nil
|
298
|
+
option :limit, :type => :numeric, :default => nil
|
299
|
+
option :works, :type => :boolean, :default => false
|
300
|
+
def journals(ids=nil)
|
301
|
+
if ids.nil?
|
302
|
+
out = veyor.journals(query: options[:query], limit: options[:limit],
|
303
|
+
works: options[:works])
|
304
|
+
else
|
305
|
+
out = veyor.journals(ids: ids.split(","), query: options[:query], limit: options[:limit],
|
306
|
+
works: options[:works])
|
307
|
+
end
|
308
|
+
|
309
|
+
if !options[:json]
|
310
|
+
if !options[:works]
|
311
|
+
if out.class == Hash
|
312
|
+
out = out['message']['items']
|
313
|
+
else
|
314
|
+
out = out.collect { |x| x['message'] }
|
315
|
+
end
|
316
|
+
|
317
|
+
out.each do |x|
|
318
|
+
puts 'ISSN: ' + x['ISSN'][0]
|
319
|
+
puts 'title: ' + x['title']
|
320
|
+
puts 'publisher: ' + x['publisher']
|
321
|
+
puts
|
322
|
+
end
|
323
|
+
else
|
324
|
+
print_works(out)
|
325
|
+
end
|
326
|
+
else
|
327
|
+
puts MultiJson.encode(out)
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
desc "types [type name]", "Search for types by name"
|
332
|
+
long_desc <<-LONGDESC
|
333
|
+
`veyor types` accepts one or more type names
|
334
|
+
|
335
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
336
|
+
|
337
|
+
$ veyor types journal
|
338
|
+
|
339
|
+
id: 100004410
|
340
|
+
\x5name: European Molecular Biology Organization
|
341
|
+
\x5location: Germany
|
342
|
+
|
343
|
+
$ veyor types journal dissertation
|
344
|
+
|
345
|
+
id: 100000001
|
346
|
+
\x5name: National Science Foundation
|
347
|
+
\x5location: United States
|
348
|
+
|
349
|
+
id: 100000015
|
350
|
+
\x5name: U.S. Department of Energy
|
351
|
+
\x5location: United States
|
352
|
+
|
353
|
+
$ veyor types journal dissertation --json=true | jq .[].message
|
354
|
+
|
355
|
+
"National Science Foundation"
|
356
|
+
\x5"U.S. Department of Energy"
|
357
|
+
|
358
|
+
$ veyor types dissertation --works
|
359
|
+
|
360
|
+
$ veyor types dissertation --works --limit=2
|
361
|
+
LONGDESC
|
362
|
+
option :json, :type => :boolean, :default => false
|
363
|
+
option :works, :type => :boolean, :default => false
|
364
|
+
option :limit, :type => :numeric, :default => nil
|
365
|
+
def types(*ids)
|
366
|
+
out = veyor.types(ids: ids, limit: options[:limit],
|
367
|
+
works: options[:works])
|
368
|
+
|
369
|
+
if !options[:json]
|
370
|
+
if !options[:works]
|
371
|
+
if out.class == Hash
|
372
|
+
out = out['message']['items']
|
373
|
+
else
|
374
|
+
out = out.collect { |x| x['message'] }
|
375
|
+
end
|
376
|
+
|
377
|
+
out.each do |x|
|
378
|
+
puts 'id: ' + x['id']
|
379
|
+
puts 'label: ' + x['label']
|
380
|
+
puts
|
381
|
+
end
|
382
|
+
else
|
383
|
+
print_works(out)
|
384
|
+
end
|
385
|
+
else
|
386
|
+
puts MultiJson.encode(out)
|
387
|
+
end
|
388
|
+
end
|
389
|
+
|
390
|
+
desc "licenses", "Search for licenses by name"
|
391
|
+
long_desc <<-LONGDESC
|
392
|
+
`veyor licenses` accepts one or more type names
|
393
|
+
|
394
|
+
Toggle `json` to get simplified (summary) or complete output (JSON)
|
395
|
+
|
396
|
+
$ veyor licenses
|
397
|
+
|
398
|
+
url: http://avs.org
|
399
|
+
\x5work-count: 1
|
400
|
+
|
401
|
+
url: http://creativecommons.org/LICENSEs/by/3.0/
|
402
|
+
\x5work-count: 14
|
403
|
+
|
404
|
+
$ veyor licenses --query=creative
|
405
|
+
|
406
|
+
id: 100000001
|
407
|
+
\x5name: National Science Foundation
|
408
|
+
\x5location: United States
|
409
|
+
|
410
|
+
id: 100000015
|
411
|
+
\x5name: U.S. Department of Energy
|
412
|
+
\x5location: United States
|
413
|
+
|
414
|
+
$ veyor licenses --json=true | jq .message.items[]
|
415
|
+
|
416
|
+
"National Science Foundation"
|
417
|
+
\x5"U.S. Department of Energy"
|
418
|
+
LONGDESC
|
419
|
+
option :json, :type => :boolean, :default => false
|
420
|
+
option :query, :type => :string, :default => nil
|
421
|
+
def licenses
|
422
|
+
out = veyor.licenses(query: options[:query])
|
423
|
+
if !options[:json]
|
424
|
+
out = out['message']['items']
|
425
|
+
out.each do |x|
|
426
|
+
puts 'url: ' + x['URL']
|
427
|
+
puts 'work-count: ' + x['work-count'].to_s
|
428
|
+
puts
|
429
|
+
end
|
430
|
+
else
|
431
|
+
puts MultiJson.encode(out)
|
432
|
+
end
|
433
|
+
end
|
434
|
+
|
435
|
+
desc "contneg", "Content negotiation"
|
436
|
+
long_desc <<-LONGDESC
|
437
|
+
`veyor contneg` accepts a DOI
|
438
|
+
|
439
|
+
$ veyor contneg 10.1890/13-0590.1
|
440
|
+
|
441
|
+
Murtaugh, P. A. (2014). In defense of P values . Ecology, 95(3), 611–617. doi:10.1890/13-0590.1
|
442
|
+
|
443
|
+
$ veyor contneg 10.1890/13-0590.1 --style=heredity
|
444
|
+
|
445
|
+
Murtaugh PA (2014). In defense of P values . Ecology 95: 611–617.
|
446
|
+
LONGDESC
|
447
|
+
option :format, :type => :string, :default => "text"
|
448
|
+
option :style, :type => :string, :default => "apa"
|
449
|
+
option :locale, :type => :string, :default => "en-US"
|
450
|
+
def contneg(ids)
|
451
|
+
puts veyor.content_negotiation(ids: ids, format: options[:format], style:
|
452
|
+
options[:style], locale: options[:locale])
|
453
|
+
end
|
454
|
+
|
455
|
+
desc "version", "Get veyor version"
|
456
|
+
def version
|
457
|
+
puts veyor::VERSION
|
458
|
+
end
|
459
|
+
|
460
|
+
private
|
461
|
+
|
462
|
+
def print_works(data)
|
463
|
+
if data.is_a? Array
|
464
|
+
data = data[0]['message']['items']
|
465
|
+
else
|
466
|
+
data = data.collect { |x| x['message'].select { |k,v| k[/DOI|type|title/] } }
|
467
|
+
end
|
468
|
+
data.each do |x|
|
469
|
+
puts 'DOI: ' + x['DOI']
|
470
|
+
puts 'type: ' + x['type']
|
471
|
+
puts 'title: ' + x['title'][0]
|
472
|
+
puts
|
473
|
+
end
|
474
|
+
end
|
475
|
+
|
476
|
+
end
|
477
|
+
|
478
|
+
Sr.start(ARGV)
|