unimatrix 2.5.0 → 2.5.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/lib/unimatrix/archivist/artifact_locator.rb +1 -1
- data/lib/unimatrix/archivist/artifact_relationship.rb +1 -1
- data/lib/unimatrix/archivist/blueprint_attribute.rb +1 -1
- data/lib/unimatrix/blueprintable.rb +19 -21
- data/lib/unimatrix/distributor/activity_reference.rb +1 -1
- data/lib/unimatrix/operation.rb +33 -0
- data/lib/unimatrix/parser.rb +17 -17
- data/lib/unimatrix/resource.rb +7 -6
- data/lib/unimatrix/serializer.rb +2 -1
- data/lib/unimatrix/version.rb +7 -1
- data/lib/unimatrix.rb +0 -1
- metadata +3 -4
- data/lib/unimatrix/zephyrus/transcribing_rendition.rb +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b136e83e3869e1cfa52d87786415f4810862f620
|
4
|
+
data.tar.gz: 6087fc4a9a4bd7f4fac85482bbdf4025eeb41165
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 06e196c7b3700eb625776670bad3a2198313766bcb5d3d024152427b607d5749fb559e17a9d93a4a232a0a2b34a72e5a43d64374ccb052a0da687833c8c9e41a
|
7
|
+
data.tar.gz: 98e7997592da6b39ba7bc83e6e8bd70e4750f153be8a35cd959853124dfd93129bb33ea3cf897b184346b9c77d6e4448a569cf38210b7b2b5f4715e76089fb2b
|
@@ -11,54 +11,52 @@ module Unimatrix
|
|
11
11
|
cattr_accessor :blueprints
|
12
12
|
|
13
13
|
def find_blueprint( class_type_name )
|
14
|
-
blueprint
|
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
|
-
|
35
|
-
klass =
|
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
|
-
|
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(
|
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
|
data/lib/unimatrix/operation.rb
CHANGED
@@ -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 |
|
data/lib/unimatrix/parser.rb
CHANGED
@@ -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.
|
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
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
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
|
data/lib/unimatrix/resource.rb
CHANGED
@@ -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
|
-
|
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
|
-
|
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 = {} )
|
data/lib/unimatrix/serializer.rb
CHANGED
@@ -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
|
-
|
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
|
data/lib/unimatrix/version.rb
CHANGED
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.
|
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-
|
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.
|
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.
|