rails-schema 0.1.4 → 0.1.5
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +17 -0
- data/CLAUDE.md +4 -2
- data/README.md +8 -1
- data/docs/index.html +544 -54
- data/docs/screenshot.png +0 -0
- data/lib/rails/schema/assets/app.js +175 -20
- data/lib/rails/schema/assets/style.css +50 -4
- data/lib/rails/schema/assets/template.html.erb +6 -1
- data/lib/rails/schema/configuration.rb +2 -1
- data/lib/rails/schema/extractor/model_scanner.rb +2 -0
- data/lib/rails/schema/extractor/mongoid/model_scanner.rb +2 -0
- data/lib/rails/schema/transformer/edge.rb +6 -1
- data/lib/rails/schema/transformer/graph_builder.rb +51 -3
- data/lib/rails/schema/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 14f99b5a4a676074862ccab2a47f79ebb68595632cf6b3770e9383d14ab02202
|
|
4
|
+
data.tar.gz: e145477c9d42ac72e16972eed1ef0d2dd3d325cd4a9fcf1ba0bf595beceb2d4d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: c756f2e042f3b2958357eeb3048f900ea695139f4163ebe50770926dd1e597eda5695f96aa4763e7a401ef5b5f5d767e5306bd595528534cffb08601e20cda4a
|
|
7
|
+
data.tar.gz: 3a7734bc958fdac6246e35585fb66ed62609c1bbfa30dd5fa8640dcb36d7817d774321dd439bb51589eef657cdd8b7324699babf20e34ecf49a3367da6140a51
|
data/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,23 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/), and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [0.1.5] - 2026-03-14
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `exclude_model_if` configuration option: provide a proc/lambda to dynamically exclude models based on arbitrary conditions, works with both ActiveRecord and Mongoid pipelines (#16)
|
|
12
|
+
- Mermaid ER diagram export (`.mmd`) — respects sidebar visibility filters so you can export a subset of models (#23)
|
|
13
|
+
- Double-click a model node to isolate its neighborhood (#20)
|
|
14
|
+
- Shift-click range selection for sidebar checkboxes (#24)
|
|
15
|
+
- Smart "Select All" toggle — when all models are selected and a search filter is active, narrows to only filtered models (#24)
|
|
16
|
+
- Search clear button in the sidebar (#24)
|
|
17
|
+
- Color-coded edge labels by association type (#19)
|
|
18
|
+
- Edge deduplication for `has_many`/`belongs_to` pairs — reciprocal associations are merged into a single edge with dual labels, each colored by its own association type
|
|
19
|
+
|
|
20
|
+
### Changed
|
|
21
|
+
|
|
22
|
+
- Refactored text measurement and truncation functions for cleaner rendering
|
|
23
|
+
|
|
7
24
|
## [0.1.4] - 2026-03-08
|
|
8
25
|
|
|
9
26
|
### Added
|
data/CLAUDE.md
CHANGED
|
@@ -57,7 +57,7 @@ end
|
|
|
57
57
|
1. Calls `Rails.application.eager_load!` (Zeitwerk support, multiple fallback strategies including `LoadError` rescue)
|
|
58
58
|
2. Collects `ActiveRecord::Base.descendants`
|
|
59
59
|
3. Filters: abstract classes, anonymous classes, models without known tables
|
|
60
|
-
4. Applies `exclude_models` config (supports wildcard prefix like `"ActiveStorage::*"`)
|
|
60
|
+
4. Applies `exclude_models` config (supports wildcard prefix like `"ActiveStorage::*"`) and `exclude_model_if` proc
|
|
61
61
|
|
|
62
62
|
`Mongoid::ModelScanner`:
|
|
63
63
|
1. Eager-loads via Zeitwerk or file glob with fallbacks
|
|
@@ -96,7 +96,8 @@ Single self-contained HTML file — no CDN, no network requests. D3 is vendored/
|
|
|
96
96
|
|
|
97
97
|
- **Vanilla JS + d3-force** for graph rendering
|
|
98
98
|
- **CSS custom properties** for dark/light theming
|
|
99
|
-
- Features: searchable sidebar, click-to-focus, detail panel, zoom/pan, keyboard shortcuts (`/` search, `Esc` deselect, `+/-` zoom, `F` fit)
|
|
99
|
+
- Features: searchable sidebar, click-to-focus, double-click to isolate neighborhood, detail panel, zoom/pan, keyboard shortcuts (`/` search, `Esc` deselect, `+/-` zoom, `F` fit), Mermaid ER diagram export (`.mmd`) filtered by sidebar visibility
|
|
100
|
+
- **Select All smart toggle** — when all models are already selected and a search filter is active, "Select All" narrows to only filtered models (acts as "select only these"); otherwise it adds filtered models to the current selection
|
|
100
101
|
|
|
101
102
|
## Design Decisions
|
|
102
103
|
|
|
@@ -105,3 +106,4 @@ Single self-contained HTML file — no CDN, no network requests. D3 is vendored/
|
|
|
105
106
|
- **Parse schema files** — works without DB connection (CI environments, no local DB)
|
|
106
107
|
- **Force-directed layout** — handles unknown schemas gracefully without pre-defined positions
|
|
107
108
|
- **Node layout categories** — three-way partition in `app.js`: connected nodes use force simulation, self-ref-only models (all edges point to themselves) are placed in a vertical left column via `layoutSelfRefNodes()`, true orphans (zero edges) are placed in rows above the diagram via `layoutOrphans()`
|
|
109
|
+
- **Edge deduplication** — `GraphBuilder.deduplicate_edges` chains two passes: (1) HABTM dedup merges symmetric `has_and_belongs_to_many` pairs into one edge with `reverse_label`, (2) has_many/belongs_to dedup merges matching pairs (same foreign_key, reversed endpoints) into one edge where the has_many/has_one side is kept and the belongs_to label becomes `reverse_label` with its own `reverse_association_type`. The frontend uses `reverse_association_type` to color each label by its own association type.
|
data/README.md
CHANGED
|
@@ -61,6 +61,7 @@ Rails::Schema.configure do |config|
|
|
|
61
61
|
"ActiveStorage::Attachment",
|
|
62
62
|
"ActionMailbox::*" # wildcard prefix matching
|
|
63
63
|
]
|
|
64
|
+
config.exclude_model_if = ->(model) { model.table_name.start_with?("_") }
|
|
64
65
|
end
|
|
65
66
|
```
|
|
66
67
|
|
|
@@ -72,6 +73,7 @@ end
|
|
|
72
73
|
| `expand_columns` | `false` | Whether model nodes start with columns expanded |
|
|
73
74
|
| `schema_format` | `:auto` | Schema source — `:auto`, `:ruby`, `:sql`, or `:mongoid` (see below) |
|
|
74
75
|
| `exclude_models` | `[]` | Models to hide; supports exact names and wildcard prefixes (`"ActionMailbox::*"`) |
|
|
76
|
+
| `exclude_model_if` | `nil` | A proc/lambda that receives a model class and returns `true` to exclude it |
|
|
75
77
|
|
|
76
78
|
### Schema format
|
|
77
79
|
|
|
@@ -108,12 +110,17 @@ For Mongoid apps, the gem introspects model classes at runtime to read field def
|
|
|
108
110
|
|
|
109
111
|
- **No database required** — reads from `db/schema.rb`, `db/structure.sql`, or Mongoid model introspection
|
|
110
112
|
- **Force-directed layout** — models cluster naturally by association density; self-referential-only models are placed in a left column, true orphans in rows above
|
|
111
|
-
- **Searchable sidebar** — filter models by name or table
|
|
113
|
+
- **Searchable sidebar** — filter models by name or table, with a clear button to reset
|
|
114
|
+
- **Select/Deselect All** — operates on filtered (visible) models only, so you can search and bulk-toggle a subset; when all models are selected and a search filter is active, "Select All" narrows the selection to only the filtered models
|
|
115
|
+
- **Shift-click range selection** — hold Shift and click checkboxes to toggle a range at once
|
|
112
116
|
- **Click-to-focus** — click a model to highlight its neighborhood, fading unrelated models
|
|
117
|
+
- **Double-click to isolate** — double-click a model to filter the view to only that model and its direct neighbors
|
|
113
118
|
- **Detail panel** — full column list and associations for the selected model
|
|
114
119
|
- **Dark/light theme** — toggle or auto-detect from system preference
|
|
115
120
|
- **Zoom & pan** — scroll wheel, pinch, or buttons
|
|
116
121
|
- **Keyboard shortcuts** — `/` search, `Esc` deselect, `+/-` zoom, `F` fit to screen
|
|
122
|
+
- **Export to Mermaid** — download the diagram as a `.mmd` file for use in Markdown, GitHub, or other tools that render Mermaid ER diagrams; respects sidebar visibility filters so you can export a subset of models
|
|
123
|
+
- **Deduplicated edges** — reciprocal associations (e.g. `has_many :posts` / `belongs_to :user`, or symmetric HABTM) are merged into a single edge with dual labels, each colored by its own association type
|
|
117
124
|
- **Self-contained** — single HTML file with all CSS, JS, and data inlined
|
|
118
125
|
|
|
119
126
|
## License
|