Skip to content

Commit e9bdcae

Browse files
committed
Add missing ruby platform gem
1 parent a5a1950 commit e9bdcae

2 files changed

Lines changed: 18 additions & 3 deletions

File tree

gem/lib/triangulum/validation.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ class BunNotFound < Triangulum::Error
1919
Gem::Platform.match_gem?(platform, Gem::Platform.local.to_s)
2020
end
2121

22+
IS_RUBY_PLATFORM_GEM = Dir.glob(File.expand_path('../../exe/*/bun', __dir__)).empty?
23+
2224
attr_reader :flow, :runtime_function_definitions, :data_types
2325

2426
def initialize(flow, runtime_function_definitions, data_types)
@@ -38,10 +40,8 @@ def validate
3840
private
3941

4042
def run_ts_triangulum(input)
41-
raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil?
42-
4343
stdout_s, stderr_s, status = Open3.capture3(
44-
BUN_EXE, 'run', ENTRYPOINT,
44+
bun, 'run', ENTRYPOINT,
4545
stdin_data: input
4646
)
4747

@@ -88,5 +88,15 @@ def parse_output(output)
8888
end
8989
)
9090
end
91+
92+
def bun
93+
if IS_RUBY_PLATFORM_GEM
94+
'bun'
95+
else
96+
raise BunNotFound, "No bundled bun binary found for #{Gem::Platform.local}" if BUN_EXE.nil?
97+
98+
BUN_EXE
99+
end
100+
end
91101
end
92102
end

gem/rakelib/package.rake

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ exepaths = []
1919

2020
TRIANGULUM_GEMSPEC = Bundler.load_gemspec('triangulum.gemspec')
2121

22+
ruby_gem_path = Gem::PackageTask.new(TRIANGULUM_GEMSPEC).define
23+
24+
desc 'Build the ruby (platform-independent) gem'
25+
task 'gem:ruby' => [ruby_gem_path]
26+
2227
BUN_PLATFORMS.each do |platform, (zip_filename, expected_checksum)|
2328
TRIANGULUM_GEMSPEC.dup.tap do |gemspec|
2429
exedir = File.join('exe', platform)

0 commit comments

Comments
 (0)