unimatrix 2.2.1 → 2.3.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6bbefa04b7e63f9c32a57b063fad7c7f3f2141c6
4
- data.tar.gz: d9e4a1638bdc45d326b59b099be970dc3587cf6f
3
+ metadata.gz: 3d3e2a1fbf8ecd5a6aed641bc96082a03073a941
4
+ data.tar.gz: 8b74c9770faa1cc09ce0a2abff7379535164a146
5
5
  SHA512:
6
- metadata.gz: fd36484f60ea3f20922001882f23e5d691ae0340596b94b40312a72e5e47e22f55699ad79847fbc8007c7ee899ecd7212a8b0059ad061a99fba9bbff005e1fc5
7
- data.tar.gz: dc010c9ac93db818c90f91d05fd8e02a5ec8b9e66679694c91edaa627eb261ace5590b562f7993728bddd5468792d1b3fbe6c76496061b462311de21bb152110
6
+ metadata.gz: a00a806353e993ccbc4ab872792d14757e1e2dd974e084df429cd7142c00c4c9123854fe30a219eec5072cff59557cba7a41ac9fd2acc178d320773e60e49342
7
+ data.tar.gz: 766f98f696db873f4e4d899c36595b754296396740c3d16cf50299e23e9906621422439e975472054cf114434ace190bff68832df471dbb4ccc3279bcbf73122
@@ -1,6 +1,8 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
- class Artifact < Unimatrix::DynamicResource
3
+ class Artifact < Unimatrix::Resource
4
+
5
+ include Unimatrix::Blueprintable
4
6
 
5
7
  field :id
6
8
  field :creator_uuid
@@ -20,7 +22,7 @@ module Unimatrix::Archivist
20
22
  field :uuid
21
23
  field :realm_uuid
22
24
  field :component_uuids
23
- field relationships: [ :category ]
25
+ field relationships: [ :category, :cast, :season, :asset, :athlete ]
24
26
  field :name
25
27
  field :created_at
26
28
  field :updated_at
@@ -1,6 +1,6 @@
1
1
  module Unimatrix::Archivist
2
2
 
3
- class Blueprint < Unimatrix::DynamicResource
3
+ class Blueprint < Unimatrix::Resource
4
4
 
5
5
  field :id
6
6
  field :uuid
@@ -1,9 +1,9 @@
1
1
  require 'net/http'
2
2
  require 'json'
3
3
 
4
- module Unimatrix::Authorization
4
+ module Unimatrix::Authorization
5
5
  class ClientCredentialsGrant
6
-
6
+
7
7
  def initialize( args )
8
8
  @client_id = args[ :client_id ]
9
9
  @client_secret = args[ :client_secret ]
@@ -9,9 +9,6 @@ module Unimatrix::Authorization
9
9
  field :realm_uuid
10
10
  field :actions
11
11
 
12
- has_one :resource
13
- has_one :resource_server
14
-
15
12
  end
16
13
 
17
14
  end
@@ -19,7 +19,7 @@ module Unimatrix::Authorization
19
19
  end
20
20
  else
21
21
  @success = false
22
- @resources << Error.new(
22
+ @resources << Unimatrix::Error.new(
23
23
  message: "#{ @code }: #{ http_response.message }."
24
24
  )
25
25
  end
@@ -0,0 +1,45 @@
1
+ module Unimatrix
2
+
3
+ class BlueprintOperation < Unimatrix::Operation
4
+
5
+ @@blueprints = {}
6
+
7
+ def initialize( realm_uuid, options = {} )
8
+ @realm_uuid = realm_uuid
9
+ super( "/realms/#{ realm_uuid }/blueprints", options )
10
+ end
11
+
12
+ def read
13
+ @@blueprints[ @realm_uuid ] ||= begin
14
+ blueprints = []
15
+
16
+ offset = 0
17
+ segment_count = 10
18
+ total = nil
19
+ errors = nil
20
+
21
+ while total.nil? || offset < total
22
+ operation = self.offset( offset ).include( 'blueprint_attributes' )
23
+
24
+ operation.read do | resources, response |
25
+
26
+ if !response.body[ 'errors' ].nil?
27
+ errors = response.body[ 'errors' ]
28
+ break
29
+ end
30
+
31
+ offset += segment_count
32
+ total = response.body[ '$this' ][ 'unlimited_count' ]
33
+
34
+ blueprints += resources
35
+ end
36
+
37
+ raise "Error requesting blueprints for realm #{ @realm_uuid }. Error: #{ errors }" if !errors.nil?
38
+ end
39
+
40
+ blueprints
41
+ end
42
+ end
43
+
44
+ end
45
+ end
@@ -0,0 +1,72 @@
1
+ module Unimatrix
2
+
3
+ module Blueprintable
4
+
5
+ @module_members = []
6
+
7
+ def self.included( klass )
8
+ @module_members << klass
9
+
10
+ class << klass
11
+ cattr_accessor :blueprints
12
+
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
22
+ end
23
+
24
+ blueprint
25
+ end
26
+
27
+ def build( attributes )
28
+ blueprint = find_blueprint( attributes[ 'type_name' ] ) rescue nil
29
+ klass = build_typed_class( attributes, blueprint )
30
+ klass.new( attributes ) rescue nil
31
+ end
32
+
33
+ def build_typed_class( attributes, blueprint )
34
+ base_class = Class.new( self )
35
+ klass = base_class
36
+
37
+ if !blueprint.nil?
38
+ 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 )
43
+
44
+ default_attributes = [ "type_name", "relationships", "realm_uuid" ]
45
+
46
+ if blueprint.respond_to?( 'blueprint_attributes' )
47
+ permitted_attributes = blueprint.blueprint_attributes.map( &:name ) + default_attributes
48
+
49
+ klass.instance_eval do
50
+ permitted_attributes.each do | field_name |
51
+ field field_name.to_sym
52
+ end
53
+ end
54
+ end
55
+
56
+ else
57
+ klass = module_name.const_get( entity_type_name )
58
+ end
59
+ end
60
+
61
+ klass
62
+ end
63
+ end
64
+ end
65
+
66
+ def self.assign_blueprints( blueprints )
67
+ @module_members.map{ | klass | klass.blueprints = blueprints }
68
+ end
69
+
70
+ end
71
+
72
+ end
@@ -0,0 +1,6 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class City < GeographicArea
4
+ end
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class Continent < GeographicArea
4
+ end
5
+
6
+ end
@@ -0,0 +1,6 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class Country < GeographicArea
4
+ end
5
+
6
+ end
@@ -0,0 +1,19 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class GeographicArea < Unimatrix::DynamicResource
4
+
5
+ field :id
6
+ field :type_name
7
+ field :name
8
+ field :uuid
9
+ field :parent_uuid
10
+ field :code
11
+ field :created_at
12
+ field :updated_at
13
+
14
+ has_many :regions
15
+ has_many :region_geographic_areas
16
+
17
+ end
18
+
19
+ end
@@ -0,0 +1,15 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class Realm < Unimatrix::DynamicResource
4
+
5
+ field :id
6
+ field :uuid
7
+ field :created_at
8
+ field :updated_at
9
+
10
+ has_many :regions
11
+ has_many :region_geographic_areas
12
+
13
+ end
14
+
15
+ end
@@ -0,0 +1,17 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class Region < Unimatrix::DynamicResource
4
+
5
+ field :id
6
+ field :uuid
7
+ field :name
8
+ field :realm_id
9
+ field :created_at
10
+ field :updated_at
11
+
12
+ has_many :geographic_areas
13
+ has_many :region_geographic_areas
14
+
15
+ end
16
+
17
+ end
@@ -0,0 +1,14 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class RegionGeographicArea < Unimatrix::DynamicResource
4
+
5
+ field :id
6
+ field :realm_id
7
+ field :region_id
8
+ field :geographic_area_id
9
+ field :created_at
10
+ field :updated_at
11
+
12
+ end
13
+
14
+ end
@@ -0,0 +1,6 @@
1
+ module Unimatrix::Cartographer
2
+
3
+ class Territory < GeographicArea
4
+ end
5
+
6
+ end
@@ -2,18 +2,18 @@ module Unimatrix
2
2
 
3
3
  class DynamicResource < Resource
4
4
 
5
- class << self
6
-
5
+ class << self
6
+
7
7
  alias old_new new
8
-
8
+
9
9
  def new( attributes = {}, associations = {} )
10
- Class.new( self ).old_new(
10
+ Class.new( self ).old_new(
11
11
  { type_name: self.name.split( '::' ).last.underscore }.
12
- merge( attributes ),
13
- associations
12
+ merge( attributes ),
13
+ associations
14
14
  )
15
15
  end
16
-
16
+
17
17
  end
18
18
 
19
19
  def initialize( attributes = {}, associations = {} )
@@ -24,17 +24,17 @@ module Unimatrix
24
24
  unless self.respond_to?( key.to_sym )
25
25
  end
26
26
 
27
- self.class_eval do
27
+ self.class_eval do
28
28
  unsupported_attributes_names.each do | name |
29
- field name
29
+ field name
30
30
  end
31
31
  end
32
32
 
33
- super( attributes, associations )
33
+ super( attributes, associations )
34
34
  yield self if block_given?
35
35
 
36
36
  end
37
37
 
38
38
  end
39
-
39
+
40
40
  end
@@ -99,7 +99,7 @@ module Unimatrix
99
99
  if resource_attributes.present?
100
100
  parse_nested_attributes( resource_attributes )
101
101
 
102
- resource_class = find_resource_class_by_type_name(
102
+ resource_class = find_resource_class_by_type_name(
103
103
  resource_attributes[ 'type_name' ],
104
104
  options[ 'type_name' ]
105
105
  )
@@ -26,6 +26,10 @@ module Unimatrix
26
26
  @descendants_by_type_name[ type_name ]
27
27
  end
28
28
 
29
+ def build( attributes = {} )
30
+ new( attributes )
31
+ end
32
+
29
33
  def field( name, options = {} )
30
34
  if name.is_a?( Hash )
31
35
  nested_field_key = name.keys.first
@@ -1,3 +1,3 @@
1
1
  module Unimatrix
2
- VERSION = "2.2.1"
2
+ VERSION = "2.3.1"
3
3
  end
data/lib/unimatrix.rb CHANGED
@@ -13,6 +13,9 @@ require 'unimatrix/serializer'
13
13
 
14
14
  require 'unimatrix/resource'
15
15
  require 'unimatrix/dynamic_resource'
16
+ require 'unimatrix/blueprintable'
17
+ require 'unimatrix/blueprint_operation'
18
+
16
19
  require 'unimatrix/realm'
17
20
 
18
21
  require 'unimatrix/error'
@@ -72,6 +75,16 @@ require 'unimatrix/authorization/resource'
72
75
  require 'unimatrix/authorization/resource_owner'
73
76
  require 'unimatrix/authorization/resource_server'
74
77
 
78
+ # cartographer
79
+ require 'unimatrix/cartographer/geographic_area'
80
+ require 'unimatrix/cartographer/city'
81
+ require 'unimatrix/cartographer/continent'
82
+ require 'unimatrix/cartographer/country'
83
+ require 'unimatrix/cartographer/realm'
84
+ require 'unimatrix/cartographer/region'
85
+ require 'unimatrix/cartographer/region_geographic_area'
86
+ require 'unimatrix/cartographer/territory'
87
+
75
88
  # distributor
76
89
  require 'unimatrix/distributor/destination'
77
90
  require 'unimatrix/distributor/distribution'
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.2.1
4
+ version: 2.3.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-02-26 00:00:00.000000000 Z
11
+ date: 2018-03-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -126,6 +126,16 @@ files:
126
126
  - lib/unimatrix/authorization/resource_server.rb
127
127
  - lib/unimatrix/authorization/response.rb
128
128
  - lib/unimatrix/bad_request_error.rb
129
+ - lib/unimatrix/blueprint_operation.rb
130
+ - lib/unimatrix/blueprintable.rb
131
+ - lib/unimatrix/cartographer/city.rb
132
+ - lib/unimatrix/cartographer/continent.rb
133
+ - lib/unimatrix/cartographer/country.rb
134
+ - lib/unimatrix/cartographer/geographic_area.rb
135
+ - lib/unimatrix/cartographer/realm.rb
136
+ - lib/unimatrix/cartographer/region.rb
137
+ - lib/unimatrix/cartographer/region_geographic_area.rb
138
+ - lib/unimatrix/cartographer/territory.rb
129
139
  - lib/unimatrix/configuration.rb
130
140
  - lib/unimatrix/curator/activity_reference.rb
131
141
  - lib/unimatrix/curator/source.rb