Skip to content

Commit 9cb13ee

Browse files
author
Omar Qureshi
committed
feat(ruby): Ruby language bindings
1 parent 76b8d18 commit 9cb13ee

72 files changed

Lines changed: 21451 additions & 62 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/main.yml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@ jobs:
5252
cache: pip
5353
- name: Install python3-venv
5454
run: sudo apt install -y python3-venv
55+
- name: Set up Ruby 3.3
56+
uses: ruby/setup-ruby@v1
57+
with:
58+
ruby-version: "3.3"
5559
- name: Cache
5660
uses: actions/cache@v5
5761
with:
@@ -136,6 +140,10 @@ jobs:
136140
cache: pip
137141
- name: Install python3-venv
138142
run: sudo apt install -y python3-venv
143+
- name: Set up Ruby 3.3
144+
uses: ruby/setup-ruby@v1
145+
with:
146+
ruby-version: "3.3"
139147
- name: Cache
140148
uses: actions/cache@v5
141149
with:
@@ -368,6 +376,10 @@ jobs:
368376
- name: "Linux: Install python3-venv"
369377
if: runner.os == 'Linux'
370378
run: sudo apt install -y python3-venv
379+
- name: Set up Ruby 3.3
380+
uses: ruby/setup-ruby@v1
381+
with:
382+
ruby-version: "3.3"
371383
- if: runner.os == 'Windows'
372384
name: Windows performance improvements
373385
run: |-
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
diff --git a/lib/project-info.js b/lib/project-info.js
2+
index 62630bf1c76effac44081479b31f762ece4697e0..f7e0ca309a0940998d7cb2e2a7c2e5509f627cfe 100644
3+
--- a/lib/project-info.js
4+
+++ b/lib/project-info.js
5+
@@ -124,6 +124,7 @@ function validateTargets(targets) {
6+
python: ['module', 'distName', 'classifiers'],
7+
dotnet: ['namespace', 'packageId', 'iconUrl', 'versionSuffix'],
8+
go: ['moduleName', 'packageName', 'versionSuffix'],
9+
+ ruby: ['gem', 'module'],
10+
};
11+
for (const [language, config] of Object.entries(targets)) {
12+
if (!(language in VALID_TARGET_KEYS)) {
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
diff --git a/lib/languages/index.js b/lib/languages/index.js
2+
index 1abc03b0e0df5ff9f1af10560c87a76efaf09a79..ad7e175d147cb24248f9c92eae6d04c9351fea2e 100644
3+
--- a/lib/languages/index.js
4+
+++ b/lib/languages/index.js
5+
@@ -29,6 +29,7 @@ exports.TARGET_LANGUAGES = {
6+
};
7+
function getVisitorFromLanguage(language) {
8+
if (language !== undefined) {
9+
+ if (language === 'ruby') return new visualize_1.VisualizeAstVisitor();
10+
const target = Object.values(target_language_1.TargetLanguage).find((t) => t === language);
11+
if (target === undefined) {
12+
throw new Error(`Unknown target language: ${language}. Expected one of ${Object.values(target_language_1.TargetLanguage).join(', ')}`);
13+
diff --git a/lib/main.js b/lib/main.js
14+
index 07339c7c8c43e4603c76282dcf6833a43f533845..367d73c12173fb44260d2c2efc741a91ce2c9891 100644
15+
--- a/lib/main.js
16+
+++ b/lib/main.js
17+
@@ -310,6 +310,7 @@ async function main() {
18+
const languages = args.language.length > 0
19+
? args.language
20+
.map((lang) => lang.toUpperCase())
21+
+ .filter((lang) => lang !== 'RUBY')
22+
.map((lang) => {
23+
const target = Object.entries(languages_1.TargetLanguage).find(([k]) => k === lang)?.[1];
24+
if (target == null) {

buildspec.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ version: 0.2
22

33
phases:
44
install:
5+
runtime-versions:
6+
ruby: 3.3
57
commands:
68
- corepack enable
79
- yarn install --immutable

package.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
"jest-circus": "^30.3.0",
3434
"jest-config": "^30.3.0",
3535
"jest-expect-message": "^1.1.3",
36+
"jsii-pacmak": "^0.0.0",
3637
"lerna": "^9.0.7",
3738
"npm-check-updates": "^22.1.0",
3839
"prettier": "^3.8.3",
@@ -51,5 +52,8 @@
5152
"packages/@scope/*",
5253
"tools/*"
5354
],
54-
"packageManager": "yarn@4.13.0"
55+
"packageManager": "yarn@4.13.0",
56+
"resolutions": {
57+
"jsii@npm:~5.9.1": "patch:jsii@npm%3A5.9.28#~/.yarn/patches/jsii-npm-5.9.28-797cbf1229.patch"
58+
}
5559
}

packages/@jsii/kernel/src/kernel.test.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -417,6 +417,10 @@ defineTest(
417417
module: 'jsii_calc',
418418
classifiers: ['Test :: Classifier :: Is Dummy'],
419419
},
420+
ruby: {
421+
gem: 'jsii-calc',
422+
module: 'JsiiCalc',
423+
},
420424
});
421425
expect(sandbox.naming({ assembly: '@scope/jsii-calc-lib' }).naming).toEqual(
422426
{
@@ -442,6 +446,10 @@ defineTest(
442446
distName: 'scope.jsii-calc-lib',
443447
module: 'scope.jsii_calc_lib',
444448
},
449+
ruby: {
450+
gem: 'scope-jsii-calc-lib',
451+
module: 'Scope::JsiiCalcLib',
452+
},
445453
},
446454
);
447455
},
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
lib/
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
source 'https://rubygems.org'
2+
3+
gem 'jsii-ruby-runtime', path: '../ruby-runtime'
4+
gem 'rspec', '~> 3.12'
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
PATH
2+
remote: ../ruby-runtime
3+
specs:
4+
jsii-ruby-runtime (0.0.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
diff-lcs (1.6.2)
10+
rspec (3.13.2)
11+
rspec-core (~> 3.13.0)
12+
rspec-expectations (~> 3.13.0)
13+
rspec-mocks (~> 3.13.0)
14+
rspec-core (3.13.6)
15+
rspec-support (~> 3.13.0)
16+
rspec-expectations (3.13.5)
17+
diff-lcs (>= 1.2.0, < 2.0)
18+
rspec-support (~> 3.13.0)
19+
rspec-mocks (3.13.8)
20+
diff-lcs (>= 1.2.0, < 2.0)
21+
rspec-support (~> 3.13.0)
22+
rspec-support (3.13.7)
23+
24+
PLATFORMS
25+
ruby
26+
x86_64-linux-gnu
27+
28+
DEPENDENCIES
29+
jsii-ruby-runtime!
30+
rspec (~> 3.12)
31+
32+
CHECKSUMS
33+
bundler (4.0.11) sha256=5bcec0fb78302e48d02ee46f10ee6e6942be647ba5b44a6d1ddfda9a240ce785
34+
diff-lcs (1.6.2) sha256=9ae0d2cba7d4df3075fe8cd8602a8604993efc0dfa934cff568969efb1909962
35+
jsii-ruby-runtime (0.0.0)
36+
rspec (3.13.2) sha256=206284a08ad798e61f86d7ca3e376718d52c0bc944626b2349266f239f820587
37+
rspec-core (3.13.6) sha256=a8823c6411667b60a8bca135364351dda34cd55e44ff94c4be4633b37d828b2d
38+
rspec-expectations (3.13.5) sha256=33a4d3a1d95060aea4c94e9f237030a8f9eae5615e9bd85718fe3a09e4b58836
39+
rspec-mocks (3.13.8) sha256=086ad3d3d17533f4237643de0b5c42f04b66348c28bf6b9c2d3f4a3b01af1d47
40+
rspec-support (3.13.7) sha256=0640e5570872aafefd79867901deeeeb40b0c9875a36b983d85f54fb7381c47c
41+
42+
BUNDLED WITH
43+
4.0.11
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!/usr/bin/env bash
2+
# Generate the Ruby bindings for the jsii-calc fixture assemblies into ./lib,
3+
# where spec/spec_helper.rb expects to find them. Invoked by `yarn build`.
4+
set -euo pipefail
5+
6+
genRoot="./lib"
7+
8+
# Clean up any previously-generated bindings so stale types don't linger when
9+
# an assembly is removed or renamed upstream.
10+
rm -rf "${genRoot}"
11+
12+
# `--code-only` skips `gem build`, which would require Ruby + RubyGems to be
13+
# present in every environment that runs `yarn build`. The runtime tests do
14+
# not consume a built .gem — they load the generated sources under lib/
15+
# directly via $LOAD_PATH (see spec/spec_helper.rb).
16+
#
17+
# `--recurse` pacmaks jsii-calc *and* the whole dependency closure
18+
# (@scope/jsii-calc-{lib,base,base-of-base}), so we only need to pass the
19+
# top-level assembly here.
20+
yarn jsii-pacmak -t ruby --code-only --recurse -o "${genRoot}" ../../jsii-calc

0 commit comments

Comments
 (0)