ratatui_ruby 1.2.0 → 1.2.1

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 (259) hide show
  1. checksums.yaml +4 -4
  2. data/ext/ratatui_ruby/Cargo.lock +1 -1
  3. data/ext/ratatui_ruby/Cargo.toml +1 -1
  4. data/lib/ratatui_ruby/version.rb +1 -1
  5. metadata +1 -255
  6. data/.builds/ruby-3.2.yml +0 -54
  7. data/.builds/ruby-3.3.yml +0 -54
  8. data/.builds/ruby-3.4.yml +0 -54
  9. data/.builds/ruby-4.0.0.yml +0 -54
  10. data/.pre-commit-config.yaml +0 -16
  11. data/.rubocop.yml +0 -10
  12. data/AGENTS.md +0 -147
  13. data/CHANGELOG.md +0 -751
  14. data/README.md +0 -187
  15. data/README.rdoc +0 -302
  16. data/Rakefile +0 -11
  17. data/Steepfile +0 -50
  18. data/doc/concepts/application_architecture.md +0 -321
  19. data/doc/concepts/application_testing.md +0 -193
  20. data/doc/concepts/async.md +0 -190
  21. data/doc/concepts/custom_widgets.md +0 -247
  22. data/doc/concepts/debugging.md +0 -401
  23. data/doc/concepts/event_handling.md +0 -162
  24. data/doc/concepts/interactive_design.md +0 -146
  25. data/doc/contributors/auditing/parity.md +0 -239
  26. data/doc/contributors/design/ruby_frontend.md +0 -448
  27. data/doc/contributors/design/rust_backend.md +0 -434
  28. data/doc/contributors/design.md +0 -11
  29. data/doc/contributors/developing_examples.md +0 -400
  30. data/doc/contributors/documentation_style.md +0 -121
  31. data/doc/contributors/index.md +0 -21
  32. data/doc/contributors/releasing.md +0 -215
  33. data/doc/contributors/todo/align/api_completeness_audit-finished.md +0 -381
  34. data/doc/contributors/todo/align/api_completeness_audit-unfinished.md +0 -200
  35. data/doc/contributors/todo/align/term.md +0 -351
  36. data/doc/contributors/todo/align/terminal.md +0 -647
  37. data/doc/contributors/todo/future_work.md +0 -169
  38. data/doc/contributors/upstream_requests/paragraph_span_rects.md +0 -259
  39. data/doc/contributors/upstream_requests/tab_rects.md +0 -173
  40. data/doc/contributors/upstream_requests/title_rects.md +0 -132
  41. data/doc/custom.css +0 -22
  42. data/doc/getting_started/quickstart.md +0 -291
  43. data/doc/getting_started/why.md +0 -93
  44. data/doc/images/app_all_events.png +0 -0
  45. data/doc/images/app_cli_rich_moments.gif +0 -0
  46. data/doc/images/app_color_picker.png +0 -0
  47. data/doc/images/app_debugging_showcase.gif +0 -0
  48. data/doc/images/app_debugging_showcase.png +0 -0
  49. data/doc/images/app_external_editor.gif +0 -0
  50. data/doc/images/app_login_form.png +0 -0
  51. data/doc/images/app_stateful_interaction.png +0 -0
  52. data/doc/images/verify_quickstart_dsl.png +0 -0
  53. data/doc/images/verify_quickstart_layout.png +0 -0
  54. data/doc/images/verify_quickstart_lifecycle.png +0 -0
  55. data/doc/images/verify_readme_usage.png +0 -0
  56. data/doc/images/widget_barchart.png +0 -0
  57. data/doc/images/widget_block.png +0 -0
  58. data/doc/images/widget_box.png +0 -0
  59. data/doc/images/widget_calendar.png +0 -0
  60. data/doc/images/widget_canvas.png +0 -0
  61. data/doc/images/widget_cell.png +0 -0
  62. data/doc/images/widget_center.png +0 -0
  63. data/doc/images/widget_chart.png +0 -0
  64. data/doc/images/widget_gauge.png +0 -0
  65. data/doc/images/widget_layout_split.png +0 -0
  66. data/doc/images/widget_line_gauge.png +0 -0
  67. data/doc/images/widget_list.png +0 -0
  68. data/doc/images/widget_map.png +0 -0
  69. data/doc/images/widget_overlay.png +0 -0
  70. data/doc/images/widget_popup.png +0 -0
  71. data/doc/images/widget_ratatui_logo.png +0 -0
  72. data/doc/images/widget_ratatui_mascot.png +0 -0
  73. data/doc/images/widget_rect.png +0 -0
  74. data/doc/images/widget_render.png +0 -0
  75. data/doc/images/widget_rich_text.png +0 -0
  76. data/doc/images/widget_scroll_text.png +0 -0
  77. data/doc/images/widget_scrollbar.png +0 -0
  78. data/doc/images/widget_sparkline.png +0 -0
  79. data/doc/images/widget_style_colors.png +0 -0
  80. data/doc/images/widget_table.png +0 -0
  81. data/doc/images/widget_tabs.png +0 -0
  82. data/doc/images/widget_text_width.png +0 -0
  83. data/doc/index.md +0 -34
  84. data/doc/troubleshooting/async.md +0 -4
  85. data/doc/troubleshooting/terminal_limitations.md +0 -131
  86. data/doc/troubleshooting/tui_output.md +0 -197
  87. data/examples/app_all_events/README.md +0 -114
  88. data/examples/app_all_events/app.rb +0 -98
  89. data/examples/app_all_events/model/app_model.rb +0 -159
  90. data/examples/app_all_events/model/event_color_cycle.rb +0 -43
  91. data/examples/app_all_events/model/event_entry.rb +0 -94
  92. data/examples/app_all_events/model/msg.rb +0 -39
  93. data/examples/app_all_events/model/timestamp.rb +0 -56
  94. data/examples/app_all_events/update.rb +0 -75
  95. data/examples/app_all_events/view/app_view.rb +0 -80
  96. data/examples/app_all_events/view/controls_view.rb +0 -54
  97. data/examples/app_all_events/view/counts_view.rb +0 -61
  98. data/examples/app_all_events/view/live_view.rb +0 -72
  99. data/examples/app_all_events/view/log_view.rb +0 -57
  100. data/examples/app_all_events/view.rb +0 -9
  101. data/examples/app_cli_rich_moments/README.md +0 -81
  102. data/examples/app_cli_rich_moments/app.rb +0 -189
  103. data/examples/app_color_picker/README.md +0 -156
  104. data/examples/app_color_picker/app.rb +0 -76
  105. data/examples/app_color_picker/clipboard.rb +0 -86
  106. data/examples/app_color_picker/color.rb +0 -193
  107. data/examples/app_color_picker/controls.rb +0 -92
  108. data/examples/app_color_picker/copy_dialog.rb +0 -168
  109. data/examples/app_color_picker/export_pane.rb +0 -128
  110. data/examples/app_color_picker/harmony.rb +0 -58
  111. data/examples/app_color_picker/input.rb +0 -176
  112. data/examples/app_color_picker/main_container.rb +0 -180
  113. data/examples/app_color_picker/palette.rb +0 -111
  114. data/examples/app_debugging_showcase/README.md +0 -119
  115. data/examples/app_debugging_showcase/app.rb +0 -318
  116. data/examples/app_external_editor/README.md +0 -62
  117. data/examples/app_external_editor/app.rb +0 -344
  118. data/examples/app_login_form/README.md +0 -58
  119. data/examples/app_login_form/app.rb +0 -109
  120. data/examples/app_stateful_interaction/README.md +0 -35
  121. data/examples/app_stateful_interaction/app.rb +0 -328
  122. data/examples/timeout_demo.rb +0 -45
  123. data/examples/verify_quickstart_dsl/README.md +0 -55
  124. data/examples/verify_quickstart_dsl/app.rb +0 -49
  125. data/examples/verify_quickstart_layout/README.md +0 -77
  126. data/examples/verify_quickstart_layout/app.rb +0 -73
  127. data/examples/verify_quickstart_lifecycle/README.md +0 -68
  128. data/examples/verify_quickstart_lifecycle/app.rb +0 -62
  129. data/examples/verify_readme_usage/README.md +0 -49
  130. data/examples/verify_readme_usage/app.rb +0 -42
  131. data/examples/verify_website_managed/README.md +0 -48
  132. data/examples/verify_website_managed/app.rb +0 -36
  133. data/examples/verify_website_menu/README.md +0 -60
  134. data/examples/verify_website_menu/app.rb +0 -84
  135. data/examples/verify_website_spinner/README.md +0 -44
  136. data/examples/verify_website_spinner/app.rb +0 -34
  137. data/examples/widget_barchart/README.md +0 -58
  138. data/examples/widget_barchart/app.rb +0 -240
  139. data/examples/widget_block/README.md +0 -44
  140. data/examples/widget_block/app.rb +0 -258
  141. data/examples/widget_box/README.md +0 -54
  142. data/examples/widget_box/app.rb +0 -255
  143. data/examples/widget_calendar/README.md +0 -48
  144. data/examples/widget_calendar/app.rb +0 -115
  145. data/examples/widget_canvas/README.md +0 -31
  146. data/examples/widget_canvas/app.rb +0 -130
  147. data/examples/widget_cell/README.md +0 -45
  148. data/examples/widget_cell/app.rb +0 -112
  149. data/examples/widget_center/README.md +0 -33
  150. data/examples/widget_center/app.rb +0 -118
  151. data/examples/widget_chart/README.md +0 -50
  152. data/examples/widget_chart/app.rb +0 -220
  153. data/examples/widget_gauge/README.md +0 -50
  154. data/examples/widget_gauge/app.rb +0 -229
  155. data/examples/widget_layout_split/README.md +0 -53
  156. data/examples/widget_layout_split/app.rb +0 -260
  157. data/examples/widget_line_gauge/README.md +0 -50
  158. data/examples/widget_line_gauge/app.rb +0 -219
  159. data/examples/widget_list/README.md +0 -58
  160. data/examples/widget_list/app.rb +0 -382
  161. data/examples/widget_map/README.md +0 -48
  162. data/examples/widget_map/app.rb +0 -95
  163. data/examples/widget_overlay/README.md +0 -45
  164. data/examples/widget_overlay/app.rb +0 -250
  165. data/examples/widget_popup/README.md +0 -45
  166. data/examples/widget_popup/app.rb +0 -106
  167. data/examples/widget_ratatui_logo/README.md +0 -43
  168. data/examples/widget_ratatui_logo/app.rb +0 -104
  169. data/examples/widget_ratatui_mascot/README.md +0 -43
  170. data/examples/widget_ratatui_mascot/app.rb +0 -95
  171. data/examples/widget_rect/README.md +0 -53
  172. data/examples/widget_rect/app.rb +0 -222
  173. data/examples/widget_render/README.md +0 -46
  174. data/examples/widget_render/app.rb +0 -186
  175. data/examples/widget_render/app.rbs +0 -41
  176. data/examples/widget_rich_text/README.md +0 -44
  177. data/examples/widget_rich_text/app.rb +0 -193
  178. data/examples/widget_scroll_text/README.md +0 -46
  179. data/examples/widget_scroll_text/app.rb +0 -109
  180. data/examples/widget_scrollbar/README.md +0 -46
  181. data/examples/widget_scrollbar/app.rb +0 -155
  182. data/examples/widget_sparkline/README.md +0 -51
  183. data/examples/widget_sparkline/app.rb +0 -277
  184. data/examples/widget_style_colors/README.md +0 -43
  185. data/examples/widget_style_colors/app.rb +0 -83
  186. data/examples/widget_table/README.md +0 -57
  187. data/examples/widget_table/app.rb +0 -285
  188. data/examples/widget_tabs/README.md +0 -50
  189. data/examples/widget_tabs/app.rb +0 -183
  190. data/examples/widget_text_width/README.md +0 -44
  191. data/examples/widget_text_width/app.rb +0 -117
  192. data/migrate_to_buffer.rb +0 -145
  193. data/mise.toml +0 -8
  194. data/tasks/autodoc/examples.rb +0 -87
  195. data/tasks/autodoc/member.rb +0 -58
  196. data/tasks/autodoc/name.rb +0 -21
  197. data/tasks/autodoc.rake +0 -21
  198. data/tasks/bump/bump_workflow.rb +0 -49
  199. data/tasks/bump/cargo_lockfile.rb +0 -21
  200. data/tasks/bump/changelog.rb +0 -104
  201. data/tasks/bump/header.rb +0 -32
  202. data/tasks/bump/history.rb +0 -32
  203. data/tasks/bump/links.rb +0 -69
  204. data/tasks/bump/manifest.rb +0 -33
  205. data/tasks/bump/patch_release.rb +0 -19
  206. data/tasks/bump/release_branch.rb +0 -17
  207. data/tasks/bump/release_from_trunk.rb +0 -49
  208. data/tasks/bump/repository.rb +0 -54
  209. data/tasks/bump/ruby_gem.rb +0 -29
  210. data/tasks/bump/sem_ver.rb +0 -44
  211. data/tasks/bump/unreleased_section.rb +0 -73
  212. data/tasks/bump.rake +0 -61
  213. data/tasks/doc/documentation.rb +0 -59
  214. data/tasks/doc/link/file_url.rb +0 -30
  215. data/tasks/doc/link/relative_path.rb +0 -61
  216. data/tasks/doc/link/web_url.rb +0 -55
  217. data/tasks/doc/link.rb +0 -52
  218. data/tasks/doc/link_audit.rb +0 -116
  219. data/tasks/doc/problem.rb +0 -40
  220. data/tasks/doc/source_file.rb +0 -93
  221. data/tasks/doc.rake +0 -905
  222. data/tasks/example_viewer.html.erb +0 -172
  223. data/tasks/extension.rake +0 -14
  224. data/tasks/license/headers_md.rb +0 -223
  225. data/tasks/license/headers_rb.rb +0 -210
  226. data/tasks/license/license_utils.rb +0 -130
  227. data/tasks/license/snippets_md.rb +0 -315
  228. data/tasks/license/snippets_rdoc.rb +0 -150
  229. data/tasks/license.rake +0 -91
  230. data/tasks/lint.rake +0 -170
  231. data/tasks/rbs_predicates/predicate_catalog.rb +0 -52
  232. data/tasks/rbs_predicates/predicate_tests.rb +0 -124
  233. data/tasks/rbs_predicates/rbs_signature.rb +0 -63
  234. data/tasks/rbs_predicates.rake +0 -31
  235. data/tasks/rdoc_config.rb +0 -29
  236. data/tasks/resources/build.yml.erb +0 -60
  237. data/tasks/resources/index.html.erb +0 -141
  238. data/tasks/resources/rubies.yml +0 -7
  239. data/tasks/sourcehut.rake +0 -122
  240. data/tasks/steep.rake +0 -11
  241. data/tasks/terminal_preview/app_screenshot.rb +0 -45
  242. data/tasks/terminal_preview/crash_report.rb +0 -54
  243. data/tasks/terminal_preview/example_app.rb +0 -27
  244. data/tasks/terminal_preview/launcher_script.rb +0 -48
  245. data/tasks/terminal_preview/preview_collection.rb +0 -60
  246. data/tasks/terminal_preview/preview_timing.rb +0 -24
  247. data/tasks/terminal_preview/safety_confirmation.rb +0 -58
  248. data/tasks/terminal_preview/saved_screenshot.rb +0 -56
  249. data/tasks/terminal_preview/system_appearance.rb +0 -13
  250. data/tasks/terminal_preview/terminal_window.rb +0 -138
  251. data/tasks/terminal_preview/window_id.rb +0 -16
  252. data/tasks/terminal_preview.rake +0 -30
  253. data/tasks/test.rake +0 -36
  254. data/tasks/website/index_page.rb +0 -30
  255. data/tasks/website/version.rb +0 -122
  256. data/tasks/website/version_menu.rb +0 -68
  257. data/tasks/website/versioned_documentation.rb +0 -83
  258. data/tasks/website/website.rb +0 -53
  259. data/tasks/website.rake +0 -28
@@ -1,172 +0,0 @@
1
- <%#
2
- SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
3
- SPDX-License-Identifier: AGPL-3.0-or-later
4
- %>
5
- <!DOCTYPE html>
6
- <html lang="en">
7
- <head>
8
- <meta charset="UTF-8">
9
- <meta name="viewport" content="width=device-width, initial-scale=1">
10
- <title><%= page_title %> - Example Viewer</title>
11
-
12
- <script>
13
- var rdoc_rel_prefix = "<%= doc_root_link.sub('index.html', '') %>";
14
- var index_rel_prefix = "<%= '../' * (relative_path.split('/').size - 1) %>";
15
- </script>
16
-
17
- <script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_navigation.js" defer></script>
18
- <script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_data.js" defer></script>
19
- <script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_ranker.js" defer></script>
20
- <script src="<%= '../' * (relative_path.split('/').size - 1) %>js/search_controller.js" defer></script>
21
- <script src="<%= '../' * (relative_path.split('/').size - 1) %>js/aliki.js" defer></script>
22
-
23
- <link href="<%= doc_root_link.sub('index.html', '') %>css/rdoc.css" rel="stylesheet">
24
- <link href="<%= doc_root_link.sub('index.html', '') %>custom.css" rel="stylesheet">
25
- </head>
26
- <body class="file<%= ' has-toc' unless toc_items.empty? %>">
27
- <%= icons_svg %>
28
- <header class="top-navbar">
29
- <div class="navbar-brand">
30
- Example Viewer
31
- </div>
32
-
33
- <!-- Desktop search bar -->
34
- <div class="navbar-search navbar-search-desktop" role="search">
35
- <form action="#" method="get" accept-charset="utf-8">
36
- <input id="search-field" role="combobox" aria-label="Search"
37
- aria-autocomplete="list" aria-controls="search-results-desktop"
38
- type="text" name="search" placeholder="Search (/) examples..."
39
- spellcheck="false" autocomplete="off"
40
- title="Type to search, Up and Down to navigate, Enter to load">
41
- <ul id="search-results-desktop" aria-label="Search Results"
42
- aria-busy="false" aria-expanded="false"
43
- aria-atomic="false" class="initially-hidden search-results"></ul>
44
- </form>
45
- </div>
46
-
47
- <!-- Mobile search icon button -->
48
- <button id="search-toggle" class="navbar-search-mobile" aria-label="Open search" type="button">
49
- <span aria-hidden="true">🔍</span>
50
- </button>
51
-
52
- <button id="theme-toggle" class="theme-toggle" aria-label="Switch to dark mode" type="button" onclick="cycleColorMode()">
53
- <span class="theme-toggle-icon" aria-hidden="true">🌙</span>
54
- </button>
55
- </header>
56
-
57
- <!-- Search Modal (Mobile) -->
58
- <div id="search-modal" class="search-modal" hidden aria-modal="true" role="dialog" aria-label="Search">
59
- <div class="search-modal-backdrop"></div>
60
- <div class="search-modal-content">
61
- <div class="search-modal-header">
62
- <form class="search-modal-form" action="#" method="get" accept-charset="utf-8">
63
- <span class="search-modal-icon" aria-hidden="true">🔍</span>
64
- <input id="search-field-mobile" role="combobox" aria-label="Search"
65
- aria-autocomplete="list" aria-controls="search-results-mobile"
66
- type="text" name="search" placeholder="Search examples"
67
- spellcheck="false" autocomplete="off">
68
- <button type="button" class="search-modal-close" aria-label="Close search" id="search-modal-close">
69
- <span aria-hidden="true">esc</span>
70
- </button>
71
- </form>
72
- </div>
73
- <div class="search-modal-body">
74
- <ul id="search-results-mobile" aria-label="Search Results"
75
- aria-busy="false" aria-expanded="false"
76
- aria-atomic="false" class="search-results search-modal-results initially-hidden"></ul>
77
- <div class="search-modal-empty">
78
- <p>No recent searches</p>
79
- </div>
80
- </div>
81
- </div>
82
- </div>
83
-
84
- <nav id="navigation" role="navigation">
85
- <div id="fileindex-section" class="nav-section">
86
- <details class="nav-section-collapsible" open>
87
- <summary class="nav-section-header">
88
- <span class="nav-section-icon">
89
- <svg><use href="#icon-file"></use></svg>
90
- </span>
91
- <span class="nav-section-title">Examples</span>
92
- <span class="nav-section-chevron">
93
- <svg><use href="#icon-chevron"></use></svg>
94
- </span>
95
- </summary>
96
- <ul class="nav-list">
97
- <li><a href="<%= doc_root_link %>">← Back to Docs</a></li>
98
- </ul>
99
- </details>
100
- </div>
101
- <div class="nav-section">
102
- <details class="nav-section-collapsible" open>
103
- <summary class="nav-section-header">
104
- <span class="nav-section-icon">
105
- <svg><use href="#icon-layers"></use></svg>
106
- </span>
107
- <span class="nav-section-title">Files</span>
108
- <span class="nav-section-chevron">
109
- <svg><use href="#icon-chevron"></use></svg>
110
- </span>
111
- </summary>
112
- <ul class="link-list nav-list">
113
- <%= render_tree(tree_data, relative_path, current_file_html) %>
114
- </ul>
115
- </details>
116
- </div>
117
- </nav>
118
-
119
- <main role="main">
120
- <div class="breadcrumb">
121
- <%= breadcrumb_path %>
122
- </div>
123
- <%= file_header_html %>
124
- <div class="content">
125
- <%= file_content_html %>
126
- </div>
127
- </main>
128
-
129
- <% unless toc_items.empty? %>
130
- <aside class="table-of-contents" role="complementary" aria-label="Table of Contents">
131
- <div class="toc-sticky">
132
- <div class="toc-list">
133
- <h3>On This Page</h3>
134
- <%= render_toc(toc_items) %>
135
- </div>
136
- </div>
137
- </aside>
138
- <% end %>
139
-
140
-
141
- <script>
142
- const modes = ['auto', 'light', 'dark'];
143
- const icons = { auto: '🌓', light: '☀️', dark: '🌙' };
144
-
145
- function setColorMode(mode) {
146
- if (mode === 'auto') {
147
- document.documentElement.removeAttribute('data-theme');
148
- const systemTheme = (window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches) ? 'dark' : 'light';
149
- document.documentElement.setAttribute('data-theme', systemTheme);
150
- } else {
151
- document.documentElement.setAttribute('data-theme', mode);
152
- }
153
-
154
- const icon = icons[mode];
155
- const toggle = document.getElementById('theme-toggle');
156
- toggle.querySelector('.theme-toggle-icon').textContent = icon;
157
-
158
- localStorage.setItem('rdoc-theme', mode);
159
- }
160
-
161
- function cycleColorMode() {
162
- const current = localStorage.getItem('rdoc-theme') || 'auto';
163
- const currentIndex = modes.indexOf(current);
164
- const nextMode = modes[(currentIndex + 1) % modes.length];
165
- setColorMode(nextMode);
166
- }
167
-
168
- const savedMode = localStorage.getItem('rdoc-theme') || 'auto';
169
- setColorMode(savedMode);
170
- </script>
171
- </body>
172
- </html>
data/tasks/extension.rake DELETED
@@ -1,14 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #--
4
- # SPDX-FileCopyrightText: 2025 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
6
- #++
7
-
8
- require "rake/extensiontask"
9
-
10
- spec = Gem::Specification.load("ratatui_ruby.gemspec")
11
- Rake::ExtensionTask.new("ratatui_ruby", spec) do |ext|
12
- ext.lib_dir = "lib/ratatui_ruby"
13
- ext.ext_dir = "ext/ratatui_ruby"
14
- end
@@ -1,223 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #--
4
- # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
6
- #++
7
-
8
- # Script to ensure markdown files have correct SPDX file headers (CC-BY-SA-4.0).
9
- #
10
- # Usage: ruby tasks/license/headers_md.rb [path...]
11
- #
12
- # If no paths are given, processes all .md files via git ls-files.
13
- #
14
- # Rules:
15
- # - Ensures file has CC-BY-SA-4.0 license header with YOUR copyright
16
- # - Updates years for EXISTING contributors based on git blame + Co-Authored-By
17
- # - Does NOT add new contributors from git history - only updates existing ones
18
- # - Uses non-code-block lines for year calculation
19
- # - Adds header with YOUR copyright if missing
20
-
21
- require_relative "license_utils"
22
-
23
- YOUR_NAME = "Kerrick Long"
24
- YOUR_EMAIL = "me@kerricklong.com"
25
- YOUR_IDENTIFIERS = [YOUR_NAME, YOUR_EMAIL].freeze
26
- YOUR_COPYRIGHT = "#{YOUR_NAME} <#{YOUR_EMAIL}>"
27
- LICENSE = "CC-BY-SA-4.0"
28
-
29
- def find_code_blocks(lines)
30
- blocks = []
31
- i = 0
32
-
33
- while i < lines.length
34
- line = lines[i]
35
-
36
- if line =~ /^(````*)(\w*)$/
37
- fence_marker = $1
38
- fence_start = i
39
- re_end = /^#{Regexp.escape(fence_marker)}$/
40
-
41
- j = i + 1
42
- while j < lines.length
43
- if lines[j] =~ re_end
44
- blocks << { start: fence_start, end: j }
45
- i = j
46
- break
47
- end
48
- j += 1
49
- end
50
- end
51
-
52
- i += 1
53
- end
54
-
55
- blocks
56
- end
57
-
58
- def get_non_code_line_ranges(lines)
59
- header_end = 0
60
- if lines[0]&.include?("<!--")
61
- (0...(lines.length)).each do |i|
62
- if lines[i].include?("-->")
63
- header_end = i + 1
64
- break
65
- end
66
- end
67
- end
68
-
69
- code_blocks = find_code_blocks(lines)
70
- non_code_ranges = []
71
- current_line = header_end
72
-
73
- code_blocks.each do |block|
74
- if current_line < block[:start]
75
- non_code_ranges << [current_line + 1, block[:start]]
76
- end
77
- current_line = block[:end] + 1
78
- end
79
-
80
- if current_line < lines.length
81
- non_code_ranges << [current_line + 1, lines.length]
82
- end
83
-
84
- non_code_ranges
85
- end
86
-
87
- def parse_existing_header(lines)
88
- return nil unless lines[0]&.include?("<!--")
89
-
90
- header_end = nil
91
- copyrights = []
92
- license = nil
93
-
94
- (0...(lines.length)).each do |i|
95
- line = lines[i]
96
-
97
- if line =~ /SPDX-FileCopyrightText:\s*(\d{4})\s+(.+)$/
98
- copyrights << { year: $1.to_i, holder: $2.strip }
99
- # REUSE-IgnoreStart
100
- elsif line =~ /SPDX-License-Identifier:\s*(.+)$/
101
- # REUSE-IgnoreEnd
102
- license = $1.strip
103
- end
104
-
105
- if line.include?("-->")
106
- header_end = i
107
- break
108
- end
109
- end
110
-
111
- return nil if header_end.nil?
112
- return nil if copyrights.empty? && license.nil?
113
-
114
- { end_line: header_end, copyrights:, license: }
115
- end
116
-
117
- def process_file(filepath)
118
- content = File.read(filepath)
119
- lines = content.lines
120
-
121
- non_code_ranges = get_non_code_line_ranges(lines)
122
-
123
- # Get contributors from non-code lines for year lookups
124
- all_contributors = {}
125
- non_code_ranges.each do |start_line, end_line|
126
- range_contributors = LicenseUtils.get_contributors_for_lines(filepath, start_line, end_line)
127
- range_contributors.each do |contributor, year|
128
- all_contributors[contributor] = [all_contributors[contributor] || 0, year].max
129
- end
130
- end
131
-
132
- your_year = nil
133
- all_contributors.each do |contributor, year|
134
- if YOUR_IDENTIFIERS.any? { |id| contributor.include?(id) }
135
- your_year = [your_year || 0, year].max
136
- end
137
- end
138
- your_year ||= Date.today.year
139
-
140
- existing = parse_existing_header(lines)
141
-
142
- if existing
143
- # Only update years for EXISTING contributors
144
- needs_update = false
145
- updated_copyrights = []
146
-
147
- existing[:copyrights].each do |c|
148
- git_year = nil
149
- all_contributors.each do |contributor, year|
150
- if c[:holder].split.any? { |word| contributor.include?(word) }
151
- git_year = [git_year || 0, year].max
152
- end
153
- end
154
-
155
- if git_year && git_year != c[:year]
156
- puts " Updated #{c[:holder].split.first}'s copyright year: #{c[:year]} -> #{git_year}"
157
- updated_copyrights << { year: git_year, holder: c[:holder] }
158
- needs_update = true
159
- else
160
- updated_copyrights << c
161
- end
162
- end
163
-
164
- # Check if YOUR year needs updating
165
- your_existing = updated_copyrights.find { |c| YOUR_IDENTIFIERS.any? { |id| c[:holder].include?(id) } }
166
- if your_existing.nil?
167
- puts " Adding your copyright"
168
- updated_copyrights << { year: your_year, holder: YOUR_COPYRIGHT }
169
- needs_update = true
170
- end
171
-
172
- if existing[:license] != LICENSE
173
- puts " Fixing license: #{existing[:license]} -> #{LICENSE}"
174
- needs_update = true
175
- end
176
-
177
- if needs_update
178
- # REUSE-IgnoreStart
179
- header_lines = ["<!--\n"]
180
- updated_copyrights.each do |c|
181
- header_lines << " SPDX-FileCopyrightText: #{c[:year]} #{c[:holder]}\n"
182
- end
183
- header_lines << " SPDX-License-Identifier: #{LICENSE}\n"
184
- header_lines << "-->\n"
185
- # REUSE-IgnoreEnd
186
-
187
- remaining = lines[(existing[:end_line] + 1)..]
188
- File.write(filepath, header_lines.join + remaining.join)
189
- puts "Updated: #{filepath}"
190
- end
191
- else
192
- # No header - add one with YOUR copyright only
193
- # REUSE-IgnoreStart
194
- header = "<!--\n SPDX-FileCopyrightText: #{your_year} #{YOUR_COPYRIGHT}\n SPDX-License-Identifier: #{LICENSE}\n-->\n"
195
- # REUSE-IgnoreEnd
196
-
197
- File.write(filepath, header + content)
198
- puts "Added header: #{filepath}"
199
- end
200
- end
201
-
202
- def find_md_files(paths)
203
- if paths.empty?
204
- `git ls-files '*.md'`.split("\n")
205
- else
206
- paths.flat_map do |path|
207
- if File.directory?(path)
208
- `git ls-files '#{path}/**/*.md'`.split("\n")
209
- else
210
- path
211
- end
212
- end
213
- end
214
- end
215
-
216
- if __FILE__ == $0
217
- paths = ARGV.empty? ? [] : ARGV
218
- files = find_md_files(paths)
219
-
220
- files.each do |file|
221
- process_file(file)
222
- end
223
- end
@@ -1,210 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- #--
4
- # SPDX-FileCopyrightText: 2026 Kerrick Long <me@kerricklong.com>
5
- # SPDX-License-Identifier: AGPL-3.0-or-later
6
- #++
7
-
8
- # Script to ensure Ruby files have correct SPDX file headers.
9
- #
10
- # Usage: ruby tasks/license/headers_rb.rb [path...]
11
- #
12
- # If no paths are given, processes lib/, ext/, test/, examples/, tasks/, bin/.
13
- #
14
- # License selection by directory:
15
- # - lib/, ext/, test/ → LGPL-3.0-or-later
16
- # - examples/widget_*, examples/verify_* → MIT-0
17
- # - examples/app_*, tasks/, bin/ → AGPL-3.0-or-later
18
-
19
- require_relative "license_utils"
20
-
21
- YOUR_NAME = "Kerrick Long"
22
- YOUR_EMAIL = "me@kerricklong.com"
23
- YOUR_IDENTIFIERS = [YOUR_NAME, YOUR_EMAIL].freeze
24
- YOUR_COPYRIGHT = "#{YOUR_NAME} <#{YOUR_EMAIL}>"
25
-
26
- def license_for_file(filepath)
27
- case filepath
28
- when %r{^(lib|sig/ratatui_ruby|ext|test)/}
29
- "LGPL-3.0-or-later"
30
- when %r{^(examples|sig/examples)/(widget_|verify_)}
31
- "MIT-0"
32
- else
33
- "AGPL-3.0-or-later"
34
- end
35
- end
36
-
37
- def parse_existing_header(lines)
38
- # Returns { end_line:, copyrights: [{year:, holder:}], license: }
39
- # REUSE-IgnoreStart
40
- # Ruby files typically have:
41
- # # frozen_string_literal: true
42
- # (blank line)
43
- # #--
44
- # # SPDX-FileCopyrightText: YYYY Name
45
- # # SPDX-License-Identifier: LICENSE
46
- # #++
47
- # REUSE-IgnoreEnd
48
-
49
- copyrights = []
50
- license = nil
51
- header_end = nil
52
- found_spdx = false
53
-
54
- lines.each_with_index do |line, i|
55
- if line =~ /^#\s*SPDX-FileCopyrightText:\s*(\d{4})\s+(.+)$/
56
- copyrights << { year: $1.to_i, holder: $2.strip }
57
- found_spdx = true
58
- # REUSE-IgnoreStart
59
- elsif line =~ /^#\s*SPDX-License-Identifier:\s*(.+)$/
60
- # REUSE-IgnoreEnd
61
- license = $1.strip
62
- found_spdx = true
63
- elsif line =~ /^#\+\+\s*$/ && found_spdx
64
- header_end = i
65
- break
66
- end
67
- end
68
-
69
- return nil if copyrights.empty? && license.nil?
70
-
71
- { end_line: header_end || 0, copyrights:, license: }
72
- end
73
-
74
- def process_file(filepath)
75
- content = File.read(filepath)
76
- lines = content.lines
77
-
78
- target_license = license_for_file(filepath)
79
-
80
- # Get contributors from git for year lookups
81
- all_contributors = LicenseUtils.get_contributors_for_lines(filepath)
82
- your_year = LicenseUtils.get_your_latest_year(filepath, YOUR_IDENTIFIERS)
83
-
84
- existing = parse_existing_header(lines)
85
-
86
- if existing
87
- # File has existing header - only update years for EXISTING contributors
88
- needs_update = false
89
- updated_copyrights = []
90
-
91
- existing[:copyrights].each do |c|
92
- # Find this contributor's latest year from git
93
- git_year = nil
94
- all_contributors.each do |contributor, year|
95
- if c[:holder].split.any? { |word| contributor.include?(word) }
96
- git_year = [git_year || 0, year].max
97
- end
98
- end
99
-
100
- if git_year && git_year != c[:year]
101
- puts " Updated #{c[:holder].split.first}'s copyright year: #{c[:year]} -> #{git_year}"
102
- updated_copyrights << { year: git_year, holder: c[:holder] }
103
- needs_update = true
104
- else
105
- updated_copyrights << c
106
- end
107
- end
108
-
109
- # Check if YOUR year needs updating (if you're a contributor)
110
- your_existing = updated_copyrights.find { |c| YOUR_IDENTIFIERS.any? { |id| c[:holder].include?(id) } }
111
- if your_existing.nil?
112
- puts " Adding your copyright"
113
- updated_copyrights << { year: your_year, holder: YOUR_COPYRIGHT }
114
- needs_update = true
115
- end
116
-
117
- # Check license
118
- if existing[:license] != target_license
119
- puts " Fixing license: #{existing[:license]} -> #{target_license}"
120
- needs_update = true
121
- end
122
-
123
- if needs_update
124
- frozen_string = lines[0].include?("frozen_string_literal") ? lines[0] : nil
125
-
126
- header_lines = []
127
- header_lines << "# frozen_string_literal: true\n" unless frozen_string
128
- header_lines << "\n" if frozen_string.nil? && !lines[0].strip.empty?
129
- header_lines << "#--\n"
130
-
131
- # REUSE-IgnoreStart
132
- updated_copyrights.each do |c|
133
- header_lines << "# SPDX-FileCopyrightText: #{c[:year]} #{c[:holder]}\n"
134
- end
135
- header_lines << "# SPDX-License-Identifier: #{target_license}\n"
136
- # REUSE-IgnoreEnd
137
- header_lines << "#++\n"
138
-
139
- content_start = existing[:end_line] + 1
140
- while content_start < lines.length && lines[content_start].strip.empty?
141
- content_start += 1
142
- end
143
-
144
- remaining = lines[content_start..]
145
-
146
- new_content = if frozen_string
147
- "#{frozen_string}\n#{header_lines.join}\n#{remaining.join}"
148
- else
149
- "#{header_lines.join}\n#{remaining.join}"
150
- end
151
-
152
- File.write(filepath, new_content)
153
- puts "Updated: #{filepath}"
154
- end
155
- else
156
- # No header - add one with YOUR copyright only
157
- frozen_line = lines[0]&.include?("frozen_string_literal") ? lines.shift : nil
158
-
159
- header = []
160
- header << "# frozen_string_literal: true\n\n" unless frozen_line
161
- header << "#--\n"
162
- # REUSE-IgnoreStart
163
- header << "# SPDX-FileCopyrightText: #{your_year} #{YOUR_COPYRIGHT}\n"
164
- header << "# SPDX-License-Identifier: #{target_license}\n"
165
- # REUSE-IgnoreEnd
166
- header << "#++\n\n"
167
-
168
- if frozen_line
169
- File.write(filepath, "#{frozen_line}\n#{header.join}#{lines.join}")
170
- else
171
- File.write(filepath, header.join + lines.join)
172
- end
173
- puts "Added header: #{filepath}"
174
- end
175
- end
176
-
177
- def find_rb_files(paths)
178
- if paths.empty?
179
- # Process all relevant directories
180
- dirs = %w[lib ext test examples tasks bin sig]
181
- files = dirs.flat_map do |dir|
182
- # Include both root files and subdirectory files, for both .rb and .rbs
183
- %w[rb rbs].flat_map do |ext|
184
- root_files = `git ls-files '#{dir}/*.#{ext}' 2>/dev/null`.split("\n")
185
- sub_files = `git ls-files '#{dir}/**/*.#{ext}' 2>/dev/null`.split("\n")
186
- root_files + sub_files
187
- end
188
- end
189
- files.uniq
190
- else
191
- paths.flat_map do |path|
192
- if File.directory?(path)
193
- rb_files = `git ls-files '#{path}/**/*.rb'`.split("\n")
194
- rbs_files = `git ls-files '#{path}/**/*.rbs'`.split("\n")
195
- rb_files + rbs_files
196
- else
197
- path
198
- end
199
- end
200
- end
201
- end
202
-
203
- if __FILE__ == $0
204
- paths = ARGV.empty? ? [] : ARGV
205
- files = find_rb_files(paths)
206
-
207
- files.each do |file|
208
- process_file(file)
209
- end
210
- end