Class: Eco::API::UseCases::GraphQL::Samples::Pages::Template::CsvBuild::Parser
- Inherits:
-
Object
- Object
- Eco::API::UseCases::GraphQL::Samples::Pages::Template::CsvBuild::Parser
- Defined in:
- lib/eco/api/usecases/graphql/samples/pages/template/csv_build/parser.rb
Overview
Parse a columnar CSV describing ONE template into an ordered, grouped intermediate structure
(stages → sections → fields) that the Builder turns into a WorkflowCommand batch.
Format specifics live ENTIRELY in FormatMap (see its TODO about the ~mid-July format). The
parser only groups RowSpecs by their declared hierarchy while PRESERVING first-seen order, so
the emitted command batch is deterministic and dependency-safe.
parser = Parser.new(csv_string) # or Parser.from_file(path) tree = parser.tree tree # => [ { name:, ordering:, sections: [ { heading:, layout:, ordering:, fields: [...] } ] } ]
Defined Under Namespace
Classes: Field
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(source) ⇒ Parser
constructor
A new instance of Parser.
-
#row_specs ⇒ Object
Flat list of RowSpecs (post FormatMap mapping), skipping blank / header-only rows.
-
#tree ⇒ Object
The grouped hierarchy: stages (first-seen order) → sections → fields.
Constructor Details
#initialize(source) ⇒ Parser
Returns a new instance of Parser.
24 25 26 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/parser.rb', line 24 def initialize(source) @source = source.to_s end |
Class Method Details
.from_file(path) ⇒ Object
19 20 21 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/parser.rb', line 19 def self.from_file(path) new(File.read(path)) end |
Instance Method Details
#row_specs ⇒ Object
Flat list of RowSpecs (post FormatMap mapping), skipping blank / header-only rows.
34 35 36 37 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/parser.rb', line 34 def row_specs @row_specs ||= rows.map { |row| FormatMap.row_spec(row) }. reject { |rs| rs.stage.nil? && rs.field_label.nil? } end |
#tree ⇒ Object
The grouped hierarchy: stages (first-seen order) → sections → fields.
29 30 31 |
# File 'lib/eco/api/usecases/graphql/samples/pages/template/csv_build/parser.rb', line 29 def tree @tree ||= build_tree end |