arvados 0.1.20131216133021 → 0.1.20131217081749

Sign up to get free protection for your applications and to get access to all the features.
Files changed (3) hide show
  1. data/lib/arvados.rb +17 -9
  2. metadata +22 -14
  3. checksums.yaml +0 -7
@@ -53,6 +53,7 @@ class Arvados
53
53
  # resource. After this, self.job will return Arvados::Job;
54
54
  # self.job.new() and self.job.find() will do what you want.
55
55
  _arvados = self
56
+ namespace_class = Arvados.const_set "A#{self.object_id}", Class.new
56
57
  self.arvados_api.schemas.each do |classname, schema|
57
58
  next if classname.match /List$/
58
59
  klass = Class.new(Arvados::Model) do
@@ -72,11 +73,10 @@ class Arvados
72
73
  arvados_api.
73
74
  send(classname.underscore.split('/').last.pluralize.to_sym).
74
75
  discovered_methods.
75
- collect(&:name).
76
- each do |method_name|
76
+ each do |method|
77
77
  class << klass; self; end.class_eval do
78
- define_method method_name do |*params|
79
- self.api_exec(method_name.to_sym, *params)
78
+ define_method method.name do |*params|
79
+ self.api_exec(method.name.to_sym, *params)
80
80
  end
81
81
  end
82
82
  end
@@ -89,9 +89,10 @@ class Arvados
89
89
  @api_model_sym = classname.underscore.split('/').last.to_sym
90
90
  end
91
91
 
92
- # This might produce confusing results when using multiple
93
- # Arvados instances.
94
- Arvados.const_set classname, klass
92
+ # Create the new class in namespace_class so it doesn't
93
+ # interfere with classes created by other Arvados objects. The
94
+ # result looks like Arvados::A26949680::Job.
95
+ namespace_class.const_set classname, klass
95
96
 
96
97
  self.class.class_eval do
97
98
  define_method classname.underscore do
@@ -157,8 +158,15 @@ class Arvados
157
158
  resp = JSON.parse result.body, :symbolize_names => true
158
159
  if resp[:errors]
159
160
  raise Arvados::TransactionFailedError.new(resp[:errors])
161
+ elsif resp[:uuid] and resp[:etag]
162
+ self.new(resp)
163
+ elsif resp[:items].is_a? Array
164
+ resp.merge(items: resp[:items].collect do |i|
165
+ self.new(i)
166
+ end)
167
+ else
168
+ resp
160
169
  end
161
- resp
162
170
  end
163
171
 
164
172
  def []=(x,y)
@@ -182,7 +190,7 @@ class Arvados
182
190
  :uuid => @attributes[:uuid],
183
191
  self.class.api_model_sym => @attributes_to_update.to_json
184
192
  }
185
- unless j.is_a? Hash and j[:uuid]
193
+ unless j.respond_to? :[] and j[:uuid]
186
194
  debuglog "Failed to save #{self.to_s}: #{j[:errors] rescue nil}", 0
187
195
  nil
188
196
  else
metadata CHANGED
@@ -1,58 +1,65 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arvados
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.20131216133021
4
+ version: 0.1.20131217081749
5
+ prerelease:
5
6
  platform: ruby
6
7
  authors:
7
8
  - Arvados Authors
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2013-12-16 00:00:00.000000000 Z
12
+ date: 2013-12-17 00:00:00.000000000 Z
12
13
  dependencies:
13
14
  - !ruby/object:Gem::Dependency
14
15
  name: google-api-client
15
16
  requirement: !ruby/object:Gem::Requirement
17
+ none: false
16
18
  requirements:
17
- - - '>='
19
+ - - ! '>='
18
20
  - !ruby/object:Gem::Version
19
21
  version: 0.6.3
20
22
  type: :runtime
21
23
  prerelease: false
22
24
  version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
23
26
  requirements:
24
- - - '>='
27
+ - - ! '>='
25
28
  - !ruby/object:Gem::Version
26
29
  version: 0.6.3
27
30
  - !ruby/object:Gem::Dependency
28
31
  name: activesupport
29
32
  requirement: !ruby/object:Gem::Requirement
33
+ none: false
30
34
  requirements:
31
- - - '>='
35
+ - - ! '>='
32
36
  - !ruby/object:Gem::Version
33
37
  version: 3.2.13
34
38
  type: :runtime
35
39
  prerelease: false
36
40
  version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
37
42
  requirements:
38
- - - '>='
43
+ - - ! '>='
39
44
  - !ruby/object:Gem::Version
40
45
  version: 3.2.13
41
46
  - !ruby/object:Gem::Dependency
42
47
  name: json
43
48
  requirement: !ruby/object:Gem::Requirement
49
+ none: false
44
50
  requirements:
45
- - - '>='
51
+ - - ! '>='
46
52
  - !ruby/object:Gem::Version
47
53
  version: 1.7.7
48
54
  type: :runtime
49
55
  prerelease: false
50
56
  version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
51
58
  requirements:
52
- - - '>='
59
+ - - ! '>='
53
60
  - !ruby/object:Gem::Version
54
61
  version: 1.7.7
55
- description: This is the Arvados SDK gem, git revision 527255236b66380bd50bda0f42e8e4bf56397386
62
+ description: This is the Arvados SDK gem, git revision ac220a417a971f3598c30ac7a10161f6829f5691
56
63
  email: gem-dev@clinicalfuture.com
57
64
  executables: []
58
65
  extensions: []
@@ -62,25 +69,26 @@ files:
62
69
  homepage: http://arvados.org
63
70
  licenses:
64
71
  - Apache License, Version 2.0
65
- metadata: {}
66
72
  post_install_message:
67
73
  rdoc_options: []
68
74
  require_paths:
69
75
  - lib
70
76
  required_ruby_version: !ruby/object:Gem::Requirement
77
+ none: false
71
78
  requirements:
72
- - - '>='
79
+ - - ! '>='
73
80
  - !ruby/object:Gem::Version
74
81
  version: '0'
75
82
  required_rubygems_version: !ruby/object:Gem::Requirement
83
+ none: false
76
84
  requirements:
77
- - - '>='
85
+ - - ! '>='
78
86
  - !ruby/object:Gem::Version
79
87
  version: '0'
80
88
  requirements: []
81
89
  rubyforge_project:
82
- rubygems_version: 2.1.11
90
+ rubygems_version: 1.8.25
83
91
  signing_key:
84
- specification_version: 4
92
+ specification_version: 3
85
93
  summary: Arvados SDK Ruby
86
94
  test_files: []
checksums.yaml DELETED
@@ -1,7 +0,0 @@
1
- ---
2
- SHA1:
3
- metadata.gz: 473d588a0d21ba2ce8329ae2a1e80cd5dd98726b
4
- data.tar.gz: ffba6fc8b9111fbde0bf79d5fd06204f654b325b
5
- SHA512:
6
- metadata.gz: 7612dbb518fc8a73e2eed92b988d0f9680a69135ad9b26ea4130ddc398f031c4e847b748729b54491dc744fad5911da51eb2b381304e9f89e706fa772537354d
7
- data.tar.gz: 2770179cc6eb03dcac86b7c1ec069dc44b535e2bd368cd8aad375591b76ac3698b6f525c57fab16b059577b6f80bcd4910943bed15b27c063607325007d91417