@suss/adapter-ruby 0.4.0 → 0.5.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.
package/README.md CHANGED
@@ -98,6 +98,60 @@ through `const_set` or `Object.const_get`, which nothing here reads.
98
98
  The definitions are collected per file and matched afterwards, since which
99
99
  file defines a constant is only settled once every file has been read.
100
100
 
101
+ ## What a class inherits
102
+
103
+ A class says which class it extends, twice. `extends` points at whatever the
104
+ superclass name binds to, so the shared rules find a method a base class
105
+ declares on a subclass that never overrode it. `extendsNamed` keeps the name
106
+ as written, because a base class the project does not declare, like
107
+ `ActiveRecord::Base`, has no node in the run to point at:
108
+
109
+ ```ruby
110
+ class Order < ApplicationRecord
111
+ end
112
+ ```
113
+
114
+ ```
115
+ extends order.rb:0-31 order.rb#ApplicationRecord
116
+ extendsNamed order.rb:0-31 ApplicationRecord
117
+ ```
118
+
119
+ A pack matching a library base class reads the second one, and follows the
120
+ first to keep going up.
121
+
122
+ ## What a body does with the database
123
+
124
+ Ruby writes no return type, so the Python adapter's trick of reading what a
125
+ method says it gives back has no counterpart here. A pack says which base
126
+ class the library gives a model instead:
127
+
128
+ ```ts
129
+ storage: [
130
+ {
131
+ baseClasses: ["ActiveRecord::Base"],
132
+ writes: ["update", "destroy", "save", "create", "delete_all"],
133
+ storageSystem: "postgres",
134
+ },
135
+ ]
136
+ ```
137
+
138
+ A call matches when the constant its receivers start at reaches one of those
139
+ base classes. Rails puts its own class in between, and following `extends`
140
+ through the project and matching `extendsNamed` at the library takes care of
141
+ that:
142
+
143
+ ```ruby
144
+ class ApplicationRecord < ActiveRecord::Base; end
145
+ class Order < ApplicationRecord; end
146
+
147
+ Order.where(id: 1).first # one read, against Order, picking rows by id
148
+ ```
149
+
150
+ A chain is one thing the code does, so that counts once. The method the chain
151
+ ends with tells a read from a write, and the keywords along it become the
152
+ selector. `fields` comes back empty, and a call on anything that is not a
153
+ constant says nothing, since there is no class to ask about.
154
+
101
155
  ## Where it fits in suss
102
156
 
103
157
  Depends on `@suss/extractor` (for `RawCodeStructure` / `assembleSummary`), `@suss/behavioral-ir`, `@suss/datalog` (for the fact database), and `web-tree-sitter`. Framework packs under `packages/framework/*` (starting with `@suss/framework-graphql-ruby`) consume its `RubyPack` contract; nothing in this package knows what any particular library's classes or DSL calls are named beyond graphql-ruby's own `field` / `argument` / `type` verbs, which the discovery logic reads structurally rather than through pack configuration.