|
1 | | -# Triangulum |
| 1 | +# Triangulum Ruby Gem |
2 | 2 |
|
3 | | -TODO: Delete this and the text below, and describe your gem |
4 | | - |
5 | | -Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/triangulum`. To experiment with that code, run `bin/console` for an interactive prompt. |
| 3 | +Ruby bindings for the [Triangulum](https://github.com/code0-tech/triangulum) validation layer. This gem wraps the TypeScript library and a bundled [Bun](https://bun.sh) runtime to validate flows using the TypeScript compiler. |
6 | 4 |
|
7 | 5 | ## Installation |
8 | 6 |
|
9 | | -TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org. |
10 | | - |
11 | | -Install the gem and add to the application's Gemfile by executing: |
| 7 | +Add to your Gemfile: |
12 | 8 |
|
13 | | -```bash |
14 | | -bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 9 | +```ruby |
| 10 | +gem 'triangulum' |
15 | 11 | ``` |
16 | 12 |
|
17 | | -If bundler is not being used to manage dependencies, install the gem by executing: |
| 13 | +Platform-specific gems are published for: |
| 14 | + |
| 15 | +- `arm64-darwin` (macOS Apple Silicon) |
| 16 | +- `x86_64-darwin` (macOS Intel) |
| 17 | +- `x86_64-linux-gnu` (Linux x64) |
| 18 | +- `x86_64-linux-musl` (Linux x64 musl) |
| 19 | +- `aarch64-linux-gnu` (Linux ARM64) |
| 20 | +- `aarch64-linux-musl` (Linux ARM64 musl) |
| 21 | + |
| 22 | +If Bundler doesn't automatically select the correct platform gem, add your platform: |
18 | 23 |
|
19 | 24 | ```bash |
20 | | -gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG |
| 25 | +bundle lock --add-platform x86_64-linux-gnu |
21 | 26 | ``` |
22 | 27 |
|
23 | 28 | ## Usage |
24 | 29 |
|
25 | | -TODO: Write usage instructions here |
| 30 | +```ruby |
| 31 | +result = Triangulum::Validation.new(flow, runtime_function_definitions, data_types).validate |
| 32 | + |
| 33 | +result.valid? # => true / false |
| 34 | +result.return_type # => "void" |
| 35 | +result.diagnostics # => [Triangulum::Validation::Diagnostic, ...] |
| 36 | +``` |
| 37 | + |
| 38 | +The arguments are [Tucana](https://github.com/code0-tech/tucana) protobuf objects: |
| 39 | + |
| 40 | +- `flow` — `Tucana::Shared::ValidationFlow` |
| 41 | +- `runtime_function_definitions` — `Array<Tucana::Shared::RuntimeFunctionDefinition>` |
| 42 | +- `data_types` — `Array<Tucana::Shared::DefinitionDataType>` |
| 43 | + |
| 44 | +### Diagnostics |
| 45 | + |
| 46 | +Each diagnostic contains: |
| 47 | + |
| 48 | +| Field | Description | |
| 49 | +|---|---| |
| 50 | +| `message` | Human-readable error description | |
| 51 | +| `code` | TypeScript diagnostic code | |
| 52 | +| `severity` | `"error"` or `"warning"` | |
| 53 | +| `node_id` | ID of the node that caused the error | |
| 54 | +| `parameter_index` | Index of the parameter that caused the error | |
26 | 55 |
|
27 | 56 | ## Development |
28 | 57 |
|
29 | | -After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment. |
| 58 | +Prerequisites: [Bun](https://bun.sh) installed locally for building the entrypoint. |
| 59 | + |
| 60 | +```bash |
| 61 | +cd gem |
| 62 | +bundle install |
| 63 | +bundle exec rake prepare_build # downloads bun binaries + builds JS entrypoint |
| 64 | +bundle exec rake # run tests and rubocop |
| 65 | +``` |
| 66 | + |
| 67 | +### Building platform gems |
| 68 | + |
| 69 | +```bash |
| 70 | +bundle exec rake package |
| 71 | +``` |
30 | 72 |
|
31 | | -To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and the created tag, and push the `.gem` file to [rubygems.org](https://rubygems.org). |
| 73 | +This will download bun binaries (with SHA256 checksum verification) for all supported platforms and build a `.gem` file for each. |
32 | 74 |
|
33 | | -## Contributing |
| 75 | +## License |
34 | 76 |
|
35 | | -Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/triangulum. |
| 77 | +See [LICENSE](../LICENSE). |
0 commit comments