Class: Jing
- Inherits:
-
Object
- Object
- Jing
- Defined in:
- lib/tebako-runtime/adapters/jing.rb
Overview
Unpack jing.jar
Constant Summary collapse
- DEFAULT_JAR =
TebakoRuntime.extract_memfs(tmp)
Instance Method Summary collapse
-
#execute(options) ⇒ Object
The spawn shape, array form (the stock execute() backticks a shell string, which the tebako spawn hook deliberately skips; the mounted java only execs through the hook from an absolute-path array spawn).
-
#initialize(schema, options = nil) ⇒ Jing
constructor
A new instance of Jing.
- #original_initialize ⇒ Object
- #original_validate ⇒ Object
- #validate(xml) ⇒ Object
Constructor Details
#initialize(schema, options = nil) ⇒ Jing
Returns a new instance of Jing.
37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/tebako-runtime/adapters/jing.rb', line 37 def initialize(schema, = nil) original_initialize(TebakoRuntime.extract_memfs(schema, wild: true), ) # ruby-jing captures `:default => DEFAULT_JAR` at class-load time — # before this adapter replaced the constant with the extracted host # path. Force the extracted path per-instance (a nil option hash # leaves @options empty, and the builder's stale default would win). @options[:jar] = DEFAULT_JAR # The mounted openjdk toolkit payload's java wins over PATH (the # memfs-binary exec path; the bare "java" keeps the PATH answer). @options[:java] = TebakoRuntime.mounted_exe("openjdk", "java") end |
Instance Method Details
#execute(options) ⇒ Object
The spawn shape, array form (the stock execute() backticks a shell string, which the tebako spawn hook deliberately skips; the mounted java only execs through the hook from an absolute-path array spawn).
56 57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/tebako-runtime/adapters/jing.rb', line 56 def execute() # rubocop:disable Metrics/AbcSize cmd = [[:java]] cmd += [:java_opts].split if [:java_opts] cmd += ["-jar", [:jar].to_s] cmd << "-c" if [:compact] cmd += ["-e", [:encoding]] if [:encoding] cmd << "-i" if [:id_check] cmd += [[:schema].to_s, [:xmlfile].to_s] IO.popen(cmd, err: %i[child out], &:read) rescue SystemCallError => e raise ExecutionError, "jing execution failed: #{e}" end |
#original_initialize ⇒ Object
34 |
# File 'lib/tebako-runtime/adapters/jing.rb', line 34 alias original_initialize initialize |
#original_validate ⇒ Object
35 |
# File 'lib/tebako-runtime/adapters/jing.rb', line 35 alias original_validate validate |
#validate(xml) ⇒ Object
49 50 51 |
# File 'lib/tebako-runtime/adapters/jing.rb', line 49 def validate(xml) original_validate(TebakoRuntime.extract_memfs(xml)) end |