ruby-anything 0.2.0 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +12 -12
- package/.claude-plugin/plugin.json +10 -2
- package/README.md +32 -1
- package/adapters/node/harness.mjs +3 -1
- package/adapters/node/package-lock.json +26 -26
- package/adapters/node/package.json +7 -7
- package/adapters/polyglot/harness.py +350 -350
- package/adapters/polyglot/lang_csharp.py +222 -222
- package/adapters/polyglot/lang_java.py +510 -510
- package/adapters/polyglot/lang_rust.py +430 -430
- package/adapters/polyglot/lang_swift.py +337 -337
- package/docs/test-results.md +92 -0
- package/package.json +6 -4
- package/src/adapters.js +63 -63
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
# Test results
|
|
2
|
+
|
|
3
|
+
<!-- generated by `npm run test:report`; do not edit by hand -->
|
|
4
|
+
|
|
5
|
+
**22 passed, 0 failed** in 23.2s, ruby-anything 0.2.1 at commit `c5873f2`, 2026-11-28.
|
|
6
|
+
|
|
7
|
+
These are end-to-end tests: they run real Python and Node originals through the recorders,
|
|
8
|
+
real Ruby ports through the replay harness, and real HTTP servers, SMTP and SQLite for side
|
|
9
|
+
effects. The workflow tests check both that a correct port passes and that a wrong one is caught.
|
|
10
|
+
|
|
11
|
+
Every push also runs this suite on Ubuntu, Windows and macOS in GitHub Actions:
|
|
12
|
+
[latest runs](https://github.com/akkisavi/ruby-anything/actions/workflows/ruby-anything.yml).
|
|
13
|
+
|
|
14
|
+
| Environment | Version |
|
|
15
|
+
|---|---|
|
|
16
|
+
| OS | win32 x64 |
|
|
17
|
+
| Node | v24.6.0 |
|
|
18
|
+
| Python | Python 3.12.10 |
|
|
19
|
+
| Ruby | ruby 3.1.3p185 (2022-11-24 revision 1a6b16756e) [x64-mingw-ucrt] |
|
|
20
|
+
|
|
21
|
+
## Whole app over HTTP, with side effects
|
|
22
|
+
|
|
23
|
+
`test/app.test.js`
|
|
24
|
+
|
|
25
|
+
| Result | Test | Time |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| ✅ pass | app record and replay against the original | 1404 ms |
|
|
28
|
+
| ✅ pass | side effects: payment call, email and database rows are recorded and checked | 7009 ms |
|
|
29
|
+
|
|
30
|
+
## Whole CLI app: record, front door, wire, lift
|
|
31
|
+
|
|
32
|
+
`test/cli.test.js`
|
|
33
|
+
|
|
34
|
+
| Result | Test | Time |
|
|
35
|
+
|---|---|---|
|
|
36
|
+
| ✅ pass | CLI record: exit codes, output, stdin and files, without touching the checkout | 1387 ms |
|
|
37
|
+
| ✅ pass | CLI front door: fallback, wire, catch a wrong exit code, lift | 5082 ms |
|
|
38
|
+
|
|
39
|
+
## Comparison rules (numbers, errors, HTML, noise, side effects)
|
|
40
|
+
|
|
41
|
+
`test/compare.test.js`
|
|
42
|
+
|
|
43
|
+
| Result | Test | Time |
|
|
44
|
+
|---|---|---|
|
|
45
|
+
| ✅ pass | int and float stay apart | 1 ms |
|
|
46
|
+
| ✅ pass | exact doubles from different harnesses compare equal | 0 ms |
|
|
47
|
+
| ✅ pass | error families map across languages | 0 ms |
|
|
48
|
+
| ✅ pass | compareCase names the first difference | 0 ms |
|
|
49
|
+
| ✅ pass | html text and replay modes | 2 ms |
|
|
50
|
+
| ✅ pass | noise becomes wildcards, word by word | 0 ms |
|
|
51
|
+
| ✅ pass | side effects are compared | 0 ms |
|
|
52
|
+
|
|
53
|
+
## --pin-clock and drift
|
|
54
|
+
|
|
55
|
+
`test/drift.test.js`
|
|
56
|
+
|
|
57
|
+
| Result | Test | Time |
|
|
58
|
+
|---|---|---|
|
|
59
|
+
| ✅ pass | --pin-clock: the original and the port see the same instant | 1223 ms |
|
|
60
|
+
| ✅ pass | drift: nothing changed, then an upstream change is reported | 1405 ms |
|
|
61
|
+
|
|
62
|
+
## record --from-tests (Python unittest, node --test)
|
|
63
|
+
|
|
64
|
+
`test/fromtests.test.js`
|
|
65
|
+
|
|
66
|
+
| Result | Test | Time |
|
|
67
|
+
|---|---|---|
|
|
68
|
+
| ✅ pass | Python unittest calls are recorded | 497 ms |
|
|
69
|
+
| ✅ pass | node --test calls are recorded | 405 ms |
|
|
70
|
+
| ✅ pass | a leftover backup from a crash is restored first | 414 ms |
|
|
71
|
+
|
|
72
|
+
## One function: analyze, bridge, record, diff, gate, rules
|
|
73
|
+
|
|
74
|
+
`test/units.test.js`
|
|
75
|
+
|
|
76
|
+
| Result | Test | Time |
|
|
77
|
+
|---|---|---|
|
|
78
|
+
| ✅ pass | analyze finds the functions | 185 ms |
|
|
79
|
+
| ✅ pass | bridge writes a stub that gate rejects | 653 ms |
|
|
80
|
+
| ✅ pass | a correct port passes diff and gate | 1496 ms |
|
|
81
|
+
| ✅ pass | diff catches half-up rounding and int vs float | 634 ms |
|
|
82
|
+
| ✅ pass | gate rejects copied answers and edited recordings | 691 ms |
|
|
83
|
+
| ✅ pass | rules are kept | 89 ms |
|
|
84
|
+
|
|
85
|
+
## Run it yourself
|
|
86
|
+
|
|
87
|
+
```sh
|
|
88
|
+
cd packages/ruby-anything
|
|
89
|
+
npm install
|
|
90
|
+
npm test # the suite
|
|
91
|
+
npm run test:report # the suite, and rewrite this file
|
|
92
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ruby-anything",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Migrate any app (TypeScript, JavaScript, Python, Go, Java/Spring, Kotlin, C#, PHP, Rust, Swift) to Ruby on Rails with Hotwire, Tailwind and daisyUI, one piece at a time, checked against the original's recorded behavior at every step.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ruby",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"url": "git+https://github.com/akkisavi/ruby-anything.git",
|
|
22
22
|
"directory": "packages/ruby-anything"
|
|
23
23
|
},
|
|
24
|
-
"homepage": "https://
|
|
24
|
+
"homepage": "https://ruby-anything.vercel.app",
|
|
25
25
|
"bugs": {
|
|
26
26
|
"url": "https://github.com/akkisavi/ruby-anything/issues"
|
|
27
27
|
},
|
|
@@ -39,11 +39,13 @@
|
|
|
39
39
|
"README.md",
|
|
40
40
|
"LICENSE",
|
|
41
41
|
"docs",
|
|
42
|
-
"action.yml"
|
|
42
|
+
"action.yml",
|
|
43
|
+
"!adapters/node/node_modules"
|
|
43
44
|
],
|
|
44
45
|
"scripts": {
|
|
45
46
|
"prepack": "node scripts/sync-adapters.js",
|
|
46
|
-
"test": "node scripts/test.js"
|
|
47
|
+
"test": "node scripts/test.js",
|
|
48
|
+
"test:report": "node scripts/test-report.js"
|
|
47
49
|
},
|
|
48
50
|
"engines": {
|
|
49
51
|
"node": ">=18"
|
package/src/adapters.js
CHANGED
|
@@ -1,63 +1,63 @@
|
|
|
1
|
-
'use strict'
|
|
2
|
-
// Runs PortPilot's language adapters (the recorders) on the original code.
|
|
3
|
-
// Recording EXECUTES the original: work on a copy, with a test database.
|
|
4
|
-
const fs = require('node:fs')
|
|
5
|
-
const path = require('node:path')
|
|
6
|
-
const { PKG, python, which, runHarness, canon } = require('./util')
|
|
7
|
-
|
|
8
|
-
const POLYGLOT = { go: 'go', java: 'javac', kotlin: 'kotlinc', csharp: 'dotnet', php: 'php', rust: 'rustc', swift: 'swiftc', ruby: 'ruby' }
|
|
9
|
-
|
|
10
|
-
function adaptersDir() {
|
|
11
|
-
// Inside the PortPilot repo the live adapters win over a copy left by `npm pack`.
|
|
12
|
-
const dev = path.resolve(PKG, '..', '..', 'adapters')
|
|
13
|
-
if (fs.existsSync(path.join(dev, 'polyglot', 'harness.py'))) return dev
|
|
14
|
-
const bundled = path.join(PKG, 'adapters')
|
|
15
|
-
if (fs.existsSync(path.join(bundled, 'polyglot'))) return bundled
|
|
16
|
-
throw new Error('language adapters missing: reinstall ruby-anything')
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// argv + env for a language's harness, or throws with what to install.
|
|
20
|
-
function harnessFor(lang) {
|
|
21
|
-
const dir = adaptersDir()
|
|
22
|
-
const py = python()
|
|
23
|
-
if (lang === 'python') {
|
|
24
|
-
if (!py) throw new Error('python 3 is required to record Python code')
|
|
25
|
-
return { argv: [py, '-X', 'utf8', '-I', '-B', path.join(dir, 'python', 'harness.py')], env: {} }
|
|
26
|
-
}
|
|
27
|
-
if (lang === 'javascript' || lang === 'typescript') {
|
|
28
|
-
return { argv: [process.execPath, '--enable-source-maps', path.join(dir, 'node', 'harness.mjs')], env: {} }
|
|
29
|
-
}
|
|
30
|
-
if (POLYGLOT[lang]) {
|
|
31
|
-
if (!py) throw new Error(`python 3 is required to drive the ${lang} recorder`)
|
|
32
|
-
if (!which(POLYGLOT[lang])) throw new Error(`${POLYGLOT[lang]} is not installed (needed to record ${lang}); run ruby-anything doctor`)
|
|
33
|
-
return { argv: [py, '-X', 'utf8', '-B', path.join(dir, 'polyglot', 'harness.py')], env: { PORTPILOT_LANGUAGE: lang } }
|
|
34
|
-
}
|
|
35
|
-
throw new Error(`no recorder for ${lang}`)
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function supported(lang) {
|
|
39
|
-
return lang === 'python' || lang === 'javascript' || lang === 'typescript' || !!POLYGLOT[lang]
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
async function analyzeUnits(root, lang) {
|
|
43
|
-
const h = harnessFor(lang)
|
|
44
|
-
const { events } = await runHarness(h.argv, { command: 'analyze' }, { env: { ...h.env, PORTPILOT_SRC: root }, cwd: root })
|
|
45
|
-
return {
|
|
46
|
-
files: events.filter((e) => e.event === 'file'),
|
|
47
|
-
units: events.filter((e) => e.event === 'unit'),
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
async function record(root, lang, { moduleFile, fn, cases = [], count = 40, seed = 1, mode = 'edge', pinClock = false, onEvent }) {
|
|
52
|
-
const h = harnessFor(lang)
|
|
53
|
-
const req = { command: 'record', module_file: moduleFile, function: fn, cases: '__CASES__', generate: count ? { count, seed, mode } : null, pin_clock: !!pinClock }
|
|
54
|
-
// cases keep their int/float kinds ({ $n } values) on the way in
|
|
55
|
-
const raw = JSON.stringify(req).replace('"__CASES__"', canon(cases))
|
|
56
|
-
const { events } = await runHarness(h.argv, raw, { env: { ...h.env, PORTPILOT_SRC: root }, cwd: root, onEvent })
|
|
57
|
-
return {
|
|
58
|
-
runtime: events.find((e) => e.event === 'plan')?.runtime,
|
|
59
|
-
cases: events.filter((e) => e.event === 'case'),
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
module.exports = { adaptersDir, harnessFor, supported, analyzeUnits, record }
|
|
1
|
+
'use strict'
|
|
2
|
+
// Runs PortPilot's language adapters (the recorders) on the original code.
|
|
3
|
+
// Recording EXECUTES the original: work on a copy, with a test database.
|
|
4
|
+
const fs = require('node:fs')
|
|
5
|
+
const path = require('node:path')
|
|
6
|
+
const { PKG, python, which, runHarness, canon } = require('./util')
|
|
7
|
+
|
|
8
|
+
const POLYGLOT = { go: 'go', java: 'javac', kotlin: 'kotlinc', csharp: 'dotnet', php: 'php', rust: 'rustc', swift: 'swiftc', ruby: 'ruby' }
|
|
9
|
+
|
|
10
|
+
function adaptersDir() {
|
|
11
|
+
// Inside the PortPilot repo the live adapters win over a copy left by `npm pack`.
|
|
12
|
+
const dev = path.resolve(PKG, '..', '..', 'adapters')
|
|
13
|
+
if (fs.existsSync(path.join(dev, 'polyglot', 'harness.py'))) return dev
|
|
14
|
+
const bundled = path.join(PKG, 'adapters')
|
|
15
|
+
if (fs.existsSync(path.join(bundled, 'polyglot'))) return bundled
|
|
16
|
+
throw new Error('language adapters missing: reinstall ruby-anything')
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// argv + env for a language's harness, or throws with what to install.
|
|
20
|
+
function harnessFor(lang) {
|
|
21
|
+
const dir = adaptersDir()
|
|
22
|
+
const py = python()
|
|
23
|
+
if (lang === 'python') {
|
|
24
|
+
if (!py) throw new Error('python 3 is required to record Python code')
|
|
25
|
+
return { argv: [py, '-X', 'utf8', '-I', '-B', path.join(dir, 'python', 'harness.py')], env: {} }
|
|
26
|
+
}
|
|
27
|
+
if (lang === 'javascript' || lang === 'typescript') {
|
|
28
|
+
return { argv: [process.execPath, '--enable-source-maps', path.join(dir, 'node', 'harness.mjs')], env: {} }
|
|
29
|
+
}
|
|
30
|
+
if (POLYGLOT[lang]) {
|
|
31
|
+
if (!py) throw new Error(`python 3 is required to drive the ${lang} recorder`)
|
|
32
|
+
if (!which(POLYGLOT[lang])) throw new Error(`${POLYGLOT[lang]} is not installed (needed to record ${lang}); run ruby-anything doctor`)
|
|
33
|
+
return { argv: [py, '-X', 'utf8', '-B', path.join(dir, 'polyglot', 'harness.py')], env: { PORTPILOT_LANGUAGE: lang } }
|
|
34
|
+
}
|
|
35
|
+
throw new Error(`no recorder for ${lang}`)
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function supported(lang) {
|
|
39
|
+
return lang === 'python' || lang === 'javascript' || lang === 'typescript' || !!POLYGLOT[lang]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function analyzeUnits(root, lang) {
|
|
43
|
+
const h = harnessFor(lang)
|
|
44
|
+
const { events } = await runHarness(h.argv, { command: 'analyze' }, { env: { ...h.env, PORTPILOT_SRC: root }, cwd: root })
|
|
45
|
+
return {
|
|
46
|
+
files: events.filter((e) => e.event === 'file'),
|
|
47
|
+
units: events.filter((e) => e.event === 'unit'),
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
async function record(root, lang, { moduleFile, fn, cases = [], count = 40, seed = 1, mode = 'edge', pinClock = false, onEvent }) {
|
|
52
|
+
const h = harnessFor(lang)
|
|
53
|
+
const req = { command: 'record', module_file: moduleFile, function: fn, cases: '__CASES__', generate: count ? { count, seed, mode } : null, pin_clock: !!pinClock }
|
|
54
|
+
// cases keep their int/float kinds ({ $n } values) on the way in
|
|
55
|
+
const raw = JSON.stringify(req).replace('"__CASES__"', canon(cases))
|
|
56
|
+
const { events } = await runHarness(h.argv, raw, { env: { ...h.env, PORTPILOT_SRC: root }, cwd: root, onEvent })
|
|
57
|
+
return {
|
|
58
|
+
runtime: events.find((e) => e.event === 'plan')?.runtime,
|
|
59
|
+
cases: events.filter((e) => e.event === 'case'),
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
module.exports = { adaptersDir, harnessFor, supported, analyzeUnits, record }
|