expressir 2.1.13 → 2.1.14
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/.github/workflows/rake.yml +7 -82
- data/.rubocop_todo.yml +15 -74
- data/Gemfile +4 -5
- data/expressir.gemspec +3 -1
- data/lib/expressir/express/cache.rb +4 -6
- data/lib/expressir/express/formatter.rb +92 -63
- data/lib/expressir/express/model_visitor.rb +10 -9
- data/lib/expressir/express/parser.rb +10 -8
- data/lib/expressir/express/resolve_references_model_visitor.rb +0 -3
- data/lib/expressir/express/visitor.rb +2 -1
- data/lib/expressir/liquid.rb +0 -17
- data/lib/expressir/model/cache.rb +9 -8
- data/lib/expressir/model/data_types/aggregate.rb +6 -11
- data/lib/expressir/model/data_types/array.rb +14 -20
- data/lib/expressir/model/data_types/bag.rb +10 -14
- data/lib/expressir/model/data_types/binary.rb +8 -11
- data/lib/expressir/model/data_types/boolean.rb +6 -1
- data/lib/expressir/model/data_types/enumeration.rb +10 -14
- data/lib/expressir/model/data_types/enumeration_item.rb +3 -5
- data/lib/expressir/model/data_types/generic.rb +4 -6
- data/lib/expressir/model/data_types/generic_entity.rb +4 -6
- data/lib/expressir/model/data_types/integer.rb +6 -1
- data/lib/expressir/model/data_types/list.rb +12 -17
- data/lib/expressir/model/data_types/logical.rb +6 -1
- data/lib/expressir/model/data_types/number.rb +6 -1
- data/lib/expressir/model/data_types/real.rb +6 -8
- data/lib/expressir/model/data_types/select.rb +12 -17
- data/lib/expressir/model/data_types/set.rb +10 -14
- data/lib/expressir/model/data_types/string.rb +8 -11
- data/lib/expressir/model/declarations/attribute.rb +17 -26
- data/lib/expressir/model/declarations/constant.rb +8 -14
- data/lib/expressir/model/declarations/entity.rb +18 -29
- data/lib/expressir/model/declarations/function.rb +25 -39
- data/lib/expressir/model/declarations/interface.rb +12 -16
- data/lib/expressir/model/declarations/interface_item.rb +7 -11
- data/lib/expressir/model/declarations/interfaced_item.rb +11 -18
- data/lib/expressir/model/declarations/parameter.rb +8 -14
- data/lib/expressir/model/declarations/procedure.rb +23 -36
- data/lib/expressir/model/declarations/remark_item.rb +8 -11
- data/lib/expressir/model/declarations/rule.rb +27 -42
- data/lib/expressir/model/declarations/schema.rb +59 -58
- data/lib/expressir/model/declarations/schema_version.rb +7 -10
- data/lib/expressir/model/declarations/schema_version_item.rb +7 -10
- data/lib/expressir/model/declarations/subtype_constraint.rb +12 -20
- data/lib/expressir/model/declarations/type.rb +10 -17
- data/lib/expressir/model/declarations/unique_rule.rb +6 -11
- data/lib/expressir/model/declarations/variable.rb +8 -14
- data/lib/expressir/model/declarations/where_rule.rb +6 -11
- data/lib/expressir/model/expressions/aggregate_initializer.rb +6 -8
- data/lib/expressir/model/expressions/aggregate_initializer_item.rb +8 -11
- data/lib/expressir/model/expressions/binary_expression.rb +40 -42
- data/lib/expressir/model/expressions/entity_constructor.rb +8 -11
- data/lib/expressir/model/expressions/function_call.rb +8 -11
- data/lib/expressir/model/expressions/interval.rb +16 -22
- data/lib/expressir/model/expressions/query_expression.rb +8 -14
- data/lib/expressir/model/expressions/unary_expression.rb +11 -14
- data/lib/expressir/model/identifier.rb +8 -25
- data/lib/expressir/model/literals/binary.rb +6 -8
- data/lib/expressir/model/literals/integer.rb +6 -8
- data/lib/expressir/model/literals/logical.rb +9 -11
- data/lib/expressir/model/literals/real.rb +6 -8
- data/lib/expressir/model/literals/string.rb +8 -11
- data/lib/expressir/model/model_element.rb +164 -131
- data/lib/expressir/model/references/attribute_reference.rb +8 -11
- data/lib/expressir/model/references/group_reference.rb +8 -11
- data/lib/expressir/model/references/index_reference.rb +10 -14
- data/lib/expressir/model/references/simple_reference.rb +10 -13
- data/lib/expressir/model/repository.rb +5 -7
- data/lib/expressir/model/statements/alias.rb +8 -14
- data/lib/expressir/model/statements/assignment.rb +8 -11
- data/lib/expressir/model/statements/case.rb +10 -14
- data/lib/expressir/model/statements/case_action.rb +7 -10
- data/lib/expressir/model/statements/compound.rb +6 -8
- data/lib/expressir/model/statements/escape.rb +6 -1
- data/lib/expressir/model/statements/if.rb +10 -14
- data/lib/expressir/model/statements/null.rb +6 -1
- data/lib/expressir/model/statements/procedure_call.rb +8 -11
- data/lib/expressir/model/statements/repeat.rb +16 -26
- data/lib/expressir/model/statements/return.rb +6 -8
- data/lib/expressir/model/statements/skip.rb +6 -1
- data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +12 -16
- data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +6 -8
- data/lib/expressir/model.rb +1 -8
- data/lib/expressir/version.rb +1 -1
- data/lib/expressir.rb +7 -3
- metadata +32 -89
- data/lib/expressir/liquid/cache_drop.rb +0 -20
- data/lib/expressir/liquid/data_type_drop.rb +0 -8
- data/lib/expressir/liquid/data_types/aggregate_drop.rb +0 -21
- data/lib/expressir/liquid/data_types/array_drop.rb +0 -34
- data/lib/expressir/liquid/data_types/bag_drop.rb +0 -26
- data/lib/expressir/liquid/data_types/binary_drop.rb +0 -22
- data/lib/expressir/liquid/data_types/boolean_drop.rb +0 -10
- data/lib/expressir/liquid/data_types/enumeration_drop.rb +0 -30
- data/lib/expressir/liquid/data_types/enumeration_item_drop.rb +0 -17
- data/lib/expressir/liquid/data_types/generic_drop.rb +0 -17
- data/lib/expressir/liquid/data_types/generic_entity_drop.rb +0 -17
- data/lib/expressir/liquid/data_types/integer_drop.rb +0 -10
- data/lib/expressir/liquid/data_types/list_drop.rb +0 -30
- data/lib/expressir/liquid/data_types/logical_drop.rb +0 -10
- data/lib/expressir/liquid/data_types/number_drop.rb +0 -10
- data/lib/expressir/liquid/data_types/real_drop.rb +0 -18
- data/lib/expressir/liquid/data_types/select_drop.rb +0 -34
- data/lib/expressir/liquid/data_types/set_drop.rb +0 -26
- data/lib/expressir/liquid/data_types/string_drop.rb +0 -22
- data/lib/expressir/liquid/declaration_drop.rb +0 -8
- data/lib/expressir/liquid/declarations/attribute_drop.rb +0 -37
- data/lib/expressir/liquid/declarations/constant_drop.rb +0 -25
- data/lib/expressir/liquid/declarations/entity_drop.rb +0 -65
- data/lib/expressir/liquid/declarations/function_drop.rb +0 -93
- data/lib/expressir/liquid/declarations/interface_drop.rb +0 -30
- data/lib/expressir/liquid/declarations/interface_item_drop.rb +0 -22
- data/lib/expressir/liquid/declarations/interfaced_item_drop.rb +0 -34
- data/lib/expressir/liquid/declarations/parameter_drop.rb +0 -25
- data/lib/expressir/liquid/declarations/procedure_drop.rb +0 -89
- data/lib/expressir/liquid/declarations/remark_item_drop.rb +0 -22
- data/lib/expressir/liquid/declarations/rule_drop.rb +0 -105
- data/lib/expressir/liquid/declarations/schema_drop.rb +0 -131
- data/lib/expressir/liquid/declarations/schema_version_drop.rb +0 -26
- data/lib/expressir/liquid/declarations/schema_version_item_drop.rb +0 -22
- data/lib/expressir/liquid/declarations/subtype_constraint_drop.rb +0 -37
- data/lib/expressir/liquid/declarations/type_drop.rb +0 -37
- data/lib/expressir/liquid/declarations/unique_rule_drop.rb +0 -21
- data/lib/expressir/liquid/declarations/variable_drop.rb +0 -25
- data/lib/expressir/liquid/declarations/where_rule_drop.rb +0 -21
- data/lib/expressir/liquid/expression_drop.rb +0 -8
- data/lib/expressir/liquid/expressions/aggregate_initializer_drop.rb +0 -24
- data/lib/expressir/liquid/expressions/aggregate_initializer_item_drop.rb +0 -22
- data/lib/expressir/liquid/expressions/binary_expression_drop.rb +0 -26
- data/lib/expressir/liquid/expressions/entity_constructor_drop.rb +0 -26
- data/lib/expressir/liquid/expressions/function_call_drop.rb +0 -26
- data/lib/expressir/liquid/expressions/interval_drop.rb +0 -34
- data/lib/expressir/liquid/expressions/query_expression_drop.rb +0 -25
- data/lib/expressir/liquid/expressions/unary_expression_drop.rb +0 -22
- data/lib/expressir/liquid/identifier_drop.rb +0 -33
- data/lib/expressir/liquid/literal_drop.rb +0 -8
- data/lib/expressir/liquid/literals/binary_drop.rb +0 -18
- data/lib/expressir/liquid/literals/integer_drop.rb +0 -18
- data/lib/expressir/liquid/literals/logical_drop.rb +0 -18
- data/lib/expressir/liquid/literals/real_drop.rb +0 -18
- data/lib/expressir/liquid/literals/string_drop.rb +0 -22
- data/lib/expressir/liquid/model_element_drop.rb +0 -33
- data/lib/expressir/liquid/reference_drop.rb +0 -8
- data/lib/expressir/liquid/references/attribute_reference_drop.rb +0 -22
- data/lib/expressir/liquid/references/group_reference_drop.rb +0 -22
- data/lib/expressir/liquid/references/index_reference_drop.rb +0 -26
- data/lib/expressir/liquid/references/simple_reference_drop.rb +0 -22
- data/lib/expressir/liquid/repository_drop.rb +0 -25
- data/lib/expressir/liquid/statement_drop.rb +0 -8
- data/lib/expressir/liquid/statements/alias_drop.rb +0 -29
- data/lib/expressir/liquid/statements/assignment_drop.rb +0 -22
- data/lib/expressir/liquid/statements/case_action_drop.rb +0 -26
- data/lib/expressir/liquid/statements/case_drop.rb +0 -30
- data/lib/expressir/liquid/statements/compound_drop.rb +0 -22
- data/lib/expressir/liquid/statements/escape_drop.rb +0 -10
- data/lib/expressir/liquid/statements/if_drop.rb +0 -34
- data/lib/expressir/liquid/statements/null_drop.rb +0 -10
- data/lib/expressir/liquid/statements/procedure_call_drop.rb +0 -26
- data/lib/expressir/liquid/statements/repeat_drop.rb +0 -45
- data/lib/expressir/liquid/statements/return_drop.rb +0 -18
- data/lib/expressir/liquid/statements/skip_drop.rb +0 -10
- data/lib/expressir/liquid/supertype_expression_drop.rb +0 -8
- data/lib/expressir/liquid/supertype_expressions/binary_supertype_expression_drop.rb +0 -26
- data/lib/expressir/liquid/supertype_expressions/oneof_supertype_expression_drop.rb +0 -22
- data/lib/expressir/model/data_type.rb +0 -9
- data/lib/expressir/model/declaration.rb +0 -9
- data/lib/expressir/model/expression.rb +0 -9
- data/lib/expressir/model/literal.rb +0 -9
- data/lib/expressir/model/reference.rb +0 -9
- data/lib/expressir/model/statement.rb +0 -9
- data/lib/expressir/model/supertype_expression.rb +0 -9
@@ -3,47 +3,33 @@ module Expressir
|
|
3
3
|
module Declarations
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.5.1 Function
|
6
|
-
class Function <
|
6
|
+
class Function < ModelElement
|
7
7
|
include Identifier
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
9
|
+
attribute :parameters, Parameter, collection: true
|
10
|
+
attribute :return_type, ModelElement
|
11
|
+
attribute :types, ModelElement, collection: true
|
12
|
+
attribute :entities, Entity, collection: true
|
13
|
+
attribute :subtype_constraints, SubtypeConstraint, collection: true
|
14
|
+
attribute :functions, Function, collection: true
|
15
|
+
attribute :procedures, Procedure, collection: true
|
16
|
+
attribute :constants, Constant, collection: true
|
17
|
+
attribute :variables, Variable, collection: true
|
18
|
+
attribute :statements, ModelElement, collection: true
|
19
|
+
attribute :_class, :string, default: -> { send(:name) }
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
def initialize(options = {})
|
33
|
-
initialize_identifier(options)
|
34
|
-
|
35
|
-
@parameters = options[:parameters] || []
|
36
|
-
@return_type = options[:return_type]
|
37
|
-
@types = options[:types] || []
|
38
|
-
@entities = options[:entities] || []
|
39
|
-
@subtype_constraints = options[:subtype_constraints] || []
|
40
|
-
@functions = options[:functions] || []
|
41
|
-
@procedures = options[:procedures] || []
|
42
|
-
@constants = options[:constants] || []
|
43
|
-
@variables = options[:variables] || []
|
44
|
-
@statements = options[:statements] || []
|
45
|
-
|
46
|
-
super
|
21
|
+
key_value do
|
22
|
+
map "_class", to: :_class, render_default: true
|
23
|
+
map "parameters", to: :parameters
|
24
|
+
map "return_type", to: :return_type
|
25
|
+
map "types", to: :types
|
26
|
+
map "entities", to: :entities
|
27
|
+
map "subtype_constraints", to: :subtype_constraints
|
28
|
+
map "functions", to: :functions
|
29
|
+
map "procedures", to: :procedures
|
30
|
+
map "constants", to: :constants
|
31
|
+
map "variables", to: :variables
|
32
|
+
map "statements", to: :statements
|
47
33
|
end
|
48
34
|
|
49
35
|
# @return [Array<Declaration>]
|
@@ -51,7 +37,7 @@ module Expressir
|
|
51
37
|
[
|
52
38
|
*parameters,
|
53
39
|
*types,
|
54
|
-
*types
|
40
|
+
*types&.flat_map(&:enumeration_items),
|
55
41
|
*entities,
|
56
42
|
*subtype_constraints,
|
57
43
|
*functions,
|
@@ -3,24 +3,20 @@ module Expressir
|
|
3
3
|
module Declarations
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 11 Interface specification
|
6
|
-
class Interface <
|
7
|
-
USE =
|
8
|
-
REFERENCE =
|
6
|
+
class Interface < ModelElement
|
7
|
+
USE = "USE".freeze
|
8
|
+
REFERENCE = "REFERENCE".freeze
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
attribute :kind, :string, values: %w[USE REFERENCE]
|
11
|
+
attribute :schema, ModelElement
|
12
|
+
attribute :items, InterfaceItem, collection: true
|
13
|
+
attribute :_class, :string, default: -> { send(:name) }
|
13
14
|
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
@kind = options[:kind]
|
20
|
-
@schema = options[:schema]
|
21
|
-
@items = options[:items] || []
|
22
|
-
|
23
|
-
super
|
15
|
+
key_value do
|
16
|
+
map "_class", to: :_class, render_default: true
|
17
|
+
map "kind", to: :kind
|
18
|
+
map "schema", to: :schema
|
19
|
+
map "items", to: :items
|
24
20
|
end
|
25
21
|
end
|
26
22
|
end
|
@@ -4,18 +4,14 @@ module Expressir
|
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 11 Interface specification
|
6
6
|
class InterfaceItem < ModelElement
|
7
|
-
|
8
|
-
|
7
|
+
attribute :ref, ModelElement
|
8
|
+
attribute :id, :string
|
9
|
+
attribute :_class, :string, default: -> { send(:name) }
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
def initialize(options = {})
|
15
|
-
@ref = options[:ref]
|
16
|
-
@id = options[:id]
|
17
|
-
|
18
|
-
super
|
11
|
+
key_value do
|
12
|
+
map "_class", to: :_class, render_default: true
|
13
|
+
map "ref", to: :ref
|
14
|
+
map "id", to: :id
|
19
15
|
end
|
20
16
|
end
|
21
17
|
end
|
@@ -4,25 +4,18 @@ module Expressir
|
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 11 Interface specification
|
6
6
|
class InterfacedItem < ModelElement
|
7
|
-
|
8
|
-
|
9
|
-
|
7
|
+
attribute :id, :string
|
8
|
+
attribute :remarks, :string, collection: true
|
9
|
+
attribute :remark_items, RemarkItem, collection: true
|
10
|
+
attribute :base_item, ModelElement
|
11
|
+
attribute :_class, :string, default: -> { send(:name) }
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
# @option options [ModelElement] :base_item
|
18
|
-
def initialize(options = {})
|
19
|
-
@id = options[:id]
|
20
|
-
@remarks = options[:remarks] || []
|
21
|
-
@remark_items = options[:remark_items] || []
|
22
|
-
|
23
|
-
@base_item = options[:base_item]
|
24
|
-
|
25
|
-
super
|
13
|
+
key_value do
|
14
|
+
map "_class", to: :_class, render_default: true
|
15
|
+
map "id", to: :id
|
16
|
+
map "remarks", to: :remarks
|
17
|
+
map "remark_items", to: :remark_items
|
18
|
+
map "base_item", to: :base_item
|
26
19
|
end
|
27
20
|
|
28
21
|
# @return [Array<Declaration>]
|
@@ -3,23 +3,17 @@ module Expressir
|
|
3
3
|
module Declarations
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.5.3 Parameters
|
6
|
-
class Parameter <
|
6
|
+
class Parameter < ModelElement
|
7
7
|
include Identifier
|
8
8
|
|
9
|
-
|
10
|
-
|
9
|
+
attribute :var, :boolean
|
10
|
+
attribute :type, ModelElement
|
11
|
+
attribute :_class, :string, default: -> { send(:name) }
|
11
12
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
def initialize(options = {})
|
17
|
-
initialize_identifier(options)
|
18
|
-
|
19
|
-
@var = options[:var]
|
20
|
-
@type = options[:type]
|
21
|
-
|
22
|
-
super
|
13
|
+
key_value do
|
14
|
+
map "_class", to: :_class, render_default: true
|
15
|
+
map "var", to: :var
|
16
|
+
map "type", to: :type
|
23
17
|
end
|
24
18
|
|
25
19
|
# @return [Array<Declaration>]
|
@@ -3,44 +3,31 @@ module Expressir
|
|
3
3
|
module Declarations
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.5.2 Procedure
|
6
|
-
class Procedure <
|
6
|
+
class Procedure < ModelElement
|
7
7
|
include Identifier
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
9
|
+
attribute :parameters, Parameter, collection: true
|
10
|
+
attribute :types, ModelElement, collection: true
|
11
|
+
attribute :entities, Entity, collection: true
|
12
|
+
attribute :subtype_constraints, SubtypeConstraint, collection: true
|
13
|
+
attribute :functions, Function, collection: true
|
14
|
+
attribute :procedures, Procedure, collection: true
|
15
|
+
attribute :constants, Constant, collection: true
|
16
|
+
attribute :variables, Variable, collection: true
|
17
|
+
attribute :statements, ModelElement, collection: true
|
18
|
+
attribute :_class, :string, default: -> { send(:name) }
|
18
19
|
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
def initialize(options = {})
|
31
|
-
initialize_identifier(options)
|
32
|
-
|
33
|
-
@parameters = options[:parameters] || []
|
34
|
-
@types = options[:types] || []
|
35
|
-
@entities = options[:entities] || []
|
36
|
-
@subtype_constraints = options[:subtype_constraints] || []
|
37
|
-
@functions = options[:functions] || []
|
38
|
-
@procedures = options[:procedures] || []
|
39
|
-
@constants = options[:constants] || []
|
40
|
-
@variables = options[:variables] || []
|
41
|
-
@statements = options[:statements] || []
|
42
|
-
|
43
|
-
super
|
20
|
+
key_value do
|
21
|
+
map "_class", to: :_class, render_default: true
|
22
|
+
map "parameters", to: :parameters
|
23
|
+
map "types", to: :types
|
24
|
+
map "entities", to: :entities
|
25
|
+
map "subtype_constraints", to: :subtype_constraints
|
26
|
+
map "functions", to: :functions
|
27
|
+
map "procedures", to: :procedures
|
28
|
+
map "constants", to: :constants
|
29
|
+
map "variables", to: :variables
|
30
|
+
map "statements", to: :statements
|
44
31
|
end
|
45
32
|
|
46
33
|
# @return [Array<Declaration>]
|
@@ -48,7 +35,7 @@ module Expressir
|
|
48
35
|
[
|
49
36
|
*parameters,
|
50
37
|
*types,
|
51
|
-
*types
|
38
|
+
*types&.flat_map(&:enumeration_items),
|
52
39
|
*entities,
|
53
40
|
*subtype_constraints,
|
54
41
|
*functions,
|
@@ -2,18 +2,15 @@ module Expressir
|
|
2
2
|
module Model
|
3
3
|
module Declarations
|
4
4
|
# Implicit item with remarks
|
5
|
-
class RemarkItem <
|
6
|
-
|
7
|
-
|
5
|
+
class RemarkItem < ModelElement
|
6
|
+
attribute :id, :string
|
7
|
+
attribute :remarks, :string, collection: true
|
8
|
+
attribute :_class, :string, default: -> { send(:name) }
|
8
9
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
@id = options[:id]
|
14
|
-
@remarks = options[:remarks] || []
|
15
|
-
|
16
|
-
super
|
10
|
+
key_value do
|
11
|
+
map "_class", to: :_class, render_default: true
|
12
|
+
map "id", to: :id
|
13
|
+
map "remarks", to: :remarks
|
17
14
|
end
|
18
15
|
end
|
19
16
|
end
|
@@ -3,57 +3,42 @@ module Expressir
|
|
3
3
|
module Declarations
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.6 Rule
|
6
|
-
class Rule <
|
6
|
+
class Rule < ModelElement
|
7
7
|
include Identifier
|
8
8
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
9
|
+
attribute :applies_to, ModelElement, collection: true
|
10
|
+
attribute :types, ModelElement, collection: true
|
11
|
+
attribute :entities, Entity, collection: true
|
12
|
+
attribute :subtype_constraints, SubtypeConstraint, collection: true
|
13
|
+
attribute :functions, Function, collection: true
|
14
|
+
attribute :procedures, Procedure, collection: true
|
15
|
+
attribute :constants, Constant, collection: true
|
16
|
+
attribute :variables, Variable, collection: true
|
17
|
+
attribute :statements, ModelElement, collection: true
|
18
|
+
attribute :where_rules, WhereRule, collection: true
|
19
|
+
attribute :informal_propositions, RemarkItem, collection: true
|
20
|
+
attribute :_class, :string, default: -> { send(:name) }
|
20
21
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
def initialize(options = {})
|
35
|
-
initialize_identifier(options)
|
36
|
-
|
37
|
-
@applies_to = options[:applies_to] || []
|
38
|
-
@types = options[:types] || []
|
39
|
-
@entities = options[:entities] || []
|
40
|
-
@subtype_constraints = options[:subtype_constraints] || []
|
41
|
-
@functions = options[:functions] || []
|
42
|
-
@procedures = options[:procedures] || []
|
43
|
-
@constants = options[:constants] || []
|
44
|
-
@variables = options[:variables] || []
|
45
|
-
@statements = options[:statements] || []
|
46
|
-
@where_rules = options[:where_rules] || []
|
47
|
-
@informal_propositions = options[:informal_propositions] || []
|
48
|
-
|
49
|
-
super
|
22
|
+
key_value do
|
23
|
+
map "_class", to: :_class, render_default: true
|
24
|
+
map "applies_to", to: :applies_to
|
25
|
+
map "types", to: :types
|
26
|
+
map "entities", to: :entities
|
27
|
+
map "subtype_constraints", to: :subtype_constraints
|
28
|
+
map "functions", to: :functions
|
29
|
+
map "procedures", to: :procedures
|
30
|
+
map "constants", to: :constants
|
31
|
+
map "variables", to: :variables
|
32
|
+
map "statements", to: :statements
|
33
|
+
map "where_rules", to: :where_rules
|
34
|
+
map "informal_propositions", to: :informal_propositions
|
50
35
|
end
|
51
36
|
|
52
37
|
# @return [Array<Declaration>]
|
53
38
|
def children
|
54
39
|
[
|
55
40
|
*types,
|
56
|
-
*types
|
41
|
+
*types&.flat_map(&:enumeration_items),
|
57
42
|
*entities,
|
58
43
|
*subtype_constraints,
|
59
44
|
*functions,
|
@@ -3,49 +3,40 @@ module Expressir
|
|
3
3
|
module Declarations
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.3 Schema
|
6
|
-
class Schema <
|
7
|
-
model_attr_accessor :file, "String"
|
8
|
-
|
6
|
+
class Schema < ModelElement
|
9
7
|
include Identifier
|
10
8
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
# @option options [Array<Constant>] :constants
|
27
|
-
# @option options [Array<Type>] :types
|
28
|
-
# @option options [Array<Entity>] :entities
|
29
|
-
# @option options [Array<SubtypeConstraint>] :subtype_constraints
|
30
|
-
# @option options [Array<Function>] :functions
|
31
|
-
# @option options [Array<Rule>] :rules
|
32
|
-
# @option options [Array<Procedure>] :procedures
|
33
|
-
def initialize(options = {})
|
34
|
-
@file = options[:file]
|
35
|
-
|
36
|
-
initialize_identifier(options)
|
9
|
+
attribute :file, :string
|
10
|
+
attribute :version, SchemaVersion
|
11
|
+
attribute :interfaces, Interface, collection: true
|
12
|
+
attribute :constants, Constant, collection: true
|
13
|
+
attribute :types, ModelElement, collection: true
|
14
|
+
attribute :entities, Entity, collection: true
|
15
|
+
attribute :subtype_constraints, SubtypeConstraint, collection: true
|
16
|
+
attribute :functions, Function, collection: true
|
17
|
+
attribute :rules, Rule, collection: true
|
18
|
+
attribute :procedures, Procedure, collection: true
|
19
|
+
attribute :_class, :string, default: -> { send(:name) }
|
20
|
+
attribute :selected, :boolean, default: false
|
21
|
+
attribute :formatted, :string
|
22
|
+
attribute :file_basename, :string
|
23
|
+
attribute :full_source, :string
|
37
24
|
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
25
|
+
key_value do
|
26
|
+
map "_class", to: :_class, render_default: true
|
27
|
+
map "id", to: :id
|
28
|
+
map "file", to: :file
|
29
|
+
map "remarks", to: :remarks
|
30
|
+
map "remark_items", to: :remark_items
|
31
|
+
map "version", to: :version
|
32
|
+
map "interfaces", to: :interfaces
|
33
|
+
map "constants", to: :constants
|
34
|
+
map "types", to: :types
|
35
|
+
map "entities", to: :entities
|
36
|
+
map "subtype_constraints", to: :subtype_constraints
|
37
|
+
map "functions", to: :functions
|
38
|
+
map "rules", to: :rules
|
39
|
+
map "procedures", to: :procedures
|
49
40
|
end
|
50
41
|
|
51
42
|
# @return [Array<Declaration>]
|
@@ -53,7 +44,7 @@ module Expressir
|
|
53
44
|
[
|
54
45
|
*constants,
|
55
46
|
*types,
|
56
|
-
*types
|
47
|
+
*types&.flat_map(&:enumeration_items),
|
57
48
|
*entities,
|
58
49
|
*subtype_constraints,
|
59
50
|
*functions,
|
@@ -71,6 +62,17 @@ module Expressir
|
|
71
62
|
]
|
72
63
|
end
|
73
64
|
|
65
|
+
def full_source
|
66
|
+
Expressir::Express::Formatter.format(self)
|
67
|
+
end
|
68
|
+
|
69
|
+
def source
|
70
|
+
formatter = Class.new(Expressir::Express::Formatter) do
|
71
|
+
include Expressir::Express::SchemaHeadFormatter
|
72
|
+
end
|
73
|
+
formatter.format(self)
|
74
|
+
end
|
75
|
+
|
74
76
|
private
|
75
77
|
|
76
78
|
# @param [String] id
|
@@ -91,25 +93,24 @@ module Expressir
|
|
91
93
|
|
92
94
|
interfaces.flat_map do |interface|
|
93
95
|
schema = parent.children_by_id[interface.schema.id.safe_downcase]
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
end
|
96
|
+
next [] unless schema
|
97
|
+
|
98
|
+
safe_children = schema.safe_children
|
99
|
+
children_by_id = safe_children.each_with_object({}) do |child, hash|
|
100
|
+
hash[child.id.safe_downcase] = child if child.id
|
101
|
+
end
|
102
|
+
|
103
|
+
if interface.items.empty?
|
104
|
+
safe_children.map do |base_item|
|
105
|
+
create_interfaced_item(base_item.id, base_item)
|
106
|
+
end
|
107
|
+
else
|
108
|
+
interface.items.filter_map do |item|
|
109
|
+
base_item = children_by_id[item.ref.id.safe_downcase]
|
110
|
+
create_interfaced_item(item.id || base_item.id, base_item) if base_item
|
110
111
|
end
|
111
112
|
end
|
112
|
-
end.
|
113
|
+
end.compact
|
113
114
|
end
|
114
115
|
end
|
115
116
|
end
|
@@ -4,17 +4,14 @@ module Expressir
|
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.3 Schema
|
6
6
|
class SchemaVersion < ModelElement
|
7
|
-
|
8
|
-
|
7
|
+
attribute :value, :string
|
8
|
+
attribute :items, SchemaVersionItem, collection: true
|
9
|
+
attribute :_class, :string, default: -> { send(:name) }
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@value = options[:value]
|
15
|
-
@items = options[:items] || []
|
16
|
-
|
17
|
-
super
|
11
|
+
key_value do
|
12
|
+
map "_class", to: :_class, render_default: true
|
13
|
+
map "value", to: :value
|
14
|
+
map "items", to: :items
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|
@@ -4,17 +4,14 @@ module Expressir
|
|
4
4
|
# Specified in ISO 10303-11:2004
|
5
5
|
# - section 9.3 Schema
|
6
6
|
class SchemaVersionItem < ModelElement
|
7
|
-
|
8
|
-
|
7
|
+
attribute :name, :string
|
8
|
+
attribute :value, :string
|
9
|
+
attribute :_class, :string, default: -> { send(:name) }
|
9
10
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
@name = options[:name]
|
15
|
-
@value = options[:value]
|
16
|
-
|
17
|
-
super
|
11
|
+
key_value do
|
12
|
+
map "_class", to: :_class, render_default: true
|
13
|
+
map "name", to: :name
|
14
|
+
map "value", to: :value
|
18
15
|
end
|
19
16
|
end
|
20
17
|
end
|