Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::CsvBuild::Builder
- Inherits:
-
Object
- Object
- Eco::API::UseCases::GraphQL::Samples::Pages::Template::CsvBuild::Builder
- Defined in:
- lib/eco/api/usecases/graphql/samples/pages/template/csv_build/builder.rb
Overview
CSV → template BUILD pipeline.
Ties the pieces together: a Parser turns a columnar CSV into a stage/section/field tree, this
Builder replays that tree onto the EXISTING Template::CommandEmitter (reused verbatim — same
placeholder-id threading the create path already relies on), and then hands the resulting ordered
WorkflowCommand batch to the released gem's Builder::Template#create(commands:).
Offline / dry-run by DEFAULT — real creation needs credentials, so build only assembles and
returns the command batch; create! is the explicit live path (requires a gem Builder::Template
or GraphQL#template facade).
builder = CsvBuild::Builder.from_csv(csv_string) commands = builder.commands # ordered { commandKey => kwargs } batch, offline # live (needs creds): builder.create!(graphql.template) # => gem create mutation response
SECTION / FIELD IDENTITY: each field's description (from FormatMap) is passed to the emitter's
field(description:), and a hidden anchor per section carries the section identity — so a rebuilt
template stays pair-able against a prior version by the diff engine. When the field type is
select, the parsed options are emitted as addSelectFieldOption commands.
⚠ HONEST LIMITATION: the RELEASED gem's addField input drops any key outside
placeholderId/fieldType/label/stageId/sectionId/column (see CommandEmitter#field note). So today
the description identity token is NOT persisted through addField — the hidden ANCHOR FIELD's
presence (its label) is the only identity signal that currently survives to the batch. The
description wiring is in place so identity flows end-to-end the moment the gem's addField input
gains a description key. Until then, section/field identity relies on the anchor + heading/label.
Constant Summary collapse
- SECTION_ANCHOR_TYPE =
Hidden marker field type used to anchor SECTION identity across rebuilds (identity convention: hidden-field + description). Kept as a constant so it is trivial to retune when the real format / platform convention for the anchor is confirmed.
'hidden'.freeze
- SECTION_ANCHOR_LABEL =
'__section_id'.freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#commands ⇒ Object
The ordered command batch — PURE, no client needed.
-
#create!(template_facade, &block) ⇒ Object
LIVE build (needs creds).
-
#initialize(parser, section_anchors: true) ⇒ Builder
constructor
A new instance of Builder.
-
#preview ⇒ Object
Human preview of the batch (for a dry-run / simulate log).
Constructor Details
#initialize(parser, section_anchors: true) ⇒ Builder
Returns a new instance of Builder.
48 49 50 51 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/builder.rb', line 48 def initialize(parser, section_anchors: true) @parser = parser @section_anchors = section_anchors end |
Class Method Details
Instance Method Details
#commands ⇒ Object
The ordered command batch — PURE, no client needed. This is what specs assert against.
54 55 56 57 58 59 60 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/builder.rb', line 54 def commands @commands ||= begin emitter = CommandEmitter.new emit_tree(emitter) emitter.commands end end |
#create!(template_facade, &block) ⇒ Object
LIVE build (needs creds). template_facade is the gem Builder::Template (a.k.a.
graphql.template) exposing create(commands:).
64 65 66 67 68 69 70 71 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/builder.rb', line 64 def create!(template_facade, &block) unless template_facade.respond_to?(:create) raise ArgumentError, 'template facade must respond to #create(commands:)' end template_facade.create(commands: commands, &block) end |
#preview ⇒ Object
Human preview of the batch (for a dry-run / simulate log).
74 75 76 77 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/builder.rb', line 74 def preview ["CSV build — #{commands.size} workflow command(s):", *commands.map { |c| " * #{c.keys.first}: #{c.values.first.inspect}" }].join("\n") end |