omoteura 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 (6) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +39 -0
  3. data/LICENSE +21 -0
  4. data/README.md +283 -0
  5. data/lib/omoteura.rb +4 -0
  6. metadata +73 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6b75d455c45d6bd7ea34a9f557ee45a71c595384d17fe077da82bd904b507bc8
4
+ data.tar.gz: 63882a5dfc1cd5aa0ac1371efeea35858b05222045621609862fa0c38ce9a0f1
5
+ SHA512:
6
+ metadata.gz: 77e33fca85df39fa1e84e28dd692987aaac895343173141d67a9bfddf0afe4dc90a81d8a1abe3653a5507fce37f0e215f4f105a3a2696f628bc95f5c9839e2ff
7
+ data.tar.gz: f93a8834d735260608dfc5aea9fa4872fd6a8e9b788db5101bd2dc4a324c1ba8956419e70965763c4cc931c65980ffd3ae4e4cb1f728170f639d3f2fd14a242d
data/CHANGELOG.md ADDED
@@ -0,0 +1,39 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project are documented in this file. The format
4
+ is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the
5
+ project follows [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
6
+
7
+ ## Unreleased
8
+
9
+ ## 0.1.0 - 2026-10-23
10
+
11
+ The first release.
12
+
13
+ ### Added
14
+
15
+ - Read Excalidraw (`.excalidraw`) and Obsidian Excalidraw (`.md`) drawings,
16
+ including compressed drawing data.
17
+ - Attach a diagram to a code file by magic comment, `.omoteura.yml` or the
18
+ `ura/` path convention.
19
+ - Resolve `omoteura:` links to specs, methods and statements.
20
+ - `omoteura check` to report broken links and unattached diagrams.
21
+ - `Omoteura::RSpec::Formatter` to record test results as JSON, and the lines
22
+ of the project's code that ran when SimpleCov or another tool measures
23
+ coverage.
24
+ - `omoteura inspect` and `omoteura diagram`, which give editors one file's or
25
+ one diagram's data as JSON.
26
+ - `omoteura draft` to draft a diagram from code, with every box linked, as
27
+ `.excalidraw` or, with `--format md`, as an Obsidian note; it never replaces
28
+ an existing diagram; `--merge` adds only what the diagram has no shape for
29
+ yet, beside what is drawn, and `--json` prints the results for editors.
30
+ - Write Obsidian Excalidraw notes as the plugin does, keeping what the user
31
+ wrote above the drawing, and read links edited under its Element Links.
32
+ - `omoteura links`, which lists the places in a code file a shape can link
33
+ to, each with a link that resolves to exactly that place.
34
+ - `omoteura coverage`, which lists a file's declarations and public methods
35
+ and the examples that name them, for the editor's coverage panel;
36
+ `coverage_panel: false` turns it off.
37
+ - `omoteura save` for editors to save a changed drawing in the file's own
38
+ format, in one step and never over a change made elsewhere since.
39
+ - A clear message, instead of a crash, on Ruby older than 3.4.
data/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 KAIBYAKU K.K
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,283 @@
1
+ <p align="center">
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="docs/logo/omoteura-logo-vertical-dark.svg">
4
+ <img src="docs/logo/omoteura-logo-vertical.svg" alt="omoteura: code in front, context behind." width="300">
5
+ </picture>
6
+ </p>
7
+
8
+ # Omoteura [![CI](https://github.com/kaibyaku-jp/omoteura/actions/workflows/ci.yml/badge.svg)](https://github.com/kaibyaku-jp/omoteura/actions/workflows/ci.yml)
9
+
10
+ Code in front, context behind.
11
+
12
+ The code is the *omote* (front). Behind it sits an Excalidraw drawing, the
13
+ *ura* (back): diagrams, notes and the reasons behind the code, with shapes
14
+ that link to the specs and methods they describe.
15
+
16
+ > **Status:** pre-release, not yet on RubyGems. The gems below already resolve
17
+ > links, check them in CI and record test results. The VS Code extension in
18
+ > [editors/vscode](editors/vscode) marks linked lines with their test results,
19
+ > flips between the code and the drawing, and edits the drawing in place.
20
+
21
+
22
+ ## Features
23
+
24
+ ### Drawn by You
25
+
26
+ Omoteura never generates diagrams. Draw them in Obsidian's Excalidraw plugin
27
+ or on excalidraw.com, the way you would sketch on a whiteboard, and drop the
28
+ file next to your code.
29
+
30
+ ### Linked by Name
31
+
32
+ A shape's link names a spec description, a method or the start of a statement,
33
+ not a line number, so links survive the edits around them.
34
+
35
+ ### Checked in CI
36
+
37
+ `omoteura check` fails the build when a spec is renamed and a diagram still
38
+ points at the old name, or when a diagram is left behind by a moved file.
39
+
40
+ ### Hands Off Your Code
41
+
42
+ Omoteura only reads files. It runs from the command line and next to RSpec,
43
+ never inside your application, never rewrites your code and does nothing at
44
+ all where there is no diagram.
45
+
46
+ ### Light
47
+
48
+ Omoteura reads every Ruby file in a project, so it is measured for allocations
49
+ as well as time. Files without a magic comment are skipped without allocating.
50
+
51
+
52
+ ## Supported Versions
53
+
54
+ * Ruby 3.4, 4.0
55
+
56
+ * Rails 7.1, 7.2, 8.0, 8.1 projects; Omoteura reads their files and never loads Rails
57
+
58
+ * RSpec 3.12+
59
+
60
+ * Excalidraw (`.excalidraw`) and Obsidian Excalidraw (`.excalidraw.md`)
61
+
62
+
63
+ ## Installation
64
+
65
+ Put this in your Gemfile:
66
+
67
+ ```ruby
68
+ group :development, :test do
69
+ gem "omoteura", require: false
70
+ end
71
+ ```
72
+
73
+ `require: false` keeps Rails from loading Omoteura into your application; the
74
+ `omoteura` command and RSpec load what they need. Then bundle:
75
+
76
+ ```sh
77
+ % bundle
78
+ ```
79
+
80
+ `omoteura` installs the following gems. You can also pick only the ones you need.
81
+
82
+ | gem | contents |
83
+ | --- | --- |
84
+ | `omoteura-core` | Diagram files, `omoteura:` links and the `omoteura` command |
85
+ | `omoteura-rspec` | A formatter that records test results for diagrams |
86
+
87
+
88
+ ## Attaching Diagrams
89
+
90
+ ### By Path
91
+
92
+ Put the diagram under `ura/` at the same path as the code. Nothing else is
93
+ needed.
94
+
95
+ | code | diagram |
96
+ | --- | --- |
97
+ | `app/models/user.rb` | `ura/app/models/user.excalidraw.md` |
98
+ | `spec/models/user_spec.rb` | `ura/spec/models/user_spec.excalidraw` |
99
+
100
+ When both `.excalidraw.md` and `.excalidraw` exist, `.excalidraw.md` is used.
101
+
102
+ ### By Magic Comment
103
+
104
+ To share one diagram between files or give it any name, write a magic comment
105
+ on its own line at the top or the bottom of the file:
106
+
107
+ ```ruby
108
+ class User < ApplicationRecord
109
+ end
110
+
111
+ # omoteura: ura/shared/user-validations.excalidraw.md
112
+ ```
113
+
114
+ A path copied from Obsidian without its `.md` works too.
115
+
116
+ ### By `.omoteura.yml`
117
+
118
+ To leave the code untouched, map files in `.omoteura.yml`:
119
+
120
+ ```yaml
121
+ attach:
122
+ app/models/user.rb: ura/shared/user-validations.excalidraw.md
123
+ ```
124
+
125
+ A magic comment wins over `.omoteura.yml`, which wins over the path.
126
+
127
+
128
+ ## Drafting a Diagram
129
+
130
+ A blank page is the hardest part, so Omoteura can draft a diagram to draw on:
131
+
132
+ ```sh
133
+ % bundle exec omoteura draft spec/models/user_spec.rb
134
+ wrote ura/spec/models/user_spec.excalidraw (4 shapes)
135
+ ```
136
+
137
+ A spec gets a column per example group and a box per example; other code gets
138
+ a column per kind of declaration (validations, associations, callbacks, scopes,
139
+ enums) and one for public methods. Every box already links to its code, so test
140
+ results show up straight away. Then make it yours: move, delete, annotate.
141
+
142
+ A draft never replaces a diagram. When the file already has one, it goes beside
143
+ it as `user_spec.draft.excalidraw` for you to copy from, and `omoteura check`
144
+ reminds you to delete it. `--format md` writes an Obsidian `.excalidraw.md`
145
+ note instead, and `--dry-run`, `--only methods,validations` and `--out DIR`
146
+ are available too.
147
+
148
+ As the code grows, `--merge` adds what the diagram has no shape for yet, in
149
+ columns to the right of everything drawn. A shape counts as drawn when its
150
+ link points at the same code or its label is the same, and nothing drawn is
151
+ moved or removed:
152
+
153
+ ```sh
154
+ % bundle exec omoteura draft spec/models/user_spec.rb --merge
155
+ added 2 shapes to ura/spec/models/user_spec.excalidraw
156
+ ```
157
+
158
+
159
+ ## Linking Shapes to Code
160
+
161
+ Set a shape's link to text starting with `omoteura:`. Both Excalidraw and
162
+ Obsidian let you edit a shape's link.
163
+
164
+ | link | points to |
165
+ | --- | --- |
166
+ | `omoteura:#email is unique` | the spec whose description ends with "email is unique", in the attached file |
167
+ | `omoteura:#display_name` | the `describe "#display_name"` group, or the method |
168
+ | `omoteura:spec/models/user_spec.rb#validations email is unique` | the same, in another file |
169
+ | `omoteura:app/models/user.rb#validates :email` | the statement that starts with that text |
170
+ | `omoteura:app/models/user.rb` | the whole file |
171
+
172
+ A fragment is tried as a spec description, then a method name, then the start
173
+ of a statement. A link that matches nothing, or more than one place, is broken.
174
+
175
+
176
+ ## Checking Links
177
+
178
+ ```sh
179
+ % bundle exec omoteura check
180
+ ura/app/models/user.excalidraw: omoteura:#full_name matches nothing in app/models/user.rb (shape "Display name")
181
+ Checked 12 diagrams and 48 links: 1 problem.
182
+ ```
183
+
184
+ It reports broken links, missing or unreadable diagrams and diagrams no code
185
+ file is attached to, and exits with status 1 when there are any. In GitHub
186
+ Actions, add `--format github` to see the problems as annotations.
187
+
188
+
189
+ ## Recording Test Results
190
+
191
+ Add the formatter to `.rspec`, next to your usual one:
192
+
193
+ ```text
194
+ --format progress
195
+ --format Omoteura::RSpec::Formatter --out tmp/omoteura/results.json
196
+ ```
197
+
198
+ Each example's status and failure message go to `tmp/omoteura/results.json`.
199
+ Keep `tmp/omoteura/` out of version control.
200
+
201
+ When something already measures coverage, as SimpleCov does, the formatter
202
+ also records which lines of your code ran, so the coverage panel can tell
203
+ which methods the tests called. It never starts coverage itself.
204
+
205
+
206
+ ## In VS Code
207
+
208
+ The extension in [editors/vscode](editors/vscode) marks each line a shape
209
+ links to with the result of the tests behind it, explains it on hover, and
210
+ flips between a file and its diagram with `⌥⌘U` (`Ctrl+Alt+U`). The diagram
211
+ opens in Excalidraw with linked shapes outlined by test status; clicking a
212
+ link opens the code. Saving writes the file's own format, so an Obsidian note
213
+ keeps everything around the drawing, and a change made elsewhere since it
214
+ opened is never overwritten. A coverage panel lists which declarations and
215
+ public methods of the open file its specs cover.
216
+
217
+
218
+ ## Commands
219
+
220
+ | command | does |
221
+ | --- | --- |
222
+ | `omoteura check` | Report broken links and diagrams not attached to code |
223
+ | `omoteura draft FILE...` | Draft a diagram from code, as a starting point to draw on |
224
+ | `omoteura inspect FILE` | Print one file's diagram, links and test results as JSON, for editors |
225
+ | `omoteura diagram FILE` | Print one diagram's drawing, links and test results as JSON, for editors |
226
+ | `omoteura links FILE` | Print the places in one code file a shape can link to, with their links, as JSON, for editors |
227
+ | `omoteura coverage FILE` | Print which declarations and public methods of one file its specs cover, as JSON, for editors |
228
+ | `omoteura save FILE` | Save a drawing an editor changed, read as JSON from stdin, in the file's format |
229
+ | `omoteura version` | Print the version |
230
+
231
+ Run `omoteura <command> --help` for options.
232
+
233
+
234
+ ## Configuring Omoteura
235
+
236
+ `.omoteura.yml` at the project root is optional:
237
+
238
+ | key | default | meaning |
239
+ | --- | --- | --- |
240
+ | `diagrams_dir` | `ura` | Where diagrams live, relative to the root |
241
+ | `attach` | none | Code paths mapped to diagram paths |
242
+ | `coverage_panel` | `true` | `false` turns off the editor's list of tested and untested declarations and methods |
243
+
244
+ `.omoteura.local.yml` is read on top of it, entry by entry, for settings of
245
+ your own. Keep it out of version control.
246
+
247
+
248
+ ## Questions, Feedback
249
+
250
+ Open an issue on GitHub. Report security problems privately as described in
251
+ [SECURITY.md](SECURITY.md).
252
+
253
+
254
+ ## Contributing to Omoteura
255
+
256
+ Fork, fix, then send a pull request. [CONTRIBUTING.md](CONTRIBUTING.md) has the
257
+ details.
258
+
259
+ To run the specs and lint:
260
+
261
+ ```sh
262
+ % nix develop # or use Ruby 3.4+ without Nix
263
+ % bundle install
264
+ % bundle exec rake
265
+ ```
266
+
267
+ To run the specs against the oldest supported rspec-core:
268
+
269
+ ```sh
270
+ % BUNDLE_GEMFILE=gemfiles/rspec_3_12.gemfile bundle install
271
+ % BUNDLE_GEMFILE=gemfiles/rspec_3_12.gemfile bundle exec rake spec
272
+ ```
273
+
274
+ To measure allocations and time of the main code paths:
275
+
276
+ ```sh
277
+ % bundle exec rake bench
278
+ ```
279
+
280
+
281
+ ## Copyright
282
+
283
+ Copyright (c) 2026- KAIBYAKU K.K. See [LICENSE](LICENSE) for further details.
data/lib/omoteura.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "omoteura/core"
4
+ require "omoteura/rspec"
metadata ADDED
@@ -0,0 +1,73 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: omoteura
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - KAIBYAKU K.K
8
+ bindir: bin
9
+ cert_chain: []
10
+ date: 1980-01-02 00:00:00.000000000 Z
11
+ dependencies:
12
+ - !ruby/object:Gem::Dependency
13
+ name: omoteura-core
14
+ requirement: !ruby/object:Gem::Requirement
15
+ requirements:
16
+ - - '='
17
+ - !ruby/object:Gem::Version
18
+ version: 0.1.0
19
+ type: :runtime
20
+ prerelease: false
21
+ version_requirements: !ruby/object:Gem::Requirement
22
+ requirements:
23
+ - - '='
24
+ - !ruby/object:Gem::Version
25
+ version: 0.1.0
26
+ - !ruby/object:Gem::Dependency
27
+ name: omoteura-rspec
28
+ requirement: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - '='
31
+ - !ruby/object:Gem::Version
32
+ version: 0.1.0
33
+ type: :runtime
34
+ prerelease: false
35
+ version_requirements: !ruby/object:Gem::Requirement
36
+ requirements:
37
+ - - '='
38
+ - !ruby/object:Gem::Version
39
+ version: 0.1.0
40
+ description: Meta gem that installs omoteura-core and omoteura-rspec.
41
+ executables: []
42
+ extensions: []
43
+ extra_rdoc_files: []
44
+ files:
45
+ - CHANGELOG.md
46
+ - LICENSE
47
+ - README.md
48
+ - lib/omoteura.rb
49
+ homepage: https://github.com/kaibyaku-jp/omoteura
50
+ licenses:
51
+ - MIT
52
+ metadata:
53
+ source_code_uri: https://github.com/kaibyaku-jp/omoteura
54
+ changelog_uri: https://github.com/kaibyaku-jp/omoteura/blob/main/CHANGELOG.md
55
+ rubygems_mfa_required: 'true'
56
+ rdoc_options: []
57
+ require_paths:
58
+ - lib
59
+ required_ruby_version: !ruby/object:Gem::Requirement
60
+ requirements:
61
+ - - ">="
62
+ - !ruby/object:Gem::Version
63
+ version: '3.4'
64
+ required_rubygems_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ requirements: []
70
+ rubygems_version: 3.6.9
71
+ specification_version: 4
72
+ summary: Overlay hand-drawn Excalidraw diagrams on Rails and RSpec code
73
+ test_files: []