expressir 1.0.0-arm64-darwin → 1.2.1-arm64-darwin
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.cross_rubies +6 -18
- data/.github/workflows/rake.yml +50 -5
- data/.github/workflows/release.yml +11 -3
- data/.hound.yml +3 -0
- data/.rubocop.yml +6 -506
- data/.yardopts +11 -0
- data/Rakefile +3 -0
- data/expressir.gemspec +4 -1
- data/lib/expressir/express/2.7/express_parser.bundle +0 -0
- data/lib/expressir/express/3.0/express_parser.bundle +0 -0
- data/lib/expressir/express/3.1/express_parser.bundle +0 -0
- data/lib/expressir/express/cache.rb +16 -10
- data/lib/expressir/express/formatter.rb +231 -180
- data/lib/expressir/express/hyperlink_formatter.rb +15 -1
- data/lib/expressir/express/model_visitor.rb +1 -0
- data/lib/expressir/express/parser.rb +16 -10
- data/lib/expressir/express/resolve_references_model_visitor.rb +7 -5
- data/lib/expressir/express/schema_head_formatter.rb +16 -2
- data/lib/expressir/express/visitor.rb +280 -254
- data/lib/expressir/model/cache.rb +6 -2
- data/lib/expressir/model/data_type.rb +9 -0
- data/lib/expressir/model/data_types/aggregate.rb +31 -0
- data/lib/expressir/model/data_types/array.rb +31 -0
- data/lib/expressir/model/data_types/bag.rb +25 -0
- data/lib/expressir/model/data_types/binary.rb +22 -0
- data/lib/expressir/model/data_types/boolean.rb +10 -0
- data/lib/expressir/model/data_types/enumeration.rb +25 -0
- data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
- data/lib/expressir/model/data_types/generic.rb +26 -0
- data/lib/expressir/model/data_types/generic_entity.rb +26 -0
- data/lib/expressir/model/data_types/integer.rb +10 -0
- data/lib/expressir/model/data_types/list.rb +28 -0
- data/lib/expressir/model/data_types/logical.rb +10 -0
- data/lib/expressir/model/data_types/number.rb +10 -0
- data/lib/expressir/model/data_types/real.rb +19 -0
- data/lib/expressir/model/data_types/select.rb +28 -0
- data/lib/expressir/model/data_types/set.rb +25 -0
- data/lib/expressir/model/data_types/string.rb +22 -0
- data/lib/expressir/model/declaration.rb +9 -0
- data/lib/expressir/model/declarations/attribute.rb +47 -0
- data/lib/expressir/model/declarations/constant.rb +34 -0
- data/lib/expressir/model/declarations/entity.rb +53 -0
- data/lib/expressir/model/declarations/function.rb +67 -0
- data/lib/expressir/model/declarations/interface.rb +28 -0
- data/lib/expressir/model/declarations/interface_item.rb +23 -0
- data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
- data/lib/expressir/model/declarations/parameter.rb +34 -0
- data/lib/expressir/model/declarations/procedure.rb +64 -0
- data/lib/expressir/model/declarations/remark_item.rb +21 -0
- data/lib/expressir/model/declarations/rule.rb +71 -0
- data/lib/expressir/model/declarations/schema.rb +117 -0
- data/lib/expressir/model/declarations/schema_version.rb +22 -0
- data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
- data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
- data/lib/expressir/model/declarations/type.rb +45 -0
- data/lib/expressir/model/declarations/unique_rule.rb +31 -0
- data/lib/expressir/model/declarations/variable.rb +34 -0
- data/lib/expressir/model/declarations/where_rule.rb +31 -0
- data/lib/expressir/model/expression.rb +9 -0
- data/lib/expressir/model/expressions/aggregate_initializer.rb +6 -2
- data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
- data/lib/expressir/model/expressions/binary_expression.rb +16 -5
- data/lib/expressir/model/expressions/entity_constructor.rb +8 -3
- data/lib/expressir/model/expressions/function_call.rb +22 -0
- data/lib/expressir/model/expressions/interval.rb +17 -6
- data/lib/expressir/model/expressions/query_expression.rb +11 -7
- data/lib/expressir/model/expressions/unary_expression.rb +9 -3
- data/lib/expressir/model/identifier.rb +26 -4
- data/lib/expressir/model/literal.rb +9 -0
- data/lib/expressir/model/literals/binary.rb +6 -2
- data/lib/expressir/model/literals/integer.rb +6 -2
- data/lib/expressir/model/literals/logical.rb +6 -2
- data/lib/expressir/model/literals/real.rb +6 -2
- data/lib/expressir/model/literals/string.rb +8 -3
- data/lib/expressir/model/model_element.rb +63 -37
- data/lib/expressir/model/reference.rb +9 -0
- data/lib/expressir/model/references/attribute_reference.rb +22 -0
- data/lib/expressir/model/references/group_reference.rb +22 -0
- data/lib/expressir/model/references/index_reference.rb +27 -0
- data/lib/expressir/model/references/simple_reference.rb +24 -0
- data/lib/expressir/model/repository.rb +5 -1
- data/lib/expressir/model/statement.rb +9 -0
- data/lib/expressir/model/statements/alias.rb +11 -7
- data/lib/expressir/model/statements/assignment.rb +8 -3
- data/lib/expressir/model/statements/case.rb +10 -4
- data/lib/expressir/model/statements/case_action.rb +7 -2
- data/lib/expressir/model/statements/compound.rb +6 -2
- data/lib/expressir/model/statements/escape.rb +3 -1
- data/lib/expressir/model/statements/if.rb +10 -4
- data/lib/expressir/model/statements/null.rb +3 -1
- data/lib/expressir/model/statements/procedure_call.rb +22 -0
- data/lib/expressir/model/statements/repeat.rb +19 -11
- data/lib/expressir/model/statements/return.rb +6 -2
- data/lib/expressir/model/statements/skip.rb +3 -1
- data/lib/expressir/model/supertype_expression.rb +9 -0
- data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
- data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
- data/lib/expressir/model.rb +52 -45
- data/lib/expressir/version.rb +1 -1
- data/spec/expressir/model/model_element_spec.rb +131 -131
- data/spec/syntax/multiple.yaml +68 -68
- data/spec/syntax/remark.yaml +64 -64
- data/spec/syntax/single.yaml +5 -5
- data/spec/syntax/single_formatted.yaml +5 -5
- data/spec/syntax/syntax.yaml +1003 -1030
- metadata +105 -54
- data/lib/expressir/express/2.4/express_parser.bundle +0 -0
- data/lib/expressir/express/2.5/express_parser.bundle +0 -0
- data/lib/expressir/express/2.6/express_parser.bundle +0 -0
- data/lib/expressir/model/attribute.rb +0 -38
- data/lib/expressir/model/constant.rb +0 -28
- data/lib/expressir/model/entity.rb +0 -42
- data/lib/expressir/model/enumeration_item.rb +0 -22
- data/lib/expressir/model/expressions/aggregate_item.rb +0 -17
- data/lib/expressir/model/expressions/attribute_reference.rb +0 -17
- data/lib/expressir/model/expressions/call.rb +0 -17
- data/lib/expressir/model/expressions/group_reference.rb +0 -17
- data/lib/expressir/model/expressions/index_reference.rb +0 -19
- data/lib/expressir/model/expressions/simple_reference.rb +0 -19
- data/lib/expressir/model/function.rb +0 -57
- data/lib/expressir/model/interface.rb +0 -20
- data/lib/expressir/model/interface_item.rb +0 -15
- data/lib/expressir/model/interfaced_item.rb +0 -27
- data/lib/expressir/model/parameter.rb +0 -28
- data/lib/expressir/model/procedure.rb +0 -55
- data/lib/expressir/model/remark_item.rb +0 -15
- data/lib/expressir/model/rule.rb +0 -60
- data/lib/expressir/model/schema.rb +0 -100
- data/lib/expressir/model/schema_version.rb +0 -15
- data/lib/expressir/model/schema_version_item.rb +0 -15
- data/lib/expressir/model/statements/call.rb +0 -17
- data/lib/expressir/model/subtype_constraint.rb +0 -32
- data/lib/expressir/model/type.rb +0 -37
- data/lib/expressir/model/types/aggregate.rb +0 -28
- data/lib/expressir/model/types/array.rb +0 -23
- data/lib/expressir/model/types/bag.rb +0 -19
- data/lib/expressir/model/types/binary.rb +0 -17
- data/lib/expressir/model/types/boolean.rb +0 -8
- data/lib/expressir/model/types/enumeration.rb +0 -19
- data/lib/expressir/model/types/generic.rb +0 -24
- data/lib/expressir/model/types/generic_entity.rb +0 -24
- data/lib/expressir/model/types/integer.rb +0 -8
- data/lib/expressir/model/types/list.rb +0 -21
- data/lib/expressir/model/types/logical.rb +0 -8
- data/lib/expressir/model/types/number.rb +0 -8
- data/lib/expressir/model/types/real.rb +0 -15
- data/lib/expressir/model/types/select.rb +0 -21
- data/lib/expressir/model/types/set.rb +0 -19
- data/lib/expressir/model/types/string.rb +0 -17
- data/lib/expressir/model/unique_rule.rb +0 -26
- data/lib/expressir/model/variable.rb +0 -28
- data/lib/expressir/model/where_rule.rb +0 -26
@@ -1,10 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.1 Arithmetic operators
|
6
|
+
# - section 12.2 Relational operators
|
7
|
+
# - section 12.3 Binary operators
|
8
|
+
# - section 12.4 Logical operators
|
9
|
+
# - section 12.5 String operators
|
10
|
+
# - section 12.6 Aggregate operators
|
11
|
+
# - section 12.10 Complex entity instance construction operator
|
12
|
+
class BinaryExpression < Expression
|
5
13
|
ADDITION = :ADDITION
|
6
14
|
AND = :AND
|
7
|
-
ANDOR = :ANDOR
|
8
15
|
COMBINE = :COMBINE
|
9
16
|
EQUAL = :EQUAL
|
10
17
|
EXPONENTIATION = :EXPONENTIATION
|
@@ -25,10 +32,14 @@ module Expressir
|
|
25
32
|
SUBTRACTION = :SUBTRACTION
|
26
33
|
XOR = :XOR
|
27
34
|
|
28
|
-
model_attr_accessor :operator
|
29
|
-
model_attr_accessor :operand1
|
30
|
-
model_attr_accessor :operand2
|
35
|
+
model_attr_accessor :operator, ':ADDITION, :AND, :COMBINE, :EQUAL, :EXPONENTIATION, :GREATER_THAN, :GREATER_THAN_OR_EQUAL, :IN, :INSTANCE_EQUAL, :INSTANCE_NOT_EQUAL, :INTEGER_DIVISION, :LESS_THAN, :LESS_THAN_OR_EQUAL, :LIKE, :MODULO, :MULTIPLICATION, :NOT_EQUAL, :OR, :REAL_DIVISION, :SUBTRACTION, :XOR'
|
36
|
+
model_attr_accessor :operand1, 'Expression'
|
37
|
+
model_attr_accessor :operand2, 'Expression'
|
31
38
|
|
39
|
+
# @param [Hash] options
|
40
|
+
# @option options [:ADDITION, :AND, :COMBINE, :EQUAL, :EXPONENTIATION, :GREATER_THAN, :GREATER_THAN_OR_EQUAL, :IN, :INSTANCE_EQUAL, :INSTANCE_NOT_EQUAL, :INTEGER_DIVISION, :LESS_THAN, :LESS_THAN_OR_EQUAL, :LIKE, :MODULO, :MULTIPLICATION, :NOT_EQUAL, :OR, :REAL_DIVISION, :SUBTRACTION, :XOR] :operator
|
41
|
+
# @option options [Expression] :operand1
|
42
|
+
# @option options [Expression] :operand2
|
32
43
|
def initialize(options = {})
|
33
44
|
@operator = options[:operator]
|
34
45
|
@operand1 = options[:operand1]
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 9.2.6 Implicit declarations
|
6
|
+
class EntityConstructor < Expression
|
7
|
+
model_attr_accessor :entity, 'Reference'
|
8
|
+
model_attr_accessor :parameters, 'Array<Expression>'
|
7
9
|
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Reference] :entity
|
12
|
+
# @option options [Array<Expression>] :parameters
|
8
13
|
def initialize(options = {})
|
9
14
|
@entity = options[:entity]
|
10
15
|
@parameters = options[:parameters] || []
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module Expressions
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.8 Function call
|
6
|
+
class FunctionCall < Expression
|
7
|
+
model_attr_accessor :function, 'Reference'
|
8
|
+
model_attr_accessor :parameters, 'Array<Expression>'
|
9
|
+
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Reference] :function
|
12
|
+
# @option options [Array<Expression>] :parameters
|
13
|
+
def initialize(options = {})
|
14
|
+
@function = options[:function]
|
15
|
+
@parameters = options[:parameters] || []
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -1,13 +1,24 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
model_attr_accessor :high
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.2.4 Interval expressions
|
6
|
+
class Interval < Expression
|
7
|
+
LESS_THAN = :LESS_THAN
|
8
|
+
LESS_THAN_OR_EQUAL = :LESS_THAN_OR_EQUAL
|
10
9
|
|
10
|
+
model_attr_accessor :low, 'Expression'
|
11
|
+
model_attr_accessor :operator1, ':LESS_THAN, :LESS_THAN_OR_EQUAL'
|
12
|
+
model_attr_accessor :item, 'Reference'
|
13
|
+
model_attr_accessor :operator2, ':LESS_THAN, :LESS_THAN_OR_EQUAL'
|
14
|
+
model_attr_accessor :high, 'Expression'
|
15
|
+
|
16
|
+
# @param [Hash] options
|
17
|
+
# @option options [Expression] :low
|
18
|
+
# @option options [:LESS_THAN, :LESS_THAN_OR_EQUAL] :operator1
|
19
|
+
# @option options [Reference] :item
|
20
|
+
# @option options [:LESS_THAN, :LESS_THAN_OR_EQUAL] :operator2
|
21
|
+
# @option options [Expression] :high
|
11
22
|
def initialize(options = {})
|
12
23
|
@low = options[:low]
|
13
24
|
@operator1 = options[:operator1]
|
@@ -1,17 +1,20 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.6.7 Query expression
|
6
|
+
class QueryExpression < Expression
|
5
7
|
include Identifier
|
6
8
|
|
7
|
-
model_attr_accessor :aggregate_source
|
8
|
-
model_attr_accessor :expression
|
9
|
+
model_attr_accessor :aggregate_source, 'Reference'
|
10
|
+
model_attr_accessor :expression, 'Expression'
|
9
11
|
|
12
|
+
# @param [Hash] options
|
13
|
+
# @option (see Identifier#initialize_identifier)
|
14
|
+
# @option options [Reference] :aggregace_source
|
15
|
+
# @option options [Expression] :expression
|
10
16
|
def initialize(options = {})
|
11
|
-
|
12
|
-
@remarks = options[:remarks] || []
|
13
|
-
@remark_items = options[:remark_items] || []
|
14
|
-
@source = options[:source]
|
17
|
+
initialize_identifier(options)
|
15
18
|
|
16
19
|
@aggregate_source = options[:aggregate_source]
|
17
20
|
@expression = options[:expression]
|
@@ -19,6 +22,7 @@ module Expressir
|
|
19
22
|
super
|
20
23
|
end
|
21
24
|
|
25
|
+
# @return [Array<Declaration>]
|
22
26
|
def children
|
23
27
|
[
|
24
28
|
self,
|
@@ -1,14 +1,20 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Expressions
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.1 Arithmetic operators
|
6
|
+
# - section 12.4.1 NOT operator
|
7
|
+
class UnaryExpression < Expression
|
5
8
|
MINUS = :MINUS
|
6
9
|
NOT = :NOT
|
7
10
|
PLUS = :PLUS
|
8
11
|
|
9
|
-
model_attr_accessor :operator
|
10
|
-
model_attr_accessor :operand
|
12
|
+
model_attr_accessor :operator, ':MINUS, :NOT, :PLUS'
|
13
|
+
model_attr_accessor :operand, 'Expression'
|
11
14
|
|
15
|
+
# @param [Hash] options
|
16
|
+
# @option options [:MINUS, :NOT, :PLUS] :operator
|
17
|
+
# @option options [Expression] :operand
|
12
18
|
def initialize(options = {})
|
13
19
|
@operator = options[:operator]
|
14
20
|
@operand = options[:operand]
|
@@ -1,11 +1,33 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Identifier
|
4
|
+
# @!attribute id
|
5
|
+
# @return [::String]
|
6
|
+
# @!attribute remarks
|
7
|
+
# @return [::Array<::String>]
|
8
|
+
# @!attribute remark_items
|
9
|
+
# @return [::Array<RemarkItem>]
|
10
|
+
# @!attribute source
|
11
|
+
# @return [::String]
|
12
|
+
# @!visibility private
|
4
13
|
def self.included(mod)
|
5
|
-
mod.model_attr_accessor :id
|
6
|
-
mod.model_attr_accessor :remarks
|
7
|
-
mod.model_attr_accessor :remark_items
|
8
|
-
mod.model_attr_accessor :source
|
14
|
+
mod.model_attr_accessor :id, '::String'
|
15
|
+
mod.model_attr_accessor :remarks, '::Array<::String>'
|
16
|
+
mod.model_attr_accessor :remark_items, '::Array<RemarkItem>'
|
17
|
+
mod.model_attr_accessor :source, '::String'
|
18
|
+
end
|
19
|
+
|
20
|
+
# @param [Hash] options
|
21
|
+
# @option options [::String] :id
|
22
|
+
# @option options [::Array<::String>] :remarks
|
23
|
+
# @option options [::Array<RemarkItem>] :remark_items
|
24
|
+
# @option options [::String] :source
|
25
|
+
# @!visibility private
|
26
|
+
def initialize_identifier(options = {})
|
27
|
+
@id = options[:id]
|
28
|
+
@remarks = options[:remarks] || []
|
29
|
+
@remark_items = options[:remark_items] || []
|
30
|
+
@source = options[:source]
|
9
31
|
end
|
10
32
|
end
|
11
33
|
end
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.1 Binary literal
|
6
|
+
class Binary < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [::String] :value
|
7
11
|
def initialize(options = {})
|
8
12
|
@value = options[:value]
|
9
13
|
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.2 Integer literal
|
6
|
+
class Integer < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [::String] :value
|
7
11
|
def initialize(options = {})
|
8
12
|
@value = options[:value]
|
9
13
|
|
@@ -1,13 +1,17 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.5 Logical literal
|
6
|
+
class Logical < Literal
|
5
7
|
TRUE = :TRUE
|
6
8
|
FALSE = :FALSE
|
7
9
|
UNKNOWN = :UNKNOWN
|
8
10
|
|
9
|
-
model_attr_accessor :value
|
11
|
+
model_attr_accessor :value, ':TRUE, :FALSE, :UNKNOWN'
|
10
12
|
|
13
|
+
# @param [Hash] options
|
14
|
+
# @option options [:TRUE, :FALSE, :UNKNOWN] :value
|
11
15
|
def initialize(options = {})
|
12
16
|
@value = options[:value]
|
13
17
|
|
@@ -1,9 +1,13 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.3 Real literal
|
6
|
+
class Real < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
6
8
|
|
9
|
+
# @param [Hash] options
|
10
|
+
# @option options [::String] :value
|
7
11
|
def initialize(options = {})
|
8
12
|
@value = options[:value]
|
9
13
|
|
@@ -1,10 +1,15 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
3
|
module Literals
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 7.5.4 String literal
|
6
|
+
class String < Literal
|
7
|
+
model_attr_accessor :value, '::String'
|
8
|
+
model_attr_accessor :encoded, '::Boolean'
|
7
9
|
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [::String] :value
|
12
|
+
# @option options [::Boolean] :encoded
|
8
13
|
def initialize(options = {})
|
9
14
|
@value = options[:value]
|
10
15
|
@encoded = options[:encoded]
|
@@ -2,17 +2,25 @@ require 'pathname'
|
|
2
2
|
|
3
3
|
module Expressir
|
4
4
|
module Model
|
5
|
+
# Base model element
|
5
6
|
class ModelElement
|
6
7
|
CLASS_KEY = '_class'
|
7
8
|
FILE_KEY = 'file'
|
8
9
|
SOURCE_KEY = 'source'
|
9
10
|
|
11
|
+
private_constant :CLASS_KEY
|
12
|
+
private_constant :FILE_KEY
|
13
|
+
private_constant :SOURCE_KEY
|
14
|
+
|
15
|
+
# @return [ModelElement]
|
10
16
|
attr_accessor :parent
|
11
17
|
|
18
|
+
# @param [Hash] options
|
12
19
|
def initialize(options = {})
|
13
20
|
attach_parent_to_children
|
14
21
|
end
|
15
22
|
|
23
|
+
# @return [String]
|
16
24
|
def path
|
17
25
|
# this creates an implicit scope
|
18
26
|
return if is_a? Statements::Alias or is_a? Statements::Repeat or is_a? Expressions::QueryExpression
|
@@ -20,7 +28,7 @@ module Expressir
|
|
20
28
|
current_node = self
|
21
29
|
path_parts = []
|
22
30
|
loop do
|
23
|
-
if current_node.class.method_defined? :id and !(current_node.is_a?
|
31
|
+
if current_node.class.method_defined? :id and !(current_node.is_a? References::SimpleReference)
|
24
32
|
path_parts << current_node.id
|
25
33
|
end
|
26
34
|
|
@@ -33,22 +41,8 @@ module Expressir
|
|
33
41
|
path_parts.reverse.join(".")
|
34
42
|
end
|
35
43
|
|
36
|
-
|
37
|
-
|
38
|
-
value = self.send(variable)
|
39
|
-
|
40
|
-
if value.is_a? Array
|
41
|
-
value.each do |value|
|
42
|
-
if value.is_a? ModelElement
|
43
|
-
value.parent = self
|
44
|
-
end
|
45
|
-
end
|
46
|
-
elsif value.is_a? ModelElement
|
47
|
-
value.parent = self
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
44
|
+
# @param [String] path
|
45
|
+
# @return [ModelElement]
|
52
46
|
def find(path)
|
53
47
|
return self if path.empty?
|
54
48
|
|
@@ -74,30 +68,34 @@ module Expressir
|
|
74
68
|
break unless current_scope
|
75
69
|
end
|
76
70
|
|
77
|
-
if target_node.is_a? Model::InterfacedItem
|
71
|
+
if target_node.is_a? Model::Declarations::InterfacedItem
|
78
72
|
target_node = target_node.base_item
|
79
73
|
end
|
80
74
|
|
81
75
|
target_node
|
82
76
|
end
|
83
77
|
|
78
|
+
# @return [Array<Declaration>]
|
84
79
|
def children
|
85
80
|
[]
|
86
81
|
end
|
87
82
|
|
83
|
+
# @return [Hash<String, Declaration>]
|
88
84
|
def children_by_id
|
89
85
|
@children_by_id ||= children.select{|x| x.id}.map{|x| [x.id.downcase, x]}.to_h
|
90
86
|
end
|
91
87
|
|
88
|
+
# @return [nil]
|
92
89
|
def reset_children_by_id
|
93
90
|
@children_by_id = nil
|
91
|
+
nil
|
94
92
|
end
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
93
|
+
|
94
|
+
# @param [String] root_path
|
95
|
+
# @param [Express::Formatter] formatter
|
96
|
+
# @param [Boolean] include_empty
|
97
|
+
# @return [Hash]
|
98
|
+
def to_hash(root_path: nil, formatter: nil, include_empty: nil)
|
101
99
|
hash = {}
|
102
100
|
hash[CLASS_KEY] = self.class.name
|
103
101
|
|
@@ -110,20 +108,20 @@ module Expressir
|
|
110
108
|
hash[variable.to_s] = if value.is_a? Array
|
111
109
|
value.map do |value|
|
112
110
|
if value.is_a? ModelElement
|
113
|
-
value.to_hash(
|
111
|
+
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
114
112
|
else
|
115
113
|
value
|
116
114
|
end
|
117
115
|
end
|
118
116
|
elsif value.is_a? ModelElement
|
119
|
-
value.to_hash(
|
117
|
+
value.to_hash(root_path: root_path, formatter: formatter, include_empty: include_empty)
|
120
118
|
else
|
121
119
|
value
|
122
120
|
end
|
123
121
|
end
|
124
122
|
end
|
125
123
|
|
126
|
-
if self.is_a? Schema and file
|
124
|
+
if self.is_a? Declarations::Schema and file
|
127
125
|
hash[FILE_KEY] = root_path ? Pathname.new(file).relative_path_from(root_path).to_s : file
|
128
126
|
end
|
129
127
|
|
@@ -133,10 +131,11 @@ module Expressir
|
|
133
131
|
|
134
132
|
hash
|
135
133
|
end
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
134
|
+
|
135
|
+
# @param [Hash] hash
|
136
|
+
# @param [String] root_path
|
137
|
+
# @return [ModelElement]
|
138
|
+
def self.from_hash(hash, root_path: nil)
|
140
139
|
node_class = Object.const_get(hash[CLASS_KEY])
|
141
140
|
node_options = {}
|
142
141
|
|
@@ -146,19 +145,19 @@ module Expressir
|
|
146
145
|
node_options[variable] = if value.is_a? Array
|
147
146
|
value.map do |value|
|
148
147
|
if value.is_a? Hash
|
149
|
-
self.from_hash(value,
|
148
|
+
self.from_hash(value, root_path: root_path)
|
150
149
|
else
|
151
150
|
value
|
152
151
|
end
|
153
152
|
end
|
154
153
|
elsif value.is_a? Hash
|
155
|
-
self.from_hash(value,
|
154
|
+
self.from_hash(value, root_path: root_path)
|
156
155
|
else
|
157
156
|
value
|
158
157
|
end
|
159
158
|
end
|
160
159
|
|
161
|
-
if node_class == Schema and hash[FILE_KEY]
|
160
|
+
if node_class == Declarations::Schema and hash[FILE_KEY]
|
162
161
|
node_options[FILE_KEY.to_sym] = root_path ? File.expand_path("#{root_path}/#{hash[FILE_KEY]}") : hash[FILE_KEY]
|
163
162
|
end
|
164
163
|
|
@@ -167,15 +166,42 @@ module Expressir
|
|
167
166
|
node
|
168
167
|
end
|
169
168
|
|
169
|
+
# @return [Array<Symbol>]
|
170
170
|
def self.model_attrs
|
171
171
|
@model_attrs ||= []
|
172
172
|
end
|
173
173
|
|
174
|
-
|
174
|
+
# Define a new model attribute
|
175
|
+
# @param attr_name [Symbol] attribute name
|
176
|
+
# @param attr_type [Symbol] attribute type
|
177
|
+
# @!macro [attach] model_attr_accessor
|
178
|
+
# @!attribute $1
|
179
|
+
# @return [$2]
|
180
|
+
def self.model_attr_accessor(attr_name, attr_type = nil)
|
175
181
|
@model_attrs ||= []
|
176
|
-
@model_attrs
|
182
|
+
@model_attrs << attr_name
|
183
|
+
|
184
|
+
attr_accessor attr_name
|
185
|
+
end
|
186
|
+
|
187
|
+
private
|
177
188
|
|
178
|
-
|
189
|
+
# @return [nil]
|
190
|
+
def attach_parent_to_children
|
191
|
+
self.class.model_attrs.each do |variable|
|
192
|
+
value = self.send(variable)
|
193
|
+
|
194
|
+
if value.is_a? Array
|
195
|
+
value.each do |value|
|
196
|
+
if value.is_a? ModelElement
|
197
|
+
value.parent = self
|
198
|
+
end
|
199
|
+
end
|
200
|
+
elsif value.is_a? ModelElement
|
201
|
+
value.parent = self
|
202
|
+
end
|
203
|
+
end
|
204
|
+
nil
|
179
205
|
end
|
180
206
|
end
|
181
207
|
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module References
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.7.3 Attribute references
|
6
|
+
class AttributeReference < Reference
|
7
|
+
model_attr_accessor :ref, 'Reference'
|
8
|
+
model_attr_accessor :attribute, 'Reference'
|
9
|
+
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Reference] :ref
|
12
|
+
# @option options [Reference] :attribute
|
13
|
+
def initialize(options = {})
|
14
|
+
@ref = options[:ref]
|
15
|
+
@attribute = options[:attribute]
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module References
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.7.4 Group references
|
6
|
+
class GroupReference < Reference
|
7
|
+
model_attr_accessor :ref, 'Reference'
|
8
|
+
model_attr_accessor :entity, 'Reference'
|
9
|
+
|
10
|
+
# @param [Hash] options
|
11
|
+
# @option options [Reference] :ref
|
12
|
+
# @option options [Reference] :entity
|
13
|
+
def initialize(options = {})
|
14
|
+
@ref = options[:ref]
|
15
|
+
@entity = options[:entity]
|
16
|
+
|
17
|
+
super
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module References
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.3.1 Binary indexing
|
6
|
+
# - section 12.5.1 String indexing
|
7
|
+
# - section 12.6.1 Aggregate indexing
|
8
|
+
class IndexReference < Reference
|
9
|
+
model_attr_accessor :ref, 'Reference'
|
10
|
+
model_attr_accessor :index1, 'Expression'
|
11
|
+
model_attr_accessor :index2, 'Expression'
|
12
|
+
|
13
|
+
# @param [Hash] options
|
14
|
+
# @option options [Reference] :ref
|
15
|
+
# @option options [Expression] :index1
|
16
|
+
# @option options [Expression] :index2
|
17
|
+
def initialize(options = {})
|
18
|
+
@ref = options[:ref]
|
19
|
+
@index1 = options[:index1]
|
20
|
+
@index2 = options[:index2]
|
21
|
+
|
22
|
+
super
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Expressir
|
2
|
+
module Model
|
3
|
+
module References
|
4
|
+
# Specified in ISO 10303-11:2004
|
5
|
+
# - section 12.7.1 Simple references
|
6
|
+
class SimpleReference < Reference
|
7
|
+
model_attr_accessor :id, 'String'
|
8
|
+
|
9
|
+
model_attr_accessor :base_path, 'String'
|
10
|
+
|
11
|
+
# @param [Hash] options
|
12
|
+
# @option options [String] :id
|
13
|
+
# @option options [String] :base_path
|
14
|
+
def initialize(options = {})
|
15
|
+
@id = options[:id]
|
16
|
+
|
17
|
+
@base_path = options[:base_path]
|
18
|
+
|
19
|
+
super
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -1,14 +1,18 @@
|
|
1
1
|
module Expressir
|
2
2
|
module Model
|
3
|
+
# Multi-schema global scope
|
3
4
|
class Repository < ModelElement
|
4
|
-
model_attr_accessor :schemas
|
5
|
+
model_attr_accessor :schemas, 'Array<Declarations::Schema>'
|
5
6
|
|
7
|
+
# @param [Hash] options
|
8
|
+
# @option options [Array<Declarations::Schema>] :schemas
|
6
9
|
def initialize(options = {})
|
7
10
|
@schemas = options[:schemas] || []
|
8
11
|
|
9
12
|
super
|
10
13
|
end
|
11
14
|
|
15
|
+
# @return [Array<Declaration>]
|
12
16
|
def children
|
13
17
|
[
|
14
18
|
*schemas
|