ratatui_ruby 0.1.0

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.
Files changed (119) hide show
  1. checksums.yaml +7 -0
  2. data/.build.yml +34 -0
  3. data/.pre-commit-config.yaml +9 -0
  4. data/.rubocop.yml +8 -0
  5. data/.ruby-version +1 -0
  6. data/AGENTS.md +119 -0
  7. data/CHANGELOG.md +15 -0
  8. data/CODE_OF_CONDUCT.md +30 -0
  9. data/CONTRIBUTING.md +40 -0
  10. data/LICENSE +15 -0
  11. data/LICENSES/AGPL-3.0-or-later.txt +661 -0
  12. data/LICENSES/BSD-2-Clause.txt +9 -0
  13. data/LICENSES/CC-BY-SA-4.0.txt +427 -0
  14. data/LICENSES/CC0-1.0.txt +121 -0
  15. data/LICENSES/MIT.txt +21 -0
  16. data/README.md +86 -0
  17. data/REUSE.toml +17 -0
  18. data/Rakefile +108 -0
  19. data/docs/application_testing.md +96 -0
  20. data/docs/contributors/design/ruby_frontend.md +100 -0
  21. data/docs/contributors/design/rust_backend.md +61 -0
  22. data/docs/contributors/design.md +11 -0
  23. data/docs/contributors/index.md +16 -0
  24. data/docs/images/examples-analytics.rb.png +0 -0
  25. data/docs/images/examples-box_demo.rb.png +0 -0
  26. data/docs/images/examples-dashboard.rb.png +0 -0
  27. data/docs/images/examples-login_form.rb.png +0 -0
  28. data/docs/images/examples-map_demo.rb.png +0 -0
  29. data/docs/images/examples-mouse_events.rb.png +0 -0
  30. data/docs/images/examples-scrollbar_demo.rb.png +0 -0
  31. data/docs/images/examples-stock_ticker.rb.png +0 -0
  32. data/docs/images/examples-system_monitor.rb.png +0 -0
  33. data/docs/index.md +18 -0
  34. data/docs/quickstart.md +126 -0
  35. data/examples/analytics.rb +87 -0
  36. data/examples/box_demo.rb +71 -0
  37. data/examples/dashboard.rb +72 -0
  38. data/examples/login_form.rb +114 -0
  39. data/examples/map_demo.rb +58 -0
  40. data/examples/mouse_events.rb +95 -0
  41. data/examples/scrollbar_demo.rb +75 -0
  42. data/examples/stock_ticker.rb +85 -0
  43. data/examples/system_monitor.rb +93 -0
  44. data/examples/test_analytics.rb +65 -0
  45. data/examples/test_box_demo.rb +38 -0
  46. data/examples/test_dashboard.rb +38 -0
  47. data/examples/test_login_form.rb +63 -0
  48. data/examples/test_map_demo.rb +100 -0
  49. data/examples/test_stock_ticker.rb +39 -0
  50. data/examples/test_system_monitor.rb +40 -0
  51. data/ext/ratatui_ruby/.cargo/config.toml +8 -0
  52. data/ext/ratatui_ruby/.gitignore +4 -0
  53. data/ext/ratatui_ruby/Cargo.lock +698 -0
  54. data/ext/ratatui_ruby/Cargo.toml +16 -0
  55. data/ext/ratatui_ruby/extconf.rb +12 -0
  56. data/ext/ratatui_ruby/src/events.rs +279 -0
  57. data/ext/ratatui_ruby/src/lib.rs +105 -0
  58. data/ext/ratatui_ruby/src/rendering.rs +31 -0
  59. data/ext/ratatui_ruby/src/style.rs +149 -0
  60. data/ext/ratatui_ruby/src/terminal.rs +131 -0
  61. data/ext/ratatui_ruby/src/widgets/barchart.rs +73 -0
  62. data/ext/ratatui_ruby/src/widgets/block.rs +12 -0
  63. data/ext/ratatui_ruby/src/widgets/canvas.rs +146 -0
  64. data/ext/ratatui_ruby/src/widgets/center.rs +81 -0
  65. data/ext/ratatui_ruby/src/widgets/cursor.rs +29 -0
  66. data/ext/ratatui_ruby/src/widgets/gauge.rs +50 -0
  67. data/ext/ratatui_ruby/src/widgets/layout.rs +82 -0
  68. data/ext/ratatui_ruby/src/widgets/linechart.rs +154 -0
  69. data/ext/ratatui_ruby/src/widgets/list.rs +62 -0
  70. data/ext/ratatui_ruby/src/widgets/mod.rs +18 -0
  71. data/ext/ratatui_ruby/src/widgets/overlay.rs +20 -0
  72. data/ext/ratatui_ruby/src/widgets/paragraph.rs +56 -0
  73. data/ext/ratatui_ruby/src/widgets/scrollbar.rs +68 -0
  74. data/ext/ratatui_ruby/src/widgets/sparkline.rs +59 -0
  75. data/ext/ratatui_ruby/src/widgets/table.rs +117 -0
  76. data/ext/ratatui_ruby/src/widgets/tabs.rs +51 -0
  77. data/lib/ratatui_ruby/output.rb +7 -0
  78. data/lib/ratatui_ruby/schema/bar_chart.rb +28 -0
  79. data/lib/ratatui_ruby/schema/block.rb +23 -0
  80. data/lib/ratatui_ruby/schema/canvas.rb +62 -0
  81. data/lib/ratatui_ruby/schema/center.rb +19 -0
  82. data/lib/ratatui_ruby/schema/constraint.rb +33 -0
  83. data/lib/ratatui_ruby/schema/cursor.rb +17 -0
  84. data/lib/ratatui_ruby/schema/gauge.rb +24 -0
  85. data/lib/ratatui_ruby/schema/layout.rb +22 -0
  86. data/lib/ratatui_ruby/schema/line_chart.rb +41 -0
  87. data/lib/ratatui_ruby/schema/list.rb +22 -0
  88. data/lib/ratatui_ruby/schema/overlay.rb +15 -0
  89. data/lib/ratatui_ruby/schema/paragraph.rb +37 -0
  90. data/lib/ratatui_ruby/schema/scrollbar.rb +33 -0
  91. data/lib/ratatui_ruby/schema/sparkline.rb +24 -0
  92. data/lib/ratatui_ruby/schema/style.rb +31 -0
  93. data/lib/ratatui_ruby/schema/table.rb +24 -0
  94. data/lib/ratatui_ruby/schema/tabs.rb +22 -0
  95. data/lib/ratatui_ruby/test_helper.rb +75 -0
  96. data/lib/ratatui_ruby/version.rb +10 -0
  97. data/lib/ratatui_ruby.rb +87 -0
  98. data/sig/ratatui_ruby/ratatui_ruby.rbs +16 -0
  99. data/sig/ratatui_ruby/schema/bar_chart.rbs +14 -0
  100. data/sig/ratatui_ruby/schema/block.rbs +11 -0
  101. data/sig/ratatui_ruby/schema/canvas.rbs +62 -0
  102. data/sig/ratatui_ruby/schema/center.rbs +11 -0
  103. data/sig/ratatui_ruby/schema/constraint.rbs +13 -0
  104. data/sig/ratatui_ruby/schema/cursor.rbs +10 -0
  105. data/sig/ratatui_ruby/schema/gauge.rbs +13 -0
  106. data/sig/ratatui_ruby/schema/layout.rbs +11 -0
  107. data/sig/ratatui_ruby/schema/line_chart.rbs +20 -0
  108. data/sig/ratatui_ruby/schema/list.rbs +11 -0
  109. data/sig/ratatui_ruby/schema/overlay.rbs +9 -0
  110. data/sig/ratatui_ruby/schema/paragraph.rbs +11 -0
  111. data/sig/ratatui_ruby/schema/scrollbar.rbs +20 -0
  112. data/sig/ratatui_ruby/schema/sparkline.rbs +12 -0
  113. data/sig/ratatui_ruby/schema/style.rbs +13 -0
  114. data/sig/ratatui_ruby/schema/table.rbs +13 -0
  115. data/sig/ratatui_ruby/schema/tabs.rbs +11 -0
  116. data/sig/ratatui_ruby/test_helper.rbs +11 -0
  117. data/sig/ratatui_ruby/version.rbs +6 -0
  118. data/vendor/goodcop/base.yml +1047 -0
  119. metadata +196 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 996cd8cc08b1f95614ad8ff31c735fcee9150cebaa35ced2d844088e34730390
4
+ data.tar.gz: 4156030673a39867c6a99036cb6618910110c0d287c94500d601047163d87524
5
+ SHA512:
6
+ metadata.gz: 9d08516a876ec1265246ebbb2855e647e2fc50846756abb07a466a8506aaf1acf5b0547276faedc017b44795b9d237b4ac1003796209094868e627a482a0fbd3
7
+ data.tar.gz: 573b6c07ba542e1f5399da620b502a09cc999f70ae4dfa14f49974994e3b22d3bff2458c2076aa920281c418a232984834fbb6f6fd306f1a2a951ac308158f91
data/.build.yml ADDED
@@ -0,0 +1,34 @@
1
+ # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
2
+ # SPDX-License-Identifier: AGPL-3.0-or-later
3
+
4
+ image: archlinux
5
+ packages:
6
+ - ruby
7
+ - rust
8
+ - cargo
9
+ - make
10
+ - gcc
11
+ - clang
12
+ sources:
13
+ - https://git.sr.ht/~kerrick/ratatui_ruby
14
+ tasks:
15
+ - setup: |
16
+ cd ratatui_ruby
17
+ export PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"
18
+ gem install --user-install bundler -v 2.6.9
19
+ bundle config set --local path 'vendor/bundle'
20
+ bundle install
21
+ - test: |
22
+ cd ratatui_ruby
23
+ export PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"
24
+ bundle config set --local path 'vendor/bundle'
25
+ # Compile the extension before running tests
26
+ bundle exec rake compile
27
+ # Run the test suite (Headless)
28
+ bundle exec rake test
29
+ - package: |
30
+ cd ratatui_ruby
31
+ export PATH="$PATH:$(ruby -e 'puts Gem.user_dir')/bin"
32
+ bundle config set --local path 'vendor/bundle'
33
+ # Verify packaging works
34
+ gem build ratatui_ruby.gemspec
@@ -0,0 +1,9 @@
1
+ # SPDX-FileCopyrightText: 2020 Free Software Foundation Europe e.V.
2
+ # SPDX-License-Identifier: CC0-1.0
3
+ repos:
4
+ - repo: local
5
+ hooks:
6
+ - id: rake
7
+ name: rake
8
+ entry: rake
9
+ language: ruby
data/.rubocop.yml ADDED
@@ -0,0 +1,8 @@
1
+ # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
2
+ # SPDX-License-Identifier: AGPL-3.0-or-later
3
+
4
+ inherit_from:
5
+ - ./vendor/goodcop/base.yml
6
+
7
+ AllCops:
8
+ TargetRubyVersion: "3.3"
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ 3.4.7
data/AGENTS.md ADDED
@@ -0,0 +1,119 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
3
+ SPDX-License-Identifier: AGPL-3.0-or-later
4
+ -->
5
+
6
+ # AGENTS.md
7
+
8
+ ## Project Identity
9
+
10
+ Project Name: ratatui_ruby
11
+
12
+ Description: A high-performance Ruby wrapper for the Ratatui TUI library.
13
+
14
+ Architecture:
15
+
16
+ - **Frontend (Ruby):** Pure `Data` objects (Ruby 3.2+) defining the View Tree. Immediate mode.
17
+ - **Backend (Rust):** A generic renderer using `ratatui` and `magnus` that traverses the Ruby `Data` tree and renders to the terminal buffer.
18
+
19
+ ## 1. File & Coding Standards
20
+
21
+ ### Licensing & Copyright (Strict)
22
+
23
+ Every file must begin with an SPDX-compliant header. Use the following format:
24
+
25
+ ```ruby
26
+ # frozen_string_literal: true
27
+
28
+ # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
29
+ # SPDX-License-Identifier: AGPL-3.0-or-later
30
+ ```
31
+
32
+ - **Ruby/Rust/Config files:** Use comments appropriate for the language (`#` or `//`).
33
+ - **Markdown:** Use HTML comment style `<!-- -->`.
34
+ - **Exceptions:** `REUSE.toml` manages exceptions (e.g., binary files or `.gitignore`).
35
+
36
+ ### Ruby Standards
37
+
38
+ - **Version:** Strict Ruby 3.4 compatibility (Target `3.4.7` as per cosmoruby).
39
+ - **Linter:** Run via `rake lint`. You are not done until all linting passes.
40
+ - **Style:**
41
+ - Use `Data.define` for all value objects (UI Nodes). (Prefer `class Foo < Data.define()` over `Foo = Data.define() do`).
42
+ - Prefer `frozen_string_literal: true`.
43
+ - Use `Minitest` for testing.
44
+ - Define types in `.rbs` files. Don't use `untyped` just because it's easy; be comprehensive and accurate. Do not include `initialize` in `.rbs` files; use `self.new` for constructors instead.
45
+ - Every line of Ruby must be covered by tests that would stand up to mutation testing. This includes all examples in the `examples/` directory; they should have corresponding tests in `examples/` to ensure they continue to work as intended and serve as reliable documentation. Tests must be meaningful and verify specific behavior or rendering output; simply verifying that code "doesn't crash" is insufficient and unacceptable.
46
+ - Every public Ruby class/method must be documented for humans in RDoc (preferred)--**not** YARD--or markdown files (fallback), and must have `*.rbs` types defined.
47
+ - Every significant architectural and design decision must be documented for contributors in markdown files. Mermaid is allowed.
48
+
49
+ ### Rust Standards
50
+
51
+ - **Crate Type:** `cdylib`.
52
+ - **Linter:** `clippy` and `rustfmt`.
53
+ - **Bindings:** Use [magnus](https://github.com/matsadler/magnus).
54
+ - **Platform:** Support macOS (Apple Silicon), Linux, and Windows.
55
+ - **Linker Flags:** Must handle macOS `-undefined dynamic_lookup`.
56
+ - Every line of Rust must be covered by tests that would stand up to mutation testing. This includes every widget implementation in `ext/ratatui_ruby/src/widgets/`; each must have a `tests` module with unit tests verifying basic rendering. Tests must be meaningful; simply verifying that code "doesn't crash" or "compiles" is insufficient.
57
+
58
+ ## 2. Directory Structure Convention
59
+
60
+ The project follows a standard Gem layout with an `ext/` directory for Rust code.
61
+
62
+ ```plaintext
63
+ /
64
+ ├── .cargo/ # Cargo configuration (linker flags)
65
+ ├── .github/ # CI/CD workflows
66
+ ├── bin/ # Executables (console, setup)
67
+ ├── docs/ # Documentation tree
68
+ │ ├── contributors/ # Design docs, ecosystem notes
69
+ │ └── index.md
70
+ ├── ext/
71
+ │ └── ratatui_ruby/ # RUST SOURCE CODE GOES HERE
72
+ │ ├── src/
73
+ │ │ └── lib.rs # Entry point
74
+ │ ├── Cargo.toml
75
+ │ └── extconf.rb # Makefile generator
76
+ ├── lib/
77
+ │ ├── ratatui_ruby/
78
+ │ │ ├── schema/ # Ruby Data definitions
79
+ │ │ └── version.rb
80
+ │ └── ratatui_ruby.rb # Main loader
81
+ ├── test/
82
+ │ ├── data/ # Data-driven test files
83
+ │ └── ratatui_ruby/ # Unit tests
84
+ ├── vendor/ # Vendorized style configs (goodcop)
85
+ ├── AGENTS.md # Context for AI agents
86
+ ├── Gemfile
87
+ ├── Rakefile
88
+ ├── REUSE.toml # Compliance definition
89
+ └── ratatui_ruby.gemspec
90
+ ```
91
+
92
+ ## 3. Configuration & Tooling
93
+
94
+ ### Development Environment
95
+
96
+ - **Setup:** `bin/setup` must handle both Bundler and Cargo dependencies.
97
+ - **Pre-commit:** Use `.pre-commit-config.yaml` to enforce `rake` and `cargo fmt`.
98
+
99
+ ### Documentation
100
+
101
+ - Follow the `docs/` structure: `index.md` -> `contributors/` | `quickstart.md`.
102
+ - Documentation should separate "User Guide" (Ruby API for TUI developers) from "Contributor Guide" (Ruby/Rust/Magnus internals).
103
+ - Don't write .md files for something RDoc (Ruby) or rustdoc (Rust) can generate.
104
+ - **Never edit the `doc/` folder directly.** It is automatically generated by `rake rerdoc`. If you need to refresh the generated documentation, run that command instead.
105
+
106
+ ## 4. The Ruby <-> Rust Bridge Contract
107
+
108
+ ### The Ruby Side (`lib/`)
109
+
110
+ - Refer to [docs/contributors/design/ruby_frontend.md](docs/contributors/design/ruby_frontend.md) for detailed design philosophy regarding the Data-Driven UI and Immediate Mode paradigm.
111
+
112
+ ### The Rust Side (`ext/`)
113
+
114
+ - Refer to [docs/contributors/design/rust_backend.md](docs/contributors/design/rust_backend.md) for detailed implementation guidelines, module structure, and rendering logic.
115
+
116
+ ## 5. Deployment / Release
117
+
118
+ - The gem builds a native extension.
119
+ - Artifact naming: Ensure the output shared library matches Ruby's expectation on macOS (rename `.dylib`to `.bundle` if necessary during the build process in `extconf.rb` or `Rakefile`).
data/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
3
+ SPDX-License-Identifier: CC-BY-SA-4.0
4
+ -->
5
+ # Changelog
6
+
7
+ All notable changes to this project will be documented in this file.
8
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/).
9
+ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
10
+
11
+ ## [Unreleased]
12
+
13
+ ### Added
14
+
15
+ - Created the gem
@@ -0,0 +1,30 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
3
+ SPDX-License-Identifier: CC-BY-SA-4.0
4
+ -->
5
+ # **ratatui_ruby** Code of Conduct
6
+
7
+ This project is intended to be a safe, productive collaboration, and contributors are expected to adhere to the [Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct/).
8
+
9
+ For your convenience, it is reproduced below. If this document ever falls out of date and/or conflicts with the linked [Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct/) document, the linked document takes precedence.
10
+
11
+
12
+ <!-- SPDX-SnippetBegin -->
13
+ <!--
14
+ SPDX-FileCopyrightText: 2016 Yukihiro Matsumoto <matz@netlab.jp>
15
+ SPDX-License-Identifier: BSD-2-Clause
16
+ -->
17
+
18
+
19
+ ## The Ruby Community Conduct Guideline
20
+
21
+ > **We have picked the following conduct guideline based on an early proposed draft of the PostgreSQL CoC, for Ruby developers community for safe, productive collaboration. Each Ruby related community (conference etc.) may pick their own Code of Conduct.**
22
+ >
23
+ > This document provides community guidelines for a safe, respectful, productive, and collaborative place for any person who is willing to contribute to the Ruby community. It applies to all “collaborative space”, which is defined as community communications channels (such as mailing lists, submitted patches, commit comments, etc.).
24
+ >
25
+ > - Participants will be tolerant of opposing views.
26
+ > - Participants must ensure that their language and actions are free of personal attacks and disparaging personal remarks.
27
+ > - When interpreting the words and actions of others, participants should always assume good intentions.
28
+ > - Behaviour which can be reasonably considered harassment will not be tolerated.
29
+
30
+ <!-- SPDX-SnippetEnd -->
data/CONTRIBUTING.md ADDED
@@ -0,0 +1,40 @@
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
3
+ SPDX-License-Identifier: CC-BY-SA-4.0
4
+ -->
5
+ # Contribution Guide
6
+
7
+ This project is intended to be a safe, productive collaboration, and contributors are expected to adhere to the [Ruby Community Conduct Guideline](https://www.ruby-lang.org/en/conduct/).
8
+
9
+
10
+ ## Reporting Issues
11
+
12
+ Bug reports are welcome on [sourcehut](https://sourcehut.org) at https://todo.sr.ht/~kerrick/ratatui_ruby.
13
+
14
+ Issues for Ratatui should be filed at [ratatui/ratatui](https://github.com/ratatui/ratatui).
15
+
16
+
17
+ ## Requesting Features
18
+
19
+ ratatui_ruby aims to wrap all [Ratatui](https://ratatui.rs) features. Please request new features there.
20
+
21
+
22
+ ## Pull Requests
23
+
24
+ Please join our **devel** mailing list at https://lists.sr.ht/~kerrick/ratatui_ruby-devel. Then, send a pull request via email to the mailing list.
25
+
26
+ The easiest way to send a pull request via email is to use [git-send-email](https://git-scm.com/docs/git-send-email). If you are unfamiliar with using git to send a pull request via email, read the [four-step tutorial at git-send-email.io](https://git-send-email.io).
27
+
28
+ Alternatively, [sourcehut](https://sourcehut.org) has a web UI you can use to prepare the email to send. [Read their documentation](https://man.sr.ht/git.sr.ht/#sending-patches-upstream) to find out if this is right for you.
29
+
30
+
31
+ ## Development
32
+
33
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
34
+
35
+ 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).
36
+
37
+
38
+ ## Contributors’ Documentation
39
+
40
+ We have documentation on how **ratatui_ruby** works internally, how it is designed, and how it interacts with the official Ratatui projects. See the [contributors’ documentation index](docs/contributors/index.md) for more information.
data/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ratatui_ruby -- Unofficial Ruby wrapper for Ratatui
2
+ Copyright (C) 2025 Kerrick Long
3
+
4
+ This program is free software: you can redistribute it and/or modify
5
+ it under the terms of the GNU Affero General Public License as published
6
+ by the Free Software Foundation, either version 3 of the License, or
7
+ (at your option) any later version.
8
+
9
+ This program is distributed in the hope that it will be useful,
10
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ GNU Affero General Public License for more details.
13
+
14
+ You should have received a copy of the GNU Affero General Public License
15
+ along with this program. If not, see <https://www.gnu.org/licenses/>.