Module: Triangulum::Executor
- Included in:
- FlowSchemaExtraction, Validation
- Defined in:
- lib/triangulum/executor.rb
Overview
Triangulum::Executor
This module provides the execute methods for triangulum
Defined Under Namespace
Classes: BunNotFound, TriangulumFailed
Constant Summary collapse
- BUN_EXE =
Dir.glob(File.('../../exe/*/bun', __dir__)).find do |path| platform = Gem::Platform.new(File.basename(File.dirname(path))) Gem::Platform.match_gem?(platform, Gem::Platform.local.to_s) end
- IS_RUBY_PLATFORM_GEM =
Dir.glob(File.('../../exe/*/bun', __dir__)).empty?
Instance Method Summary collapse
Instance Method Details
#bun ⇒ Object
39 40 41 42 43 44 45 46 47 |
# File 'lib/triangulum/executor.rb', line 39 def bun if IS_RUBY_PLATFORM_GEM 'bun' else raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil? BUN_EXE end end |
#run_ts_triangulum(entrypoint, input) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/triangulum/executor.rb', line 20 def run_ts_triangulum(entrypoint, input) stdout_s, stderr_s, status = Open3.capture3( bun, 'run', entrypoint, stdin_data: input ) unless status.success? status_info = if status.signaled? "SIGNAL: #{status.termsig}" else "STATUS: #{status.exitstatus}" end raise TriangulumFailed, "#{status_info}\n\nOUT:\n#{stdout_s}\n\nERR:\n#{stderr_s}" end stdout_s end |