Module: CleoDesignTokens::LookupBuilder
- Defined in:
- lib/cleo_design_tokens/lookup_builder.rb
Overview
Flattens token trees into frozen key -> value lookups, using TreeWalker. Exposed as module functions, rather than baked into module load, so the collision case is testable against fixtures.
Class Method Summary collapse
-
.build_lookup(tree) ⇒ Object
Flattens one tree of plain (theme-free) leaves — e.g.
-
.build_semantic_lookup(tree) ⇒ Object
Flattens
semantic.jsoninto a key -> SemanticEntry lookup, one entry per role — the theme axis lives inside the entry, not in the key.
Class Method Details
.build_lookup(tree) ⇒ Object
Flattens one tree of plain (theme-free) leaves — e.g. the parsed
primitives.json — into a key -> hex lookup.
12 13 14 |
# File 'lib/cleo_design_tokens/lookup_builder.rb', line 12 def self.build_lookup(tree) flatten_tree(tree) { |leaf| leaf["$value"].freeze } end |
.build_semantic_lookup(tree) ⇒ Object
Flattens semantic.json into a key -> SemanticEntry lookup, one entry
per role — the theme axis lives inside the entry, not in the key.
18 19 20 |
# File 'lib/cleo_design_tokens/lookup_builder.rb', line 18 def self.build_semantic_lookup(tree) flatten_tree(tree) { |leaf| semantic_entry(leaf) } end |