Class: Ea::Sources::Qea::InstanceBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/ea/sources/qea/instance_builder.rb

Overview

Translates EA t_object rows of Object_Type="Object" into Ea::Model::InstanceSpecification instances. Slots are parsed from the RunState field, which uses a packed format:

@VAR;Variable=name;Value=val;Op===;@ENDVAR;@VAR;...

Each @VAR...@ENDVAR block is one Slot.

Constant Summary collapse

RUN_STATE_PATTERN =
/
  @VAR;
  (?:Variable=(?<name>[^;]*);)?
  (?:Value=(?<value>[^;]*);)?
  (?:Op=(?<op>[^;]*);)?
  @ENDVAR;
/x.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(database) ⇒ InstanceBuilder

Returns a new instance of InstanceBuilder.



24
25
26
# File 'lib/ea/sources/qea/instance_builder.rb', line 24

def initialize(database)
  @database = database
end

Instance Attribute Details

#databaseObject (readonly)

Returns the value of attribute database.



22
23
24
# File 'lib/ea/sources/qea/instance_builder.rb', line 22

def database
  @database
end

Instance Method Details

#build_allObject



28
29
30
31
# File 'lib/ea/sources/qea/instance_builder.rb', line 28

def build_all
  objects = database.collections[:objects] || []
  objects.filter_map { |row| build_one(row) if instance?(row) }
end

#build_one(row) ⇒ Object



33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ea/sources/qea/instance_builder.rb', line 33

def build_one(row)
  Ea::Model::InstanceSpecification.new(
    id: IdNormalizer.from_guid(row.ea_guid),
    name: row.name.to_s,
    classifier_id: classifier_id_for(row),
    classifier_name: classifier_name_for(row),
    package_id: package_id_for(row),
    package_name: package_name_for(row),
    qualified_name: qualified_name_for(row),
    slots: slots_for(row),
    annotations: AnnotationBuilder.from_note(row.note, row.ea_guid,
                                              kind: "documentation")
  )
end