Skip to content

Commit 2029031

Browse files
committed
Support running on truffleruby & jruby
1 parent 70917d9 commit 2029031

File tree

6 files changed

+256
-68
lines changed

6 files changed

+256
-68
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ jobs:
1919
- "3.2.3"
2020
- "3.1.4"
2121
- "3.0.5"
22+
- "truffleruby-23.1.2"
23+
- "jruby-9.4.2.0"
2224

2325
steps:
2426
- uses: actions/checkout@v4

.rubocop.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Style/StringLiteralsInInterpolation:
1717
Enabled: true
1818
EnforcedStyle: double_quotes
1919

20+
Style/EndlessMethod:
21+
EnforcedStyle: disallow # truffleruby does not support endless method syntax on 23.x
22+
2023
Layout/LineLength:
2124
Max: 120
2225

lib/protobug/binary_encoding.rb

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,18 @@ def encode_varint(value, outbuf)
2222
break
2323
end
2424
end
25-
out.pack("c*", buffer: outbuf)
25+
pack(out, "c*", buffer: outbuf)
26+
end
27+
28+
if RUBY_ENGINE == "truffleruby"
29+
# see https://github.com/oracle/truffleruby/issues/3559
30+
def pack(ary, format, buffer:)
31+
buffer.concat ary.pack(format)
32+
end
33+
else
34+
def pack(ary, format, buffer:)
35+
ary.pack(format, buffer: buffer)
36+
end
2637
end
2738

2839
def encode_zigzag(size, value, outbuf)

0 commit comments

Comments
 (0)