expressir 2.1.0 → 2.1.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (95) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -13
  3. data/.rubocop_todo.yml +69 -6
  4. data/Gemfile +1 -1
  5. data/README.adoc +46 -0
  6. data/exe/expressir-format-test +2 -1
  7. data/expressir.gemspec +2 -3
  8. data/lib/expressir/express/cache.rb +6 -6
  9. data/lib/expressir/express/formatter.rb +754 -741
  10. data/lib/expressir/express/hyperlink_formatter.rb +2 -2
  11. data/lib/expressir/express/model_visitor.rb +1 -1
  12. data/lib/expressir/express/parser.rb +224 -100
  13. data/lib/expressir/express/resolve_references_model_visitor.rb +6 -6
  14. data/lib/expressir/express/schema_head_formatter.rb +3 -3
  15. data/lib/expressir/express/visitor.rb +353 -344
  16. data/lib/expressir/model/cache.rb +3 -3
  17. data/lib/expressir/model/data_type.rb +1 -1
  18. data/lib/expressir/model/data_types/aggregate.rb +3 -3
  19. data/lib/expressir/model/data_types/array.rb +6 -6
  20. data/lib/expressir/model/data_types/bag.rb +4 -4
  21. data/lib/expressir/model/data_types/binary.rb +3 -3
  22. data/lib/expressir/model/data_types/boolean.rb +1 -1
  23. data/lib/expressir/model/data_types/enumeration.rb +4 -4
  24. data/lib/expressir/model/data_types/enumeration_item.rb +2 -2
  25. data/lib/expressir/model/data_types/generic.rb +2 -2
  26. data/lib/expressir/model/data_types/generic_entity.rb +2 -2
  27. data/lib/expressir/model/data_types/integer.rb +1 -1
  28. data/lib/expressir/model/data_types/list.rb +5 -5
  29. data/lib/expressir/model/data_types/logical.rb +1 -1
  30. data/lib/expressir/model/data_types/number.rb +1 -1
  31. data/lib/expressir/model/data_types/real.rb +2 -2
  32. data/lib/expressir/model/data_types/select.rb +5 -5
  33. data/lib/expressir/model/data_types/set.rb +4 -4
  34. data/lib/expressir/model/data_types/string.rb +3 -3
  35. data/lib/expressir/model/declaration.rb +1 -1
  36. data/lib/expressir/model/declarations/attribute.rb +7 -7
  37. data/lib/expressir/model/declarations/constant.rb +4 -4
  38. data/lib/expressir/model/declarations/entity.rb +9 -9
  39. data/lib/expressir/model/declarations/function.rb +13 -13
  40. data/lib/expressir/model/declarations/interface.rb +4 -4
  41. data/lib/expressir/model/declarations/interface_item.rb +3 -3
  42. data/lib/expressir/model/declarations/interfaced_item.rb +6 -6
  43. data/lib/expressir/model/declarations/parameter.rb +4 -4
  44. data/lib/expressir/model/declarations/procedure.rb +12 -12
  45. data/lib/expressir/model/declarations/remark_item.rb +3 -3
  46. data/lib/expressir/model/declarations/rule.rb +14 -14
  47. data/lib/expressir/model/declarations/schema.rb +18 -18
  48. data/lib/expressir/model/declarations/schema_version.rb +3 -3
  49. data/lib/expressir/model/declarations/schema_version_item.rb +3 -3
  50. data/lib/expressir/model/declarations/subtype_constraint.rb +6 -6
  51. data/lib/expressir/model/declarations/type.rb +5 -5
  52. data/lib/expressir/model/declarations/unique_rule.rb +3 -3
  53. data/lib/expressir/model/declarations/variable.rb +4 -4
  54. data/lib/expressir/model/declarations/where_rule.rb +3 -3
  55. data/lib/expressir/model/expression.rb +1 -1
  56. data/lib/expressir/model/expressions/aggregate_initializer.rb +2 -2
  57. data/lib/expressir/model/expressions/aggregate_initializer_item.rb +3 -3
  58. data/lib/expressir/model/expressions/binary_expression.rb +12 -5
  59. data/lib/expressir/model/expressions/entity_constructor.rb +3 -3
  60. data/lib/expressir/model/expressions/function_call.rb +3 -3
  61. data/lib/expressir/model/expressions/interval.rb +6 -6
  62. data/lib/expressir/model/expressions/query_expression.rb +4 -4
  63. data/lib/expressir/model/expressions/unary_expression.rb +3 -3
  64. data/lib/expressir/model/identifier.rb +5 -5
  65. data/lib/expressir/model/literal.rb +1 -1
  66. data/lib/expressir/model/literals/binary.rb +2 -2
  67. data/lib/expressir/model/literals/integer.rb +2 -2
  68. data/lib/expressir/model/literals/logical.rb +2 -2
  69. data/lib/expressir/model/literals/real.rb +2 -2
  70. data/lib/expressir/model/literals/string.rb +3 -3
  71. data/lib/expressir/model/model_element.rb +35 -41
  72. data/lib/expressir/model/reference.rb +1 -1
  73. data/lib/expressir/model/references/attribute_reference.rb +3 -3
  74. data/lib/expressir/model/references/group_reference.rb +3 -3
  75. data/lib/expressir/model/references/index_reference.rb +4 -4
  76. data/lib/expressir/model/references/simple_reference.rb +3 -3
  77. data/lib/expressir/model/repository.rb +3 -4
  78. data/lib/expressir/model/statement.rb +1 -1
  79. data/lib/expressir/model/statements/alias.rb +4 -4
  80. data/lib/expressir/model/statements/assignment.rb +3 -3
  81. data/lib/expressir/model/statements/case.rb +4 -4
  82. data/lib/expressir/model/statements/case_action.rb +3 -3
  83. data/lib/expressir/model/statements/compound.rb +2 -2
  84. data/lib/expressir/model/statements/escape.rb +1 -1
  85. data/lib/expressir/model/statements/if.rb +4 -4
  86. data/lib/expressir/model/statements/null.rb +1 -1
  87. data/lib/expressir/model/statements/procedure_call.rb +3 -3
  88. data/lib/expressir/model/statements/repeat.rb +8 -8
  89. data/lib/expressir/model/statements/return.rb +2 -2
  90. data/lib/expressir/model/statements/skip.rb +1 -1
  91. data/lib/expressir/model/supertype_expression.rb +1 -1
  92. data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +4 -4
  93. data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +2 -2
  94. data/lib/expressir/version.rb +1 -1
  95. metadata +12 -12
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cbd41bdd1b751ae458be19326cd83cb663516e4377de07b935e914610812bccd
4
- data.tar.gz: 89a7c1ca633ecd262d9990aa1915a63480e2cbd61ffcd25f8c29e8906a74ebcf
3
+ metadata.gz: 2ae2589e65c9c989edbabf98e4052772fd7abae7c221d00a091983e7f5525ef3
4
+ data.tar.gz: d5b2682aacd2aa4bed76747876c2c8b2d4d1aed0e3f4bcc59b518404e9deae30
5
5
  SHA512:
6
- metadata.gz: ded756dbd4abdc170eac6eaef07af7af582d608fc3f974ed6b2d8b36a83cd2ebc1f3a5196228b5bb5a027e0361b12c4ad233e15d1a137183def193a07cbcd7f7
7
- data.tar.gz: c325aeec18fa692234d24883b68cf650ca4a5f85c614b311671cc62659b1d52f6a1526bd938350259cc6eaf45fdfd8e3e181133258a31d2d32091c2a03eead2e
6
+ metadata.gz: b28fcd1ecee58b9eb7b750731fa28d86866d77c18afdc8b5d3e4857d9816b5c3f92ec6bd38175519526c0add26973d31dbb664a332459f8fcaf5be4938beeffd
7
+ data.tar.gz: 66633c6a8ab3bfa54d6934b53de31b9c9b040e200ad5537ec806160ccc26ad7c7e9ad9a60c84a27836b944ff96a724bd807a21f139394080e193bf71422402d9
data/.rubocop.yml CHANGED
@@ -1,19 +1,14 @@
1
+ require:
2
+ - rubocop-performance
3
+
1
4
  inherit_from:
2
- - .rubocop_todo.yml
3
5
  - https://raw.githubusercontent.com/riboseinc/oss-guides/master/ci/rubocop.yml
6
+ - .rubocop_todo.yml
4
7
 
5
- AllCops:
6
- TargetRubyVersion: 2.7
7
- NewCops: enable
8
- SuggestExtensions: false
8
+ Naming/VariableName:
9
9
  Exclude:
10
- - 'vendor/**/*'
11
- - 'expressir.gemspec'
12
- - 'tmp/**/*'
13
- - 'pkg/**/*'
14
- - 'exe/format-test'
15
- - 'lib/expressir/express/**/*'
16
- - 'lib/expressir/model/**/*'
17
-
10
+ - lib/expressir/express/visitor.rb
18
11
  Layout/LineLength:
19
12
  Max: 160
13
+ AllCops:
14
+ TargetRubyVersion: 2.7
data/.rubocop_todo.yml CHANGED
@@ -1,21 +1,84 @@
1
1
  # This configuration was generated by
2
2
  # `rubocop --auto-gen-config`
3
- # on 2024-11-19 15:15:51 UTC using RuboCop version 1.68.0.
3
+ # on 2024-11-26 21:06:12 UTC using RuboCop version 1.68.0.
4
4
  # The point is for the user to remove these configuration records
5
5
  # one by one as the offenses are removed from the code base.
6
6
  # Note that changes in the inspected code, or installation of new
7
7
  # versions of RuboCop, may require this file to be generated again.
8
8
 
9
9
  # Offense count: 1
10
+ # Configuration parameters: AllowedParentClasses.
11
+ Lint/MissingSuper:
12
+ Exclude:
13
+ - 'lib/expressir/model/cache.rb'
14
+
15
+ # Offense count: 3
16
+ Lint/ShadowingOuterLocalVariable:
17
+ Exclude:
18
+ - 'lib/expressir/express/visitor.rb'
19
+
20
+ # Offense count: 2
10
21
  # This cop supports safe autocorrection (--autocorrect).
11
- # Configuration parameters: Max, AllowHeredoc, AllowURI, URISchemes, IgnoreCopDirectives, AllowedPatterns.
12
- # URISchemes: http, https
13
- Layout/LineLength:
22
+ # Configuration parameters: AutoCorrect, AllowUnusedKeywordArguments, IgnoreEmptyMethods, IgnoreNotImplementedMethods.
23
+ Lint/UnusedMethodArgument:
14
24
  Exclude:
15
- - 'exe/expressir-format-test'
25
+ - 'lib/expressir/express/parser.rb'
26
+
27
+ # Offense count: 54
28
+ # Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes, Max.
29
+ Metrics/AbcSize:
30
+ Exclude:
31
+ - 'lib/expressir/express/formatter.rb'
32
+ - 'lib/expressir/express/hyperlink_formatter.rb'
33
+ - 'lib/expressir/express/resolve_references_model_visitor.rb'
34
+ - 'lib/expressir/express/visitor.rb'
35
+ - 'lib/expressir/model/declarations/function.rb'
36
+ - 'lib/expressir/model/declarations/procedure.rb'
37
+ - 'lib/expressir/model/declarations/rule.rb'
38
+ - 'lib/expressir/model/declarations/schema.rb'
39
+ - 'lib/expressir/model/model_element.rb'
16
40
 
17
41
  # Offense count: 1
18
42
  # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
19
43
  # AllowedMethods: refine
20
44
  Metrics/BlockLength:
21
- Max: 36
45
+ Max: 29
46
+
47
+ # Offense count: 40
48
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
49
+ Metrics/CyclomaticComplexity:
50
+ Exclude:
51
+ - 'lib/expressir/express/formatter.rb'
52
+ - 'lib/expressir/express/visitor.rb'
53
+ - 'lib/expressir/model/declarations/function.rb'
54
+ - 'lib/expressir/model/declarations/procedure.rb'
55
+ - 'lib/expressir/model/declarations/rule.rb'
56
+ - 'lib/expressir/model/declarations/schema.rb'
57
+ - 'lib/expressir/model/model_element.rb'
58
+
59
+ # Offense count: 74
60
+ # Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
61
+ Metrics/MethodLength:
62
+ Max: 135
63
+
64
+ # Offense count: 36
65
+ # Configuration parameters: AllowedMethods, AllowedPatterns, Max.
66
+ Metrics/PerceivedComplexity:
67
+ Exclude:
68
+ - 'lib/expressir/express/formatter.rb'
69
+ - 'lib/expressir/express/visitor.rb'
70
+ - 'lib/expressir/model/declarations/function.rb'
71
+ - 'lib/expressir/model/declarations/procedure.rb'
72
+ - 'lib/expressir/model/declarations/rule.rb'
73
+ - 'lib/expressir/model/declarations/schema.rb'
74
+ - 'lib/expressir/model/model_element.rb'
75
+
76
+ # Offense count: 5
77
+ Performance/FixedSize:
78
+ Exclude:
79
+ - 'lib/expressir/express/formatter.rb'
80
+
81
+ # Offense count: 1
82
+ Style/MissingRespondToMissing:
83
+ Exclude:
84
+ - 'lib/expressir/express/visitor.rb'
data/Gemfile CHANGED
@@ -9,7 +9,7 @@ gem "pry"
9
9
  gem "rake", "~> 13.0"
10
10
  gem "rspec", "~> 3.0"
11
11
  gem "rubocop", "~> 1.21"
12
- gem "rubocop-performance", require: false
12
+ gem "rubocop-performance"
13
13
  gem "rubocop-rake", require: false
14
14
  gem "rubocop-rspec", require: false
15
15
  gem "webrick", "~> 1.7"
data/README.adoc CHANGED
@@ -142,6 +142,52 @@ schemas = repo_hash['schemas']
142
142
  schemas.map {|s| s["id"] }
143
143
  ----
144
144
 
145
+ === Convert models to liquid
146
+
147
+ Use `to_liquid` method to convert the models of `Expressir::Model::*` to liquid
148
+ drop models (`Expressir::Liquid::*`).
149
+
150
+ Example:
151
+
152
+ [source,ruby]
153
+ ----
154
+ repo = Expressir::Express::Parser.from_file("path/to/file.exp")
155
+ repo_drop = repo.to_liquid
156
+ ----
157
+
158
+ where `repo` is an instance of `Expressir::Model::Repository` and
159
+ `repo_drop` is an instance of `Expressir::Liquid::RepositoryDrop`.
160
+
161
+ The liquid drop models of `Expressir::Liquid::*` have the same attributes
162
+ (`model_attr`) as the models of `Expressir::Model::*`.
163
+
164
+ For example, `Expressir::Model::Repository` has the following attributes:
165
+
166
+ - schemas
167
+
168
+ and each `Expressir::Model::Declarations::Schema` has the following attributes:
169
+
170
+ - file
171
+ - version
172
+ - interfaces
173
+ - constants
174
+ - entities
175
+ - subtype_constraints
176
+ - functions
177
+ - rules
178
+ - procedures
179
+
180
+ Thus, `Expressir::Liquid::Repository` has the same attribute `schemas`
181
+ and `Expressir::Liquid::Declarations::SchemaDrop` has same attribute `file`.
182
+
183
+ [source,ruby]
184
+ ----
185
+ repo = Expressir::Express::Parser.from_file("path/to/file.exp")
186
+ repo_drop = repo.to_liquid
187
+ schema = repo_drop.schemas.first
188
+ schema.file = "path/to/file.exp"
189
+ ----
190
+
145
191
  == Contributing
146
192
 
147
193
  First, thank you for contributing! We love pull requests from everyone. By
@@ -49,7 +49,8 @@ exp_files = [
49
49
  "../iso-10303-stepmod/data/resources/security_classification_schema/security_classification_schema_annotated.exp",
50
50
  "../iso-10303-stepmod/data/resources/support_resource_schema/support_resource_schema_annotated.exp",
51
51
  # full test (6m18s + 8s = 6m26s)
52
- # *`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip.split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
52
+ # *`bundle exec ../stepmod-utils/exe/stepmod-find-express-files ../iso-10303-stepmod`.strip
53
+ # .split("\n").map{|file| File.exists?(file.sub(/\.exp$/, '_annotated.exp')) ? file.sub(/\.exp$/, '_annotated.exp') : file}
53
54
  ]
54
55
 
55
56
  start = Time.now
data/expressir.gemspec CHANGED
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
16
16
 
17
17
  spec.bindir = "exe"
18
18
  spec.require_paths = ["lib"]
19
- spec.required_ruby_version = Gem::Requirement.new(">= 3.0.0")
20
19
 
21
20
  spec.metadata["homepage_uri"] = spec.homepage
22
21
  spec.metadata["source_code_uri"] = spec.homepage
@@ -33,7 +32,7 @@ Gem::Specification.new do |spec|
33
32
 
34
33
  spec.test_files = `git ls-files -- {spec}/*`.split("\n")
35
34
 
36
- spec.add_dependency "thor", "~> 1.0"
37
- spec.add_dependency "parslet", "~> 2.0"
38
35
  spec.add_dependency "liquid"
36
+ spec.add_dependency "parslet", "~> 2.0"
37
+ spec.add_dependency "thor", "~> 1.0"
39
38
  end
@@ -1,6 +1,6 @@
1
- require 'yaml'
2
- require 'zlib'
3
- require 'expressir/model'
1
+ require "yaml"
2
+ require "zlib"
3
+ require "expressir/model"
4
4
 
5
5
  module Expressir
6
6
  module Express
@@ -16,7 +16,7 @@ module Expressir
16
16
 
17
17
  cache = Model::Cache.new(
18
18
  version: version,
19
- content: content
19
+ content: content,
20
20
  )
21
21
 
22
22
  hash = cache.to_hash(root_path: root_path)
@@ -37,7 +37,7 @@ module Expressir
37
37
 
38
38
  yaml_compressed = File.binread(file)
39
39
  yaml = Zlib::Inflate.inflate(yaml_compressed)
40
- hash = YAML.load(yaml)
40
+ hash = YAML.safe_load(yaml)
41
41
  cache = Model::ModelElement.from_hash(hash, root_path: root_path)
42
42
 
43
43
  if cache.version != version
@@ -48,4 +48,4 @@ module Expressir
48
48
  end
49
49
  end
50
50
  end
51
- end
51
+ end