unimatrix 2.5.0 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 818b703de00b58aa52a33b94165e4be237c7bf54
4
- data.tar.gz: 7bc4aa5e5d1e74d78949ba3a4501ed70c34bd99f
3
+ metadata.gz: b136e83e3869e1cfa52d87786415f4810862f620
4
+ data.tar.gz: 6087fc4a9a4bd7f4fac85482bbdf4025eeb41165
5
5
  SHA512:
6
- metadata.gz: 1371e18405d592836491369996b54626ba1932b87a6f89ffcbad5526ab5bcb08fbe18a76d0663b4c485ce17c499261d2907cdeee590199d5e25e8ad5043edd6a
7
- data.tar.gz: 2e653deb36ece6e67c67c09283164b251d0b67cde472a3a443793cf4feec87ead1c47cc03670bb17aae6774f270dd9a0a86d5be774ec6b9e99296f9e527c5c13
6
+ metadata.gz: 06e196c7b3700eb625776670bad3a2198313766bcb5d3d024152427b607d5749fb559e17a9d93a4a232a0a2b34a72e5a43d64374ccb052a0da687833c8c9e41a
7
+ data.tar.gz: 98e7997592da6b39ba7bc83e6e8bd70e4750f153be8a35cd959853124dfd93129bb33ea3cf897b184346b9c77d6e4448a569cf38210b7b2b5f4715e76089fb2b
@@ -1,6 +1,6 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
- class ArtifactLocator < Unimatrix::DynamicResource
3
+ class ArtifactLocator < Unimatrix::Resource
4
4
 
5
5
  field :id
6
6
  field :uuid
@@ -1,6 +1,6 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
- class ArtifactRelationship < Unimatrix::DynamicResource
3
+ class ArtifactRelationship < Unimatrix::Resource
4
4
 
5
5
  field :id
6
6
  field :uuid
@@ -1,6 +1,6 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
- class BlueprintAttribute < Unimatrix::DynamicResource
3
+ class BlueprintAttribute < Unimatrix::Resource
4
4
 
5
5
  field :id
6
6
  field :uuid
@@ -11,54 +11,52 @@ module Unimatrix
11
11
  cattr_accessor :blueprints
12
12
 
13
13
  def find_blueprint( class_type_name )
14
- blueprint = nil
15
-
16
- self.blueprints.each do | b |
17
- if ( b.resource_type_name == class_type_name ) &&
18
- ( blueprint.nil? || blueprint.realm_uuid.nil? )
19
-
20
- blueprint = b
21
- end
14
+ self.blueprints.detect do | blueprint |
15
+ blueprint.resource_type_name == class_type_name
22
16
  end
23
-
24
- blueprint
25
17
  end
26
18
 
27
- def build( attributes )
19
+ def build( attributes = {}, associations = {} )
20
+ attributes = attributes.transform_keys( &:to_s )
28
21
  blueprint = find_blueprint( attributes[ 'type_name' ] ) rescue nil
29
22
  klass = build_typed_class( attributes, blueprint )
30
- klass.new( attributes ) rescue nil
23
+ klass.new( attributes, associations ) rescue nil
31
24
  end
32
25
 
33
26
  def build_typed_class( attributes, blueprint )
34
- base_class = Class.new( self )
35
- klass = base_class
36
-
27
+
28
+ klass = self
29
+
37
30
  if !blueprint.nil?
31
+
38
32
  module_name = Unimatrix.const_get( self.name.split( '::' )[1].underscore.camelize )
39
- entity_type_name = attributes[ 'type_name' ].camelize + attributes[ 'realm_uuid' ]
40
-
41
- unless module_name.const_defined?( entity_type_name )
42
- klass = module_name.const_set( entity_type_name, base_class )
33
+ entity_class_name = attributes[ 'type_name' ].camelize + attributes[ 'realm_uuid' ]
43
34
 
35
+ unless module_name.const_defined?( entity_class_name )
36
+
37
+ klass = module_name.const_set( entity_class_name, Class.new( self ) )
44
38
  default_attributes = [ "type_name", "relationships", "realm_uuid" ]
45
39
 
46
40
  if blueprint.respond_to?( 'blueprint_attributes' )
47
41
  permitted_attributes = blueprint.blueprint_attributes.map( &:name ) + default_attributes
48
42
 
49
43
  klass.instance_eval do
44
+
50
45
  permitted_attributes.each do | field_name |
51
46
  field field_name.to_sym
52
47
  end
48
+
53
49
  end
54
50
  end
55
51
 
56
52
  else
57
- klass = module_name.const_get( entity_type_name )
53
+ klass = module_name.const_get( entity_class_name )
58
54
  end
55
+
59
56
  end
60
-
57
+
61
58
  klass
59
+
62
60
  end
63
61
  end
64
62
  end
@@ -1,6 +1,6 @@
1
1
  module Unimatrix::Distributor
2
2
 
3
- class ActivityReference < Unimatrix::DynamicResource
3
+ class ActivityReference < Unimatrix::Resource
4
4
  field :id
5
5
  field :type_name
6
6
  field :subject_uuid
@@ -68,6 +68,39 @@ module Unimatrix
68
68
  result
69
69
  end
70
70
 
71
+ def read_in_batches( options = {}, &block )
72
+
73
+ total_limit = @parameters[ :count ]
74
+ start = @parameters[ :offset ] || 0
75
+ batch_size = options[ :batch_size ] || 100
76
+
77
+ while total_limit.nil? || start < total_limit
78
+
79
+ result = nil
80
+ response = nil
81
+ operation = self.limit( batch_size ).offset( start )
82
+
83
+ operation.read do | _result, _response |
84
+ result = _result
85
+ response = _response
86
+ end
87
+
88
+ unlimited_count = response.body[ '$this' ][ 'unlimited_count' ]
89
+ total_limit = unlimited_count if total_limit.nil? && !unlimited_count.nil?
90
+ start += batch_size
91
+
92
+ if block_given?
93
+ case block.arity
94
+ when 0; yield
95
+ when 1; yield result
96
+ when 2; yield result, response
97
+ end
98
+ end
99
+ break if result.nil? || result.size < batch_size
100
+ end
101
+
102
+ end
103
+
71
104
  def write( node, objects, &block )
72
105
  result = nil
73
106
  Request.new.tap do | request |
@@ -69,7 +69,7 @@ module Unimatrix
69
69
  if resource_class.present?
70
70
  relations = name == self.name ?
71
71
  self.parse_associations( attributes ) : []
72
- resource = resource_class.new( attributes, relations )
72
+ resource = resource_class.build( attributes, relations )
73
73
  end
74
74
 
75
75
  end
@@ -95,22 +95,22 @@ module Unimatrix
95
95
 
96
96
  result = nil
97
97
  resource_attributes = resource_attribute_index[ name ][ key ]
98
-
99
- if resource_attributes.present?
100
- parse_nested_attributes( resource_attributes )
101
-
102
- resource_class = find_resource_class_by_type_name(
103
- resource_attributes[ 'type_name' ],
104
- options[ 'type_name' ]
105
- )
106
-
107
- if resource_class.present?
108
- result = resource_class.new(
109
- resource_attributes,
110
- self.resource_associations_by( name, key )
111
- )
98
+
99
+ if resource_attributes.present?
100
+
101
+ parse_nested_attributes( resource_attributes )
102
+
103
+ resource_class = find_resource_class_by_type_name(
104
+ resource_attributes[ 'type_name' ],
105
+ options[ 'type_name' ]
106
+ )
107
+ if resource_class.present?
108
+ result = resource_class.build(
109
+ resource_attributes,
110
+ self.resource_associations_by( name, key )
111
+ )
112
+ end
112
113
  end
113
- end
114
114
 
115
115
  # unlock the resource index for this name/key combination
116
116
  @resource_index_mutex[ name ].delete( key )
@@ -128,7 +128,7 @@ module Unimatrix
128
128
  end
129
129
  resource_class
130
130
  end
131
-
131
+
132
132
  def resource_associations_by( name, key )
133
133
  result = Hash.new { | hash, key | hash[ key ] = [] }
134
134
  associations = self.associations
@@ -3,8 +3,9 @@ module Unimatrix
3
3
  class Resource
4
4
 
5
5
  class << self
6
-
7
- def inherited( subclass )
6
+
7
+ def inherited( subclass )
8
+ @@descendants_by_type_name = nil
8
9
  subclass.nested_fields = {}.merge( self.nested_fields )
9
10
  subclass.fields = {}.merge( self.fields )
10
11
  end
@@ -14,7 +15,7 @@ module Unimatrix
14
15
  end
15
16
 
16
17
  def find_by_type_name( type_name )
17
- @descendants_by_type_name = begin
18
+ @@descendants_by_type_name ||= begin
18
19
  result = {}
19
20
  descendants.each do | descendant |
20
21
  descendant_type_name = descendant.type_name
@@ -23,11 +24,11 @@ module Unimatrix
23
24
  end
24
25
  result
25
26
  end
26
- @descendants_by_type_name[ type_name ]
27
+ @@descendants_by_type_name[ type_name ]
27
28
  end
28
29
 
29
- def build( attributes = {} )
30
- new( attributes )
30
+ def build( attributes = {}, associations = {} )
31
+ new( attributes.transform_keys( &:to_s ), associations )
31
32
  end
32
33
 
33
34
  def field( name, options = {} )
@@ -24,7 +24,8 @@ module Unimatrix
24
24
  nested_attributes = value.members
25
25
  nested_attributes.each do | nested_attribute |
26
26
  key = "#{ name }.#{ nested_attribute }"
27
- node_object[ key.to_sym ] = value.send( nested_attribute )
27
+ nested_attribute_value = value.send( nested_attribute )
28
+ node_object[ key.to_sym ] = value.send( nested_attribute ) if value.send( nested_attribute )
28
29
  end
29
30
  else
30
31
  node_object[ name.to_sym ] = value
@@ -1,3 +1,9 @@
1
1
  module Unimatrix
2
- VERSION = "2.5.0"
2
+ VERSION = begin
3
+ version = File.read( File.join( __dir__, "../../VERSION" ) )
4
+ version.scan( /\A.*/ ).first
5
+ rescue
6
+ raise "Error: The Unimatrix SDK VERSION file is missing or invalid."
7
+ exit( 1 )
8
+ end
3
9
  end
data/lib/unimatrix.rb CHANGED
@@ -114,7 +114,6 @@ require 'unimatrix/zephyrus/routing_output'
114
114
  require 'unimatrix/zephyrus/transcoding_output'
115
115
  require 'unimatrix/zephyrus/transcoding_rendition'
116
116
  require 'unimatrix/zephyrus/transcribing_output'
117
- require 'unimatrix/zephyrus/transcribing_rendition'
118
117
  require 'unimatrix/zephyrus/transmutation_output'
119
118
  require 'unimatrix/zephyrus/transmutation_rendition'
120
119
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: unimatrix
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.0
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jackson Souza
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-14 00:00:00.000000000 Z
11
+ date: 2018-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -176,7 +176,6 @@ files:
176
176
  - lib/unimatrix/zephyrus/transcoding_output.rb
177
177
  - lib/unimatrix/zephyrus/transcoding_rendition.rb
178
178
  - lib/unimatrix/zephyrus/transcribing_output.rb
179
- - lib/unimatrix/zephyrus/transcribing_rendition.rb
180
179
  - lib/unimatrix/zephyrus/transmutation_output.rb
181
180
  - lib/unimatrix/zephyrus/transmutation_rendition.rb
182
181
  homepage: http://sportsrocket.com
@@ -199,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
199
198
  version: '0'
200
199
  requirements: []
201
200
  rubyforge_project:
202
- rubygems_version: 2.5.2
201
+ rubygems_version: 2.4.8
203
202
  signing_key:
204
203
  specification_version: 4
205
204
  summary: Unimatrix is used to communicate with Unimatrix APIs.
@@ -1,6 +0,0 @@
1
- module Unimatrix::Zephyrus
2
-
3
- class TranscribingRendition < Rendition
4
- end
5
-
6
- end