Module: Textus::Protocol::Handlers::Read
- Includes:
- Concern
- Defined in:
- lib/textus/protocol/handlers/read.rb
Class Method Summary collapse
- .deps(key:, ctx:, call:) ⇒ Object
- .get(key:, ctx:, call:) ⇒ Object
- .graph(key:, ctx:, call:, depth: nil) ⇒ Object
- .list(ctx:, call:, prefix: nil, lane: nil, q: nil, schema: nil) ⇒ Object
- .rdeps(key:, ctx:, call:) ⇒ Object
- .schema_show(key:, ctx:, call:) ⇒ Object
- .uid(key:, ctx:, call:) ⇒ Object
- .where(key:, ctx:, call:) ⇒ Object
Methods included from Concern
Class Method Details
.deps(key:, ctx:, call:) ⇒ Object
35 36 37 38 39 |
# File 'lib/textus/protocol/handlers/read.rb', line 35 def deps(key:, ctx:, call:) entry = ctx.manifest.data.entries.find { |e| e.key == key } deps_list = entry&.external? ? Array(entry.source&.sources).compact : [] { "key" => key, "deps" => deps_list.uniq } end |
.get(key:, ctx:, call:) ⇒ Object
9 10 11 12 13 14 15 16 17 |
# File 'lib/textus/protocol/handlers/read.rb', line 9 def get(key:, ctx:, call:) env = ctx.read(key:) unless env suggestions = ctx.manifest.resolver.suggestions_for(key) raise Textus::UnknownKey.new(key, suggestions:) end Ops::SourceExpander.new.call(env, ctx:, depth: 0).to_h_for_wire end |
.graph(key:, ctx:, call:, depth: nil) ⇒ Object
52 53 54 55 56 57 |
# File 'lib/textus/protocol/handlers/read.rb', line 52 def graph(key:, ctx:, call:, depth: nil) from = ctx.link_store.links_from(key) to = ctx.link_store.links_to(key) { "key" => key, "neighbors" => (from + to).uniq.sort, "reachable" => ctx.link_store.reachable(from: key, depth:).sort } end |
.list(ctx:, call:, prefix: nil, lane: nil, q: nil, schema: nil) ⇒ Object
19 20 21 |
# File 'lib/textus/protocol/handlers/read.rb', line 19 def list(ctx:, call:, prefix: nil, lane: nil, q: nil, schema: nil) ctx.list(prefix:, lane:, q:, schema:) end |
.rdeps(key:, ctx:, call:) ⇒ Object
41 42 43 44 45 46 47 48 49 50 |
# File 'lib/textus/protocol/handlers/read.rb', line 41 def rdeps(key:, ctx:, call:) source_rdeps = ctx.manifest.data.entries.each_with_object([]) do |entry, acc| next unless entry.external? sources = Array(entry.source&.sources).compact acc << entry.key if sources.any? { |s| s == key || key.start_with?("#{s}.") } end link_rdeps = ctx.link_store.links_to(key) { "key" => key, "rdeps" => (source_rdeps + link_rdeps).uniq.sort } end |
.schema_show(key:, ctx:, call:) ⇒ Object
59 60 61 62 63 |
# File 'lib/textus/protocol/handlers/read.rb', line 59 def schema_show(key:, ctx:, call:) mentry = ctx.mentry_for(key:) schema = ctx.schemas.fetch_or_nil(mentry.schema) response(key:, schema_ref: mentry.schema, schema: schema&.to_h) end |
.uid(key:, ctx:, call:) ⇒ Object
28 29 30 31 32 33 |
# File 'lib/textus/protocol/handlers/read.rb', line 28 def uid(key:, ctx:, call:) env = ctx.read(key:) raise Textus::UnknownKey.new(key) unless env env.uid end |
.where(key:, ctx:, call:) ⇒ Object
23 24 25 26 |
# File 'lib/textus/protocol/handlers/read.rb', line 23 def where(key:, ctx:, call:) res = ctx.resolve(key:) response(key:, lane: res.entry.lane, path: res.path) end |