Repository navigation
Commit b08041b
committed
feat: add ogar-from-ruff + ogar-from-rails — producer-side bridge for the Rails ecosystem
The OGAR vocab was deliberately shaped to mirror ruff_ruby_spo's
C17a–c stable IR (per ogar-vocab/src/lib.rs:14: "the existing
producer can be lifted in-place"), but the lifter itself didn't
exist — OGAR had ogar-from-elixir for HIRO/Bardioc but no
ruff/Rails equivalent. This PR adds the pair.
**ogar-from-ruff** (lower-level): pure projection from
ruff_spo_triplet::Model → ogar_vocab::Class. No I/O. The IR
shapes already align field-for-field, so this is mostly
mechanical:
name → name
sti.inherits_from → parent
associations → associations (with rich option parsing:
class_name / foreign_key / polymorphic /
through / source / as / dependent / etc.
AcceptsNestedAttributesFor skipped — it's a
UI form helper, not a relation)
validations → validations (Normalizes skipped — write-time
transform, not a constraint)
callbacks → callbacks (phase → event)
concerns → mixins (block markers skipped)
acts_as → mixins (as `acts_as_<variant>` prefix)
attributes → attributes (alias/undef/store_accessor
filtered; the `"type"` option lifts to
Attribute.type_name)
scopes → scopes / default_scope (split by kind)
Long-tail ruff slots (delegations / dsl_calls / gem_dsl /
dynamic_methods / refinements) pass through unfiltered today —
OGAR doesn't model them at the Class level; can land as
ogar-extensions/rails/* later.
`strip_ruby_literal_markers` normalises the verbatim option
values walk::format_hash_inline produces — strings get
unquoted (`"User"` → `User`), symbols lose the leading colon
(`:destroy` → `destroy`), bare consts pass through.
**ogar-from-rails** (high-level wrapper): walks a Rails source
tree via ruff_ruby_spo::extract, then runs each Model through
ogar-from-ruff. Output is Vec<Class>, registry-ready (handing
off to lance-graph-ontology::OntologyRegistry is a separate
follow-up — this crate's surface ends at Class).
extract(&Path) → Vec<Class>
Mirrors the role ogar-from-elixir plays for HIRO. ogar-from-elixir
is added to workspace members in the same PR (pre-existing
oversight — it lived in crates/ but wasn't built).
**Smoke-tested on live OpenProject**: 694 Class values from
/home/user/openproject, matching ruff_ruby_spo::extract's count
1:1. WorkPackage shows up with its associations / mixins /
callbacks lifted correctly.
Tests: 9 unit tests in ogar-from-ruff (field-by-field), 1
default + 1 ignored real-corpus smoke in ogar-from-rails.1 parent 3016c78 commit b08041b
5 files changed
Lines changed: 620 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
13 | 16 | | |
14 | 17 | | |
15 | 18 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
0 commit comments