arvados-cli 0.1.20140117103233 → 0.1.20140127131755

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/bin/arv +64 -36
  3. metadata +103 -134
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 70b66c41cd68bee38374544c42e1aa3f0ce48ce8
4
+ data.tar.gz: 70a9c5b4e4bd49af7ad8329369ba1de5d99f828e
5
+ SHA512:
6
+ metadata.gz: b34407028dfdc9492b41b057a0e729ef3674cda5f496e88045d694313d8c56bbbf0bdd551558a22dedadd7d8e74e9d39c946967f6d4a7fe2232d83450e6155aa
7
+ data.tar.gz: 9d0b7e520f0107c735854e0478de8b3499491d528209c645a5d751d92e834bbeee6aa1be3287482f85aecd78f0c60a523288fe58d9ea0828f342dd8a48b2d2d5
data/bin/arv CHANGED
@@ -4,6 +4,8 @@
4
4
  #
5
5
  # Ward Vandewege <ward@clinicalfuture.com>
6
6
 
7
+ require 'fileutils'
8
+
7
9
  if RUBY_VERSION < '1.9.3' then
8
10
  abort <<-EOS
9
11
  #{$0.gsub(/^\.\//,'')} requires Ruby version 1.9.3 or higher.
@@ -12,7 +14,7 @@ end
12
14
 
13
15
  # read authentication data from ~/.config/arvados if present
14
16
  lineno = 0
15
- config_file = File.expand_path('~/.config/arvados')
17
+ config_file = File.expand_path('~/.config/arvados/settings.conf')
16
18
  if File.exist? config_file then
17
19
  File.open(config_file, 'r').each do |line|
18
20
  lineno = lineno + 1
@@ -116,15 +118,23 @@ end
116
118
 
117
119
  class Google::APIClient
118
120
  def discovery_document(api, version)
119
- api = api.to_s
120
- return @discovery_documents["#{api}:#{version}"] ||= (begin
121
- response = self.execute!(
122
- :http_method => :get,
123
- :uri => self.discovery_uri(api, version),
124
- :authenticated => false
125
- )
126
- response.body.class == String ? JSON.parse(response.body) : response.body
127
- end)
121
+ api = api.to_s
122
+ return @discovery_documents["#{api}:#{version}"] ||=
123
+ begin
124
+ # fetch new API discovery doc if stale
125
+ cached_doc = File.expand_path '~/.cache/arvados/discovery_uri.json'
126
+ if not File.exist?(cached_doc) or (Time.now - File.mtime(cached_doc)) > 86400
127
+ response = self.execute!(:http_method => :get,
128
+ :uri => self.discovery_uri(api, version),
129
+ :authenticated => false)
130
+ FileUtils.makedirs(File.dirname cached_doc)
131
+ File.open(cached_doc, 'w') do |f|
132
+ f.puts response.body
133
+ end
134
+ end
135
+
136
+ File.open(cached_doc) { |f| JSON.load f }
137
+ end
128
138
  end
129
139
  end
130
140
 
@@ -152,7 +162,10 @@ def help_methods(discovery_document, resource, method=nil)
152
162
  discovery_document["resources"][resource.pluralize]["methods"].
153
163
  each do |k,v|
154
164
  description = ''
155
- description = ' ' + v["description"] if v.include?("description")
165
+ if v.include? "description"
166
+ # add only the first line of the discovery doc description
167
+ description = ' ' + v["description"].split("\n").first.chomp
168
+ end
156
169
  banner += " #{sprintf("%20s",k)}#{description}\n"
157
170
  end
158
171
  banner += "\n"
@@ -171,9 +184,10 @@ def help_resources(discovery_document, resource)
171
184
  banner += "\n\n"
172
185
  discovery_document["resources"].each do |k,v|
173
186
  description = ''
174
- if discovery_document["schemas"].include?(k.singularize.capitalize) and
175
- discovery_document["schemas"][k.singularize.capitalize].include?('description') then
176
- description = ' ' + discovery_document["schemas"][k.singularize.capitalize]["description"]
187
+ resource_info = discovery_document["schemas"][k.singularize.capitalize]
188
+ if resource_info and resource_info.include?('description')
189
+ # add only the first line of the discovery doc description
190
+ description = ' ' + resource_info["description"].split("\n").first.chomp
177
191
  end
178
192
  banner += " #{sprintf("%30s",k.singularize)}#{description}\n"
179
193
  end
@@ -188,25 +202,37 @@ end
188
202
 
189
203
  def parse_arguments(discovery_document)
190
204
  resource_types = Array.new()
191
- resource_types << '--help'
192
205
  discovery_document["resources"].each do |k,v|
193
206
  resource_types << k.singularize
194
207
  end
195
208
 
196
209
  global_opts = Trollop::options do
197
- banner "arvados cli client"
210
+ version __FILE__
211
+ banner "arv: the Arvados CLI tool"
198
212
  opt :dry_run, "Don't actually do anything", :short => "-n"
199
- opt :verbose, "Print some things on stderr", :short => "-v"
200
- opt :uuid, "Return the UUIDs of the objects in the response, one per line (default)", :short => nil
201
- opt :json, "Return the entire response received from the API server, as a JSON object", :short => "-j"
202
- opt :human, "Return the response received from the API server, as a JSON object with whitespace added for human consumption", :short => "-h"
203
- opt :pretty, "Synonym of --human", :short => nil
204
- opt :yaml, "Return the response received from the API server, in YAML format", :short => "-y"
213
+ opt :verbose, "Print some things on stderr"
214
+ opt :format,
215
+ "Set the output format. Must be one of json (default), yaml or uuid.",
216
+ :type => :string,
217
+ :default => 'json'
218
+ opt :short, "Return only UUIDs (equivalent to --format=uuid)"
219
+ opt :resources, "Display list of resources known to this Arvados instance."
220
+ conflicts :short, :format
205
221
  stop_on resource_types
206
222
  end
207
-
223
+
224
+ unless %w(json yaml uuid).include?(global_opts[:format])
225
+ $stderr.puts "#{$0}: --format must be one of json, yaml or uuid."
226
+ $stderr.puts "Use #{$0} --help for more information."
227
+ abort
228
+ end
229
+
230
+ if global_opts[:short]
231
+ global_opts[:format] = 'uuid'
232
+ end
233
+
208
234
  resource = ARGV.shift
209
- if resource == '--help' or not resource_types.include?(resource)
235
+ if global_opts[:resources] or not resource_types.include?(resource)
210
236
  help_resources(discovery_document, resource)
211
237
  end
212
238
 
@@ -244,7 +270,6 @@ def parse_arguments(discovery_document)
244
270
  required: is_required,
245
271
  type: :string
246
272
  }
247
- discovered_params[resource.to_sym] = body_object
248
273
  end
249
274
  end
250
275
 
@@ -323,18 +348,21 @@ if results["errors"] then
323
348
  abort "Error: #{results["errors"][0]}"
324
349
  end
325
350
 
326
- if global_opts[:human] or global_opts[:pretty] then
351
+ case global_opts[:format]
352
+ when 'json'
327
353
  puts Oj.dump(results, :indent => 1)
328
- elsif global_opts[:yaml] then
354
+ when 'yaml'
329
355
  puts results.to_yaml
330
- elsif global_opts[:json] then
331
- puts Oj.dump(results)
332
- elsif results["items"] and results["kind"].match /list$/i
333
- results['items'].each do |i| puts i['uuid'] end
334
- elsif results['uuid'].nil?
335
- abort("Response did not include a uuid:\n" +
336
- Oj.dump(results, :indent => 1) +
337
- "\n")
338
356
  else
339
- puts results['uuid']
357
+ if results["items"] and results["kind"].match /list$/i
358
+ results['items'].each do |i| puts i['uuid'] end
359
+ elsif results['uuid'].nil?
360
+ abort("Response did not include a uuid:\n" +
361
+ Oj.dump(results, :indent => 1) +
362
+ "\n")
363
+ else
364
+ puts results['uuid']
365
+ end
340
366
  end
367
+
368
+
metadata CHANGED
@@ -1,181 +1,150 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: arvados-cli
3
- version: !ruby/object:Gem::Version
4
- hash: 40280234206489
5
- prerelease:
6
- segments:
7
- - 0
8
- - 1
9
- - 20140117103233
10
- version: 0.1.20140117103233
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.20140127131755
11
5
  platform: ruby
12
- authors:
6
+ authors:
13
7
  - Arvados Authors
14
8
  autorequire:
15
9
  bindir: bin
16
10
  cert_chain: []
17
-
18
- date: 2014-01-17 00:00:00 Z
19
- dependencies:
20
- - !ruby/object:Gem::Dependency
11
+ date: 2014-01-27 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
21
14
  name: google-api-client
22
- prerelease: false
23
- requirement: &id001 !ruby/object:Gem::Requirement
24
- none: false
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- hash: 1
29
- segments:
30
- - 0
31
- - 6
32
- - 3
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
33
19
  version: 0.6.3
34
20
  type: :runtime
35
- version_requirements: *id001
36
- - !ruby/object:Gem::Dependency
37
- name: activesupport
38
21
  prerelease: false
39
- requirement: &id002 !ruby/object:Gem::Requirement
40
- none: false
41
- requirements:
42
- - - ">="
43
- - !ruby/object:Gem::Version
44
- hash: 21
45
- segments:
46
- - 3
47
- - 2
48
- - 13
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: 0.6.3
27
+ - !ruby/object:Gem::Dependency
28
+ name: activesupport
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '>='
32
+ - !ruby/object:Gem::Version
49
33
  version: 3.2.13
50
34
  type: :runtime
51
- version_requirements: *id002
52
- - !ruby/object:Gem::Dependency
53
- name: json
54
35
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
56
- none: false
57
- requirements:
58
- - - ">="
59
- - !ruby/object:Gem::Version
60
- hash: 5
61
- segments:
62
- - 1
63
- - 7
64
- - 7
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '>='
39
+ - !ruby/object:Gem::Version
40
+ version: 3.2.13
41
+ - !ruby/object:Gem::Dependency
42
+ name: json
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '>='
46
+ - !ruby/object:Gem::Version
65
47
  version: 1.7.7
66
48
  type: :runtime
67
- version_requirements: *id003
68
- - !ruby/object:Gem::Dependency
69
- name: trollop
70
49
  prerelease: false
71
- requirement: &id004 !ruby/object:Gem::Requirement
72
- none: false
73
- requirements:
74
- - - ">="
75
- - !ruby/object:Gem::Version
76
- hash: 3
77
- segments:
78
- - 2
79
- - 0
80
- version: "2.0"
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 1.7.7
55
+ - !ruby/object:Gem::Dependency
56
+ name: trollop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '2.0'
81
62
  type: :runtime
82
- version_requirements: *id004
83
- - !ruby/object:Gem::Dependency
84
- name: andand
85
63
  prerelease: false
86
- requirement: &id005 !ruby/object:Gem::Requirement
87
- none: false
88
- requirements:
89
- - - ">="
90
- - !ruby/object:Gem::Version
91
- hash: 29
92
- segments:
93
- - 1
94
- - 3
95
- - 3
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '>='
67
+ - !ruby/object:Gem::Version
68
+ version: '2.0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: andand
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - '>='
74
+ - !ruby/object:Gem::Version
96
75
  version: 1.3.3
97
76
  type: :runtime
98
- version_requirements: *id005
99
- - !ruby/object:Gem::Dependency
100
- name: oj
101
77
  prerelease: false
102
- requirement: &id006 !ruby/object:Gem::Requirement
103
- none: false
104
- requirements:
105
- - - ">="
106
- - !ruby/object:Gem::Version
107
- hash: 9
108
- segments:
109
- - 2
110
- - 0
111
- - 3
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - '>='
81
+ - !ruby/object:Gem::Version
82
+ version: 1.3.3
83
+ - !ruby/object:Gem::Dependency
84
+ name: oj
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '>='
88
+ - !ruby/object:Gem::Version
112
89
  version: 2.0.3
113
90
  type: :runtime
114
- version_requirements: *id006
115
- - !ruby/object:Gem::Dependency
116
- name: curb
117
91
  prerelease: false
118
- requirement: &id007 !ruby/object:Gem::Requirement
119
- none: false
120
- requirements:
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '>='
95
+ - !ruby/object:Gem::Version
96
+ version: 2.0.3
97
+ - !ruby/object:Gem::Dependency
98
+ name: curb
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
121
101
  - - ~>
122
- - !ruby/object:Gem::Version
123
- hash: 27
124
- segments:
125
- - 0
126
- - 8
127
- version: "0.8"
102
+ - !ruby/object:Gem::Version
103
+ version: '0.8'
128
104
  type: :runtime
129
- version_requirements: *id007
130
- description: This is the Arvados SDK CLI gem, git revision 3055130be14ab26d68fd1c01a934870855ecbd5c
131
- email: gem-dev@clinicalfuture.com
132
- executables:
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '0.8'
111
+ description: This is the Arvados SDK CLI gem, git revision 7c99060e90f027b77c82fd8c66902095197261af
112
+ email: gem-dev@curoverse.com
113
+ executables:
133
114
  - arv
134
115
  - arv-run-pipeline-instance
135
116
  - arv-crunch-job
136
117
  - arv-tag
137
118
  extensions: []
138
-
139
119
  extra_rdoc_files: []
140
-
141
- files:
120
+ files:
142
121
  - bin/arv
143
122
  - bin/arv-run-pipeline-instance
144
123
  - bin/arv-crunch-job
145
124
  - bin/arv-tag
146
125
  - bin/crunch-job
147
126
  homepage: http://arvados.org
148
- licenses:
127
+ licenses:
149
128
  - Apache License, Version 2.0
129
+ metadata: {}
150
130
  post_install_message:
151
131
  rdoc_options: []
152
-
153
- require_paths:
132
+ require_paths:
154
133
  - lib
155
- required_ruby_version: !ruby/object:Gem::Requirement
156
- none: false
157
- requirements:
158
- - - ">="
159
- - !ruby/object:Gem::Version
160
- hash: 3
161
- segments:
162
- - 0
163
- version: "0"
164
- required_rubygems_version: !ruby/object:Gem::Requirement
165
- none: false
166
- requirements:
167
- - - ">="
168
- - !ruby/object:Gem::Version
169
- hash: 3
170
- segments:
171
- - 0
172
- version: "0"
134
+ required_ruby_version: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '>='
137
+ - !ruby/object:Gem::Version
138
+ version: '0'
139
+ required_rubygems_version: !ruby/object:Gem::Requirement
140
+ requirements:
141
+ - - '>='
142
+ - !ruby/object:Gem::Version
143
+ version: '0'
173
144
  requirements: []
174
-
175
145
  rubyforge_project:
176
- rubygems_version: 1.8.24
146
+ rubygems_version: 2.1.11
177
147
  signing_key:
178
- specification_version: 3
148
+ specification_version: 4
179
149
  summary: Arvados SDK CLI
180
150
  test_files: []
181
-