expressir 1.2.3-aarch64-linux

Sign up to get free protection for your applications and to get access to all the features.
Files changed (181) hide show
  1. checksums.yaml +7 -0
  2. data/.cross_rubies +21 -0
  3. data/.github/workflows/rake.yml +96 -0
  4. data/.github/workflows/release.yml +120 -0
  5. data/.gitignore +17 -0
  6. data/.gitmodules +3 -0
  7. data/.hound.yml +3 -0
  8. data/.rspec +2 -0
  9. data/.rubocop.yml +8 -0
  10. data/.yardopts +11 -0
  11. data/Gemfile +4 -0
  12. data/README.adoc +147 -0
  13. data/Rakefile +14 -0
  14. data/bin/console +12 -0
  15. data/bin/rspec +29 -0
  16. data/bin/setup +8 -0
  17. data/demo.rb +18 -0
  18. data/docs/development.md +90 -0
  19. data/exe/expressir +20 -0
  20. data/exe/format +18 -0
  21. data/exe/format-test +81 -0
  22. data/exe/generate-parser +48 -0
  23. data/expressir.gemspec +46 -0
  24. data/lib/expressir/cli/ui.rb +36 -0
  25. data/lib/expressir/cli.rb +21 -0
  26. data/lib/expressir/config.rb +23 -0
  27. data/lib/expressir/express/2.7/express_parser.so +0 -0
  28. data/lib/expressir/express/3.0/express_parser.so +0 -0
  29. data/lib/expressir/express/3.1/express_parser.so +0 -0
  30. data/lib/expressir/express/cache.rb +51 -0
  31. data/lib/expressir/express/formatter.rb +1608 -0
  32. data/lib/expressir/express/hyperlink_formatter.rb +36 -0
  33. data/lib/expressir/express/model_visitor.rb +24 -0
  34. data/lib/expressir/express/parser.rb +81 -0
  35. data/lib/expressir/express/resolve_references_model_visitor.rb +31 -0
  36. data/lib/expressir/express/schema_head_formatter.rb +23 -0
  37. data/lib/expressir/express/visitor.rb +2574 -0
  38. data/lib/expressir/model/cache.rb +17 -0
  39. data/lib/expressir/model/data_type.rb +9 -0
  40. data/lib/expressir/model/data_types/aggregate.rb +31 -0
  41. data/lib/expressir/model/data_types/array.rb +31 -0
  42. data/lib/expressir/model/data_types/bag.rb +25 -0
  43. data/lib/expressir/model/data_types/binary.rb +22 -0
  44. data/lib/expressir/model/data_types/boolean.rb +10 -0
  45. data/lib/expressir/model/data_types/enumeration.rb +25 -0
  46. data/lib/expressir/model/data_types/enumeration_item.rb +26 -0
  47. data/lib/expressir/model/data_types/generic.rb +26 -0
  48. data/lib/expressir/model/data_types/generic_entity.rb +26 -0
  49. data/lib/expressir/model/data_types/integer.rb +10 -0
  50. data/lib/expressir/model/data_types/list.rb +28 -0
  51. data/lib/expressir/model/data_types/logical.rb +10 -0
  52. data/lib/expressir/model/data_types/number.rb +10 -0
  53. data/lib/expressir/model/data_types/real.rb +19 -0
  54. data/lib/expressir/model/data_types/select.rb +28 -0
  55. data/lib/expressir/model/data_types/set.rb +25 -0
  56. data/lib/expressir/model/data_types/string.rb +22 -0
  57. data/lib/expressir/model/declaration.rb +9 -0
  58. data/lib/expressir/model/declarations/attribute.rb +47 -0
  59. data/lib/expressir/model/declarations/constant.rb +34 -0
  60. data/lib/expressir/model/declarations/entity.rb +53 -0
  61. data/lib/expressir/model/declarations/function.rb +67 -0
  62. data/lib/expressir/model/declarations/interface.rb +28 -0
  63. data/lib/expressir/model/declarations/interface_item.rb +23 -0
  64. data/lib/expressir/model/declarations/interfaced_item.rb +37 -0
  65. data/lib/expressir/model/declarations/parameter.rb +34 -0
  66. data/lib/expressir/model/declarations/procedure.rb +64 -0
  67. data/lib/expressir/model/declarations/remark_item.rb +21 -0
  68. data/lib/expressir/model/declarations/rule.rb +71 -0
  69. data/lib/expressir/model/declarations/schema.rb +117 -0
  70. data/lib/expressir/model/declarations/schema_version.rb +22 -0
  71. data/lib/expressir/model/declarations/schema_version_item.rb +22 -0
  72. data/lib/expressir/model/declarations/subtype_constraint.rb +40 -0
  73. data/lib/expressir/model/declarations/type.rb +45 -0
  74. data/lib/expressir/model/declarations/unique_rule.rb +31 -0
  75. data/lib/expressir/model/declarations/variable.rb +34 -0
  76. data/lib/expressir/model/declarations/where_rule.rb +31 -0
  77. data/lib/expressir/model/expression.rb +9 -0
  78. data/lib/expressir/model/expressions/aggregate_initializer.rb +19 -0
  79. data/lib/expressir/model/expressions/aggregate_initializer_item.rb +22 -0
  80. data/lib/expressir/model/expressions/binary_expression.rb +53 -0
  81. data/lib/expressir/model/expressions/entity_constructor.rb +22 -0
  82. data/lib/expressir/model/expressions/function_call.rb +22 -0
  83. data/lib/expressir/model/expressions/interval.rb +34 -0
  84. data/lib/expressir/model/expressions/query_expression.rb +35 -0
  85. data/lib/expressir/model/expressions/unary_expression.rb +27 -0
  86. data/lib/expressir/model/identifier.rb +34 -0
  87. data/lib/expressir/model/literal.rb +9 -0
  88. data/lib/expressir/model/literals/binary.rb +19 -0
  89. data/lib/expressir/model/literals/integer.rb +19 -0
  90. data/lib/expressir/model/literals/logical.rb +23 -0
  91. data/lib/expressir/model/literals/real.rb +19 -0
  92. data/lib/expressir/model/literals/string.rb +22 -0
  93. data/lib/expressir/model/model_element.rb +208 -0
  94. data/lib/expressir/model/reference.rb +9 -0
  95. data/lib/expressir/model/references/attribute_reference.rb +22 -0
  96. data/lib/expressir/model/references/group_reference.rb +22 -0
  97. data/lib/expressir/model/references/index_reference.rb +27 -0
  98. data/lib/expressir/model/references/simple_reference.rb +24 -0
  99. data/lib/expressir/model/repository.rb +23 -0
  100. data/lib/expressir/model/statement.rb +9 -0
  101. data/lib/expressir/model/statements/alias.rb +35 -0
  102. data/lib/expressir/model/statements/assignment.rb +22 -0
  103. data/lib/expressir/model/statements/case.rb +25 -0
  104. data/lib/expressir/model/statements/case_action.rb +22 -0
  105. data/lib/expressir/model/statements/compound.rb +19 -0
  106. data/lib/expressir/model/statements/escape.rb +10 -0
  107. data/lib/expressir/model/statements/if.rb +25 -0
  108. data/lib/expressir/model/statements/null.rb +10 -0
  109. data/lib/expressir/model/statements/procedure_call.rb +22 -0
  110. data/lib/expressir/model/statements/repeat.rb +47 -0
  111. data/lib/expressir/model/statements/return.rb +19 -0
  112. data/lib/expressir/model/statements/skip.rb +10 -0
  113. data/lib/expressir/model/supertype_expression.rb +9 -0
  114. data/lib/expressir/model/supertype_expressions/binary_supertype_expression.rb +29 -0
  115. data/lib/expressir/model/supertype_expressions/oneof_supertype_expression.rb +19 -0
  116. data/lib/expressir/model.rb +79 -0
  117. data/lib/expressir/version.rb +3 -0
  118. data/lib/expressir.rb +20 -0
  119. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.exp +9589 -0
  120. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.owl +36619 -0
  121. data/original/examples/ap233/ap233e1_arm_lf_stepmod-2010-11-12.xml +13294 -0
  122. data/original/examples/employment/eclipse/.project +17 -0
  123. data/original/examples/employment/eclipse/Export/Employment.png +0 -0
  124. data/original/examples/employment/eclipse/Express/employment_schema.exp +33 -0
  125. data/original/examples/employment/eclipse/Express/employment_schema.xmi +77 -0
  126. data/original/examples/employment/eclipse/Express/employment_schema.xml +93 -0
  127. data/original/examples/employment/eclipse/Models/Employment.uml +4 -0
  128. data/original/examples/employment/eclipse/Models/Employment.umldi +240 -0
  129. data/original/examples/employment/eclipse/readme.txt +7 -0
  130. data/original/examples/employment/employment_schema.exp +33 -0
  131. data/original/examples/employment/employment_schema.rb +232 -0
  132. data/original/examples/employment/employment_schema.xml +93 -0
  133. data/original/examples/employment/employment_schema___module.rb +46 -0
  134. data/original/examples/employment/employment_schema___p28attr.rb +126 -0
  135. data/original/examples/employment/employment_schema___p28inst.rb +26 -0
  136. data/original/examples/employment/example_employment_data.xml +1 -0
  137. data/original/examples/employment/example_employment_data_copy.xml +1 -0
  138. data/original/examples/employment/example_employment_reader.rb +30 -0
  139. data/original/examples/employment/example_employment_writer.rb +51 -0
  140. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.exp +3710 -0
  141. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.owl +35880 -0
  142. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xmi +15357 -0
  143. data/original/examples/plcs/ap239e1_arm_lf_dexlib_2010-01-06.xml +9468 -0
  144. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.exp +8404 -0
  145. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.owl +43147 -0
  146. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xmi +18341 -0
  147. data/original/examples/plcs/ap239e2_arm_lf_stepmod-2010-01-25.xml +11632 -0
  148. data/original/exp2ruby.rb +525 -0
  149. data/original/expsm.rb +34 -0
  150. data/original/mapping_owl.rb +1018 -0
  151. data/original/mapping_sysml.rb +2281 -0
  152. data/original/mapping_uml2.rb +599 -0
  153. data/original/mapping_uml2_eclipse.rb +433 -0
  154. data/original/reeper.rb +134 -0
  155. data/rakelib/cross-ruby.rake +316 -0
  156. data/spec/acceptance/version_spec.rb +12 -0
  157. data/spec/expressir/express/cache_spec.rb +64 -0
  158. data/spec/expressir/express/formatter_spec.rb +127 -0
  159. data/spec/expressir/express/parser_spec.rb +98 -0
  160. data/spec/expressir/model/model_element_spec.rb +266 -0
  161. data/spec/expressr_spec.rb +5 -0
  162. data/spec/spec_helper.rb +17 -0
  163. data/spec/support/console_helper.rb +29 -0
  164. data/spec/syntax/multiple.exp +23 -0
  165. data/spec/syntax/multiple.yaml +198 -0
  166. data/spec/syntax/multiple_formatted.exp +71 -0
  167. data/spec/syntax/multiple_hyperlink_formatted.exp +71 -0
  168. data/spec/syntax/multiple_schema_head_hyperlink_formatted.exp +13 -0
  169. data/spec/syntax/remark.exp +191 -0
  170. data/spec/syntax/remark.yaml +466 -0
  171. data/spec/syntax/remark_formatted.exp +227 -0
  172. data/spec/syntax/single.exp +4 -0
  173. data/spec/syntax/single.yaml +18 -0
  174. data/spec/syntax/single_formatted.exp +10 -0
  175. data/spec/syntax/single_formatted.yaml +36 -0
  176. data/spec/syntax/syntax.exp +333 -0
  177. data/spec/syntax/syntax.yaml +3509 -0
  178. data/spec/syntax/syntax_formatted.exp +902 -0
  179. data/spec/syntax/syntax_hyperlink_formatted.exp +902 -0
  180. data/spec/syntax/syntax_schema_head_formatted.exp +18 -0
  181. metadata +398 -0
@@ -0,0 +1,316 @@
1
+ require "rbconfig"
2
+ require "shellwords"
3
+
4
+ CrossRuby = Struct.new(:version, :host) do
5
+ WINDOWS_PLATFORM_REGEX = /mingw|mswin/
6
+ MINGW32_PLATFORM_REGEX = /mingw32/
7
+ LINUX_PLATFORM_REGEX = /linux/
8
+ DARWIN_PLATFORM_REGEX = /darwin/
9
+
10
+ def windows?
11
+ !!(platform =~ WINDOWS_PLATFORM_REGEX)
12
+ end
13
+
14
+ def linux?
15
+ !!(platform =~ LINUX_PLATFORM_REGEX)
16
+ end
17
+
18
+ def darwin?
19
+ !!(platform =~ DARWIN_PLATFORM_REGEX)
20
+ end
21
+
22
+ def ver
23
+ @ver ||= version[/\A[^-]+/]
24
+ end
25
+
26
+ def minor_ver
27
+ @minor_ver ||= ver[/\A\d\.\d(?=\.)/]
28
+ end
29
+
30
+ def api_ver_suffix
31
+ case minor_ver
32
+ when nil
33
+ raise "CrossRuby.api_ver_suffix: unsupported version: #{ver}"
34
+ else
35
+ minor_ver.delete(".") << "0"
36
+ end
37
+ end
38
+
39
+ def platform
40
+ @platform ||= case host
41
+ when /\Ax86_64.*mingw32/
42
+ "x64-mingw32"
43
+ when /\Ai[3-6]86.*mingw32/
44
+ "x86-mingw32"
45
+ when /\Ax86_64.*linux/
46
+ "x86_64-linux"
47
+ when /\A(arm64|aarch64).*linux/
48
+ "aarch64-linux"
49
+ when /\Ai[3-6]86.*linux/
50
+ "x86-linux"
51
+ when /\Ax86_64-darwin/
52
+ "x86_64-darwin"
53
+ when /\Aarm64-darwin/
54
+ "arm64-darwin"
55
+ else
56
+ raise "CrossRuby.platform: unsupported host: #{host}"
57
+ end
58
+ end
59
+
60
+ def tool(name)
61
+ (@binutils_prefix ||= case platform
62
+ when "x64-mingw32"
63
+ "x86_64-w64-mingw32-"
64
+ when "x86-mingw32"
65
+ "i686-w64-mingw32-"
66
+ when "x86_64-linux"
67
+ "x86_64-redhat-linux-"
68
+ when "aarch64-linux"
69
+ "aarch64-redhat-linux-"
70
+ when "x86-linux"
71
+ "i686-redhat-linux-"
72
+ when /x86_64.*darwin/
73
+ "x86_64-apple-darwin-"
74
+ when /a.*64.*darwin/
75
+ "aarch64-apple-darwin-"
76
+ else
77
+ raise "CrossRuby.tool: unmatched platform: #{platform}"
78
+ end) + name
79
+ end
80
+
81
+ def target_file_format
82
+ case platform
83
+ when "x64-mingw32"
84
+ "pei-x86-64"
85
+ when "x86-mingw32"
86
+ "pei-i386"
87
+ when "x86_64-linux"
88
+ "elf64-x86-64"
89
+ when "aarch64-linux"
90
+ "elf64-arm64"
91
+ when "x86-linux"
92
+ "elf32-i386"
93
+ when "x86_64-darwin"
94
+ "Mach-O 64-bit x86-64" # hmm
95
+ when "arm64-darwin"
96
+ "Mach-O arm64"
97
+ else
98
+ raise "CrossRuby.target_file_format: unmatched platform: #{platform}"
99
+ end
100
+ end
101
+
102
+ def dll_ext
103
+ darwin? ? "bundle" : "so"
104
+ end
105
+
106
+ def dll_staging_path
107
+ "tmp/#{platform}/stage/lib/#{GEMSPEC.name}/#{minor_ver}/#{GEMSPEC.name}.#{dll_ext}"
108
+ end
109
+
110
+ def libruby_dll
111
+ case platform
112
+ when "x64-mingw32"
113
+ "x64-msvcrt-ruby#{api_ver_suffix}.dll"
114
+ when "x86-mingw32"
115
+ "msvcrt-ruby#{api_ver_suffix}.dll"
116
+ else
117
+ raise "CrossRuby.libruby_dll: unmatched platform: #{platform}"
118
+ end
119
+ end
120
+
121
+ def allowed_dlls
122
+ case platform
123
+ when MINGW32_PLATFORM_REGEX
124
+ [
125
+ "kernel32.dll",
126
+ "msvcrt.dll",
127
+ "ws2_32.dll",
128
+ "user32.dll",
129
+ "advapi32.dll",
130
+ libruby_dll,
131
+ ]
132
+ when LINUX_PLATFORM_REGEX
133
+ [
134
+ "libm.so.6",
135
+ *(case
136
+ when ver < "2.6.0"
137
+ "libpthread.so.0"
138
+ end),
139
+ "libc.so.6",
140
+ "libdl.so.2", # on old dists only - now in libc
141
+ ]
142
+ when DARWIN_PLATFORM_REGEX
143
+ [
144
+ "/usr/lib/libSystem.B.dylib",
145
+ "/usr/lib/liblzma.5.dylib",
146
+ "/usr/lib/libobjc.A.dylib",
147
+ ]
148
+ else
149
+ raise "CrossRuby.allowed_dlls: unmatched platform: #{platform}"
150
+ end
151
+ end
152
+
153
+ def dll_ref_versions
154
+ case platform
155
+ when LINUX_PLATFORM_REGEX
156
+ { "GLIBC" => "2.17" }
157
+ else
158
+ raise "CrossRuby.dll_ref_versions: unmatched platform: #{platform}"
159
+ end
160
+ end
161
+ end
162
+
163
+ CROSS_RUBIES = File.read(".cross_rubies").split("\n").map do |line|
164
+ case line
165
+ when /\A([^#]+):([^#]+)/
166
+ CrossRuby.new($1, $2)
167
+ end
168
+ end.compact
169
+
170
+ ENV["RUBY_CC_VERSION"] = CROSS_RUBIES.map(&:ver).uniq.join(":")
171
+
172
+ require "rake_compiler_dock"
173
+
174
+ def verify_dll(dll, cross_ruby)
175
+ allowed_imports = cross_ruby.allowed_dlls
176
+ dump = `#{["env", "LANG=C", cross_ruby.tool("objdump"), "-p", dll].shelljoin}`
177
+
178
+ if cross_ruby.windows?
179
+ raise "unexpected file format for generated dll #{dll}" unless /file format #{Regexp.quote(cross_ruby.target_file_format)}\s/ === dump
180
+ raise "export function Init_nokogiri not in dll #{dll}" unless /Table.*\sInit_nokogiri\s/mi === dump
181
+
182
+ # Verify that the DLL dependencies are all allowed.
183
+ actual_imports = dump.scan(/DLL Name: (.*)$/).map(&:first).map(&:downcase).uniq
184
+ if !(actual_imports - allowed_imports).empty?
185
+ raise "unallowed so imports #{actual_imports.inspect} in #{dll} (allowed #{allowed_imports.inspect})"
186
+ end
187
+
188
+ elsif cross_ruby.linux?
189
+ nm = `#{["env", "LANG=C", cross_ruby.tool("nm"), "-D", dll].shelljoin}`
190
+
191
+ raise "unexpected file format for generated dll #{dll}" unless /file format #{Regexp.quote(cross_ruby.target_file_format)}\s/ === dump
192
+ raise "export function Init_nokogiri not in dll #{dll}" unless / T Init_nokogiri/ === nm
193
+
194
+ # Verify that the DLL dependencies are all allowed.
195
+ actual_imports = dump.scan(/NEEDED\s+(.*)/).map(&:first).uniq
196
+ if !(actual_imports - allowed_imports).empty?
197
+ raise "unallowed so imports #{actual_imports.inspect} in #{dll} (allowed #{allowed_imports.inspect})"
198
+ end
199
+
200
+ # Verify that the expected so version requirements match the actual dependencies.
201
+ ref_versions_data = dump.scan(/0x[\da-f]+ 0x[\da-f]+ \d+ (\w+)_([\d\.]+)$/i)
202
+ # Build a hash of library versions like {"LIBUDEV"=>"183", "GLIBC"=>"2.17"}
203
+ actual_ref_versions = ref_versions_data.each.with_object({}) do |(lib, ver), h|
204
+ if !h[lib] || ver.split(".").map(&:to_i).pack("C*") > h[lib].split(".").map(&:to_i).pack("C*")
205
+ h[lib] = ver
206
+ end
207
+ end
208
+ if actual_ref_versions != cross_ruby.dll_ref_versions
209
+ raise "unexpected so version requirements #{actual_ref_versions.inspect} in #{dll}"
210
+ end
211
+
212
+ elsif cross_ruby.darwin?
213
+ nm = `#{["env", "LANG=C", cross_ruby.tool("nm"), "-g", dll].shelljoin}`
214
+
215
+ raise "unexpected file format for generated dll #{dll}" unless /file format #{Regexp.quote(cross_ruby.target_file_format)}\s/ === dump
216
+ raise "export function Init_nokogiri not in dll #{dll}" unless / T _?Init_nokogiri/ === nm
217
+
218
+ # if liblzma is being referenced, let's make sure it's referring
219
+ # to the system-installed file and not the homebrew-installed file.
220
+ ldd = `#{["env", "LANG=C", cross_ruby.tool("otool"), "-L", dll].shelljoin}`
221
+ if liblzma_refs = ldd.scan(/^\t([^ ]+) /).map(&:first).uniq.grep(/liblzma/)
222
+ liblzma_refs.each do |ref|
223
+ new_ref = File.join("/usr/lib", File.basename(ref))
224
+ sh ["env", "LANG=C", cross_ruby.tool("install_name_tool"), "-change", ref, new_ref, dll].shelljoin
225
+ end
226
+
227
+ # reload!
228
+ ldd = `#{["env", "LANG=C", cross_ruby.tool("otool"), "-L", dll].shelljoin}`
229
+ end
230
+
231
+ # Verify that the DLL dependencies are all allowed.
232
+ ldd = `#{["env", "LANG=C", cross_ruby.tool("otool"), "-L", dll].shelljoin}`
233
+ actual_imports = ldd.scan(/^\t([^ ]+) /).map(&:first).uniq
234
+ if !(actual_imports - allowed_imports).empty?
235
+ raise "unallowed so imports #{actual_imports.inspect} in #{dll} (allowed #{allowed_imports.inspect})"
236
+ end
237
+ end
238
+ puts "verify_dll: #{dll}: passed shared library sanity checks"
239
+ end
240
+
241
+ CROSS_RUBIES.each do |cross_ruby|
242
+ task cross_ruby.dll_staging_path do |t|
243
+ verify_dll t.name, cross_ruby
244
+ end
245
+ end
246
+
247
+ def gem_builder(plat)
248
+ # use Task#invoke because the pkg/*gem task is defined at runtime
249
+ Rake::Task["native:#{plat}"].invoke
250
+ Rake::Task["pkg/#{GEMSPEC.full_name}-#{Gem::Platform.new(plat).to_s}.gem"].invoke
251
+ end
252
+
253
+ namespace "gem" do
254
+ REDHAT_PREREQ = "sudo yum install -y git"
255
+ UBUNTU_PREREQ = "sudo apt-get update -y && sudo apt-get install -y automake autoconf libtool build-essential"
256
+ CROSS_RUBIES.find_all { |cr| cr.windows? || cr.linux? || cr.darwin? }.map(&:platform).uniq.each do |plat|
257
+ pre_req = case plat
258
+ when /\linux/
259
+ "if [[ $(awk -F= '/^NAME/{print $2}' /etc/os-release) == '\"Ubuntu\"' ]]; then #{UBUNTU_PREREQ}; else #{REDHAT_PREREQ}; fi"
260
+ else
261
+ "#{UBUNTU_PREREQ}"
262
+ end
263
+ desc "build native gem for #{plat} platform"
264
+ task plat do
265
+ RakeCompilerDock.sh <<~EOT, platform: plat
266
+ #{pre_req} &&
267
+ gem install bundler --no-document &&
268
+ bundle &&
269
+ bundle exec rake gem:#{plat}:builder MAKE='nice make -j`nproc`'
270
+ EOT
271
+ end
272
+
273
+ namespace plat do
274
+ desc "build native gem for #{plat} platform (guest container)"
275
+ task "builder" do
276
+ gem_builder(plat)
277
+ end
278
+ task "guest" => "builder" # TODO: remove me after this code is on master, temporary backwards compat for CI
279
+ end
280
+ end
281
+
282
+ desc "build native gems for windows"
283
+ multitask "windows" => CROSS_RUBIES.find_all(&:windows?).map(&:platform).uniq
284
+
285
+ desc "build native gems for linux"
286
+ multitask "linux" => CROSS_RUBIES.find_all(&:linux?).map(&:platform).uniq
287
+
288
+ desc "build native gems for darwin"
289
+ multitask "darwin" => CROSS_RUBIES.find_all(&:darwin?).map(&:platform).uniq
290
+ end
291
+
292
+ namespace "native" do
293
+ plat = "x86_64-darwin"
294
+ namespace plat do
295
+ desc "build native gem for #{plat} platform on host OS"
296
+ task "builder" do
297
+ gem_builder(plat)
298
+ end
299
+ task "guest" => "builder" # TODO: remove me after this code is on master, temporary backwards compat for CI
300
+ end
301
+ end
302
+
303
+ require "rake/extensiontask"
304
+
305
+ Rake::ExtensionTask.new("express_parser", GEMSPEC) do |ext|
306
+ ext.ext_dir = "ext/express-parser"
307
+ ext.lib_dir = File.join(*['lib', 'expressir', 'express', ENV['FAT_DIR']].compact)
308
+ ext.config_options << ENV['EXTOPTS']
309
+ ext.cross_compile = true
310
+ ext.cross_platform = CROSS_RUBIES.map(&:platform).uniq
311
+ ext.cross_config_options << "--enable-cross-build"
312
+ ext.cross_compiling do |spec|
313
+ spec.files.reject! { |path| File.fnmatch?('ext/*', path) }
314
+ spec.dependencies.reject! { |dep| dep.name == 'rice' }
315
+ end
316
+ end
@@ -0,0 +1,12 @@
1
+ require "spec_helper"
2
+
3
+ RSpec.describe "Expressir" do
4
+ describe "version" do
5
+ it "displays the current verison" do
6
+ command = %w(version)
7
+ output = capture_stdout { Expressir::Cli.start(command) }
8
+
9
+ expect(output).to include("Version #{Expressir::VERSION}")
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,64 @@
1
+ require "yaml"
2
+ require "tempfile"
3
+ require "spec_helper"
4
+ require "expressir/express/parser"
5
+ require "expressir/express/cache"
6
+
7
+ RSpec.describe Expressir::Express::Cache do
8
+ TEST_VERSION = "0.0.0"
9
+
10
+ describe ".to_file" do
11
+ it "exports an object" do
12
+ temp_file = Tempfile.new
13
+
14
+ repository = Expressir::Model::Repository.new
15
+
16
+ begin
17
+ Expressir::Express::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)
18
+
19
+ size = File.size(temp_file)
20
+
21
+ expect(size).to be > 0
22
+ ensure
23
+ temp_file.close
24
+ temp_file.unlink
25
+ end
26
+ end
27
+ end
28
+
29
+ describe ".from_file" do
30
+ it "parses a file" do
31
+ temp_file = Tempfile.new
32
+
33
+ repository = Expressir::Model::Repository.new
34
+
35
+ begin
36
+ Expressir::Express::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)
37
+
38
+ result = Expressir::Express::Cache.from_file(temp_file, test_overwrite_version: TEST_VERSION)
39
+
40
+ expect(result).to be_instance_of(Expressir::Model::Repository)
41
+ ensure
42
+ temp_file.close
43
+ temp_file.unlink
44
+ end
45
+ end
46
+
47
+ it "fails parsing a file from a different Expressir version" do
48
+ temp_file = Tempfile.new
49
+
50
+ repository = Expressir::Model::Repository.new
51
+
52
+ begin
53
+ Expressir::Express::Cache.to_file(temp_file, repository, test_overwrite_version: TEST_VERSION)
54
+
55
+ expect do
56
+ Expressir::Express::Cache.from_file(temp_file)
57
+ end.to raise_error(Expressir::Error)
58
+ ensure
59
+ temp_file.close
60
+ temp_file.unlink
61
+ end
62
+ end
63
+ end
64
+ end
@@ -0,0 +1,127 @@
1
+ require "yaml"
2
+ require "spec_helper"
3
+ require "expressir/express/parser"
4
+ require "expressir/express/formatter"
5
+ require "expressir/express/schema_head_formatter"
6
+ require "expressir/express/hyperlink_formatter"
7
+
8
+ RSpec.describe Expressir::Express::Formatter do
9
+ describe ".format" do
10
+ it "exports an object (single.exp)" do
11
+ exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
12
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "single_formatted.exp")
13
+
14
+ repo = Expressir::Express::Parser.from_file(exp_file)
15
+
16
+ result = Expressir::Express::Formatter.format(repo)
17
+ # File.write(formatted_exp_file, result)
18
+ expected_result = File.read(formatted_exp_file)
19
+
20
+ expect(result).to eq(expected_result)
21
+ end
22
+
23
+ it "exports an object (multiple.exp)" do
24
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
25
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "multiple_formatted.exp")
26
+
27
+ repo = Expressir::Express::Parser.from_file(exp_file)
28
+
29
+ result = Expressir::Express::Formatter.format(repo)
30
+ # File.write(formatted_exp_file, result)
31
+ expected_result = File.read(formatted_exp_file)
32
+
33
+ expect(result).to eq(expected_result)
34
+ end
35
+
36
+ it "exports an object (remark.exp)" do
37
+ exp_file = Expressir.root_path.join("spec", "syntax", "remark.exp")
38
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "remark_formatted.exp")
39
+
40
+ repo = Expressir::Express::Parser.from_file(exp_file)
41
+
42
+ result = Expressir::Express::Formatter.format(repo)
43
+ # File.write(formatted_exp_file, result)
44
+ expected_result = File.read(formatted_exp_file)
45
+
46
+ expect(result).to eq(expected_result)
47
+ end
48
+
49
+ it "exports an object (syntax.exp)" do
50
+ exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
51
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "syntax_formatted.exp")
52
+
53
+ repo = Expressir::Express::Parser.from_file(exp_file)
54
+
55
+ result = Expressir::Express::Formatter.format(repo)
56
+ # File.write(formatted_exp_file, result)
57
+ expected_result = File.read(formatted_exp_file)
58
+
59
+ expect(result).to eq(expected_result)
60
+ end
61
+
62
+ it "exports an object with schema head formatter (syntax.exp)" do
63
+ exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
64
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "syntax_schema_head_formatted.exp")
65
+
66
+ repo = Expressir::Express::Parser.from_file(exp_file)
67
+
68
+ formatter = Class.new(Expressir::Express::Formatter) do
69
+ include Expressir::Express::SchemaHeadFormatter
70
+ end
71
+ result = formatter.format(repo)
72
+ # File.write(formatted_exp_file, result)
73
+ expected_result = File.read(formatted_exp_file)
74
+
75
+ expect(result).to eq(expected_result)
76
+ end
77
+
78
+ it "exports an object with hyperlink formatter (syntax.exp)" do
79
+ exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
80
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "syntax_hyperlink_formatted.exp")
81
+
82
+ repo = Expressir::Express::Parser.from_file(exp_file)
83
+
84
+ formatter = Class.new(Expressir::Express::Formatter) do
85
+ include Expressir::Express::HyperlinkFormatter
86
+ end
87
+ result = formatter.format(repo)
88
+ # File.write(formatted_exp_file, result)
89
+ expected_result = File.read(formatted_exp_file)
90
+
91
+ expect(result).to eq(expected_result)
92
+ end
93
+
94
+ it "exports an object with hyperlink formatter (multiple.exp)" do
95
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
96
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "multiple_hyperlink_formatted.exp")
97
+
98
+ repo = Expressir::Express::Parser.from_file(exp_file)
99
+
100
+ formatter = Class.new(Expressir::Express::Formatter) do
101
+ include Expressir::Express::HyperlinkFormatter
102
+ end
103
+ result = formatter.format(repo)
104
+ # File.write(formatted_exp_file, result)
105
+ expected_result = File.read(formatted_exp_file)
106
+
107
+ expect(result).to eq(expected_result)
108
+ end
109
+
110
+ it "exports an object with schema head and hyperlink formatter (multiple.exp)" do
111
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
112
+ formatted_exp_file = Expressir.root_path.join("spec", "syntax", "multiple_schema_head_hyperlink_formatted.exp")
113
+
114
+ repo = Expressir::Express::Parser.from_file(exp_file)
115
+
116
+ formatter = Class.new(Expressir::Express::Formatter) do
117
+ include Expressir::Express::SchemaHeadFormatter
118
+ include Expressir::Express::HyperlinkFormatter
119
+ end
120
+ result = formatter.format(repo)
121
+ # File.write(formatted_exp_file, result)
122
+ expected_result = File.read(formatted_exp_file)
123
+
124
+ expect(result).to eq(expected_result)
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,98 @@
1
+ require "yaml"
2
+ require "spec_helper"
3
+ require "expressir/express/parser"
4
+
5
+ RSpec.describe Expressir::Express::Parser do
6
+ describe ".from_file" do
7
+ it "parses a file (single.exp)" do
8
+ exp_file = Expressir.root_path.join("spec", "syntax", "single.exp")
9
+ yaml_file = Expressir.root_path.join("spec", "syntax", "single.yaml")
10
+
11
+ repo = Expressir::Express::Parser.from_file(exp_file)
12
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
13
+ # File.write(yaml_file, result)
14
+ expected_result = File.read(yaml_file)
15
+
16
+ expect(result).to eq(expected_result)
17
+ end
18
+
19
+ it "parses a file (multiple.exp)" do
20
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
21
+ yaml_file = Expressir.root_path.join("spec", "syntax", "multiple.yaml")
22
+
23
+ repo = Expressir::Express::Parser.from_file(exp_file)
24
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
25
+ # File.write(yaml_file, result)
26
+ expected_result = File.read(yaml_file)
27
+
28
+ expect(result).to eq(expected_result)
29
+ end
30
+
31
+ it "parses a file (syntax.exp)" do
32
+ exp_file = Expressir.root_path.join("spec", "syntax", "syntax.exp")
33
+ yaml_file = Expressir.root_path.join("spec", "syntax", "syntax.yaml")
34
+
35
+ repo = Expressir::Express::Parser.from_file(exp_file)
36
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
37
+ # File.write(yaml_file, result)
38
+ expected_result = File.read(yaml_file)
39
+
40
+ expect(result).to eq(expected_result)
41
+ end
42
+
43
+ it "parses a file (remark.exp)" do
44
+ exp_file = Expressir.root_path.join("spec", "syntax", "remark.exp")
45
+ yaml_file = Expressir.root_path.join("spec", "syntax", "remark.yaml")
46
+
47
+ repo = Expressir::Express::Parser.from_file(exp_file)
48
+ result = YAML.dump(repo.to_hash(root_path: Expressir.root_path))
49
+ # File.write(yaml_file, result)
50
+ expected_result = File.read(yaml_file)
51
+
52
+ expect(result).to eq(expected_result)
53
+ end
54
+
55
+ it "parses a file including original source (multiple.exp)" do
56
+ exp_file = Expressir.root_path.join("spec", "syntax", "multiple.exp")
57
+
58
+ input = File.read(exp_file)
59
+ repo = Expressir::Express::Parser.from_file(exp_file, include_source: true)
60
+
61
+ schema = repo.schemas.first
62
+ start_index = input.index("SCHEMA")
63
+ stop_index = input.index("END_SCHEMA;") + "END_SCHEMA;".length - 1
64
+ expected_result = input[start_index..stop_index]
65
+ expect(schema.source).to eq(expected_result)
66
+
67
+ entity = schema.entities.first
68
+ start_index = input.index("ENTITY")
69
+ stop_index = input.index("END_ENTITY;") + "END_ENTITY;".length - 1
70
+ expected_result = input[start_index..stop_index]
71
+ expect(entity.source).to eq(expected_result)
72
+ end
73
+ end
74
+
75
+ describe ".from_files" do
76
+ it "parses multiple files (single.exp, multiple.exp)" do
77
+ exp_files = [
78
+ Expressir.root_path.join("spec", "syntax", "single.exp"),
79
+ Expressir.root_path.join("spec", "syntax", "multiple.exp")
80
+ ]
81
+
82
+ repo = Expressir::Express::Parser.from_files(exp_files)
83
+
84
+ schemas = repo.schemas
85
+ expect(schemas.count).to eq(5)
86
+ expect(schemas[0].file).to eq(exp_files[0].to_s)
87
+ expect(schemas[0].id).to eq("single_schema")
88
+ expect(schemas[1].file).to eq(exp_files[1].to_s)
89
+ expect(schemas[1].id).to eq("multiple_schema")
90
+ expect(schemas[2].file).to eq(exp_files[1].to_s)
91
+ expect(schemas[2].id).to eq("multiple_schema2")
92
+ expect(schemas[3].file).to eq(exp_files[1].to_s)
93
+ expect(schemas[3].id).to eq("multiple_schema3")
94
+ expect(schemas[4].file).to eq(exp_files[1].to_s)
95
+ expect(schemas[4].id).to eq("multiple_schema4")
96
+ end
97
+ end
98
+ end