Module: Suma::SchemaNaming
- Defined in:
- lib/suma/schema_naming.rb
Overview
Converts EXPRESS schema identifiers into human-readable display names.
Naming is model-driven: the schema type (resource/module) and suffix determine how the identifier is formatted. Acronyms and numeric prefixes are preserved to match ISO 10303 conventions.
Constant Summary collapse
- ACRONYMS =
Acronyms preserved as uppercase during title-casing. Source: ISO 10303 naming conventions.
%w[ aic aec apu bom csg edraw id ifc pdf pld xml xpdl 2d 3d ].freeze
- LOWERCASE_WORDS =
Lowercase function words (ISO title-case convention).
%w[a an and as for in of on or the to].freeze
- SUFFIXES =
Suffixes stripped from the schema name before title-casing, mapped to the parenthesised label appended to the display name. A
nillabel means the suffix is stripped silently. { "_arm" => "ARM", "_mim" => "MIM", "_bom" => "BOM", "_schema" => nil, }.freeze
Class Method Summary collapse
-
.category_prefix(type) ⇒ String
Determine the category prefix for a schema type.
-
.display_name(schema_id) ⇒ String
Produce a human-readable display name from a schema identifier.
-
.prefixed_name(schema_id, path: nil) ⇒ String
Produce a prefixed display name with the schema category.
Class Method Details
.category_prefix(type) ⇒ String
Determine the category prefix for a schema type.
64 65 66 |
# File 'lib/suma/schema_naming.rb', line 64 def category_prefix(type) SchemaCategory.for_type(type).prefix end |
.display_name(schema_id) ⇒ String
Produce a human-readable display name from a schema identifier.
43 44 45 46 47 |
# File 'lib/suma/schema_naming.rb', line 43 def display_name(schema_id) base, label = decompose(schema_id) title_cased = title_case(base) label ? "#{title_cased} (#{label})" : title_cased end |
.prefixed_name(schema_id, path: nil) ⇒ String
Produce a prefixed display name with the schema category.
54 55 56 57 58 |
# File 'lib/suma/schema_naming.rb', line 54 def prefixed_name(schema_id, path: nil) type = ExpressSchema::Type.classify(id: schema_id, path: path) prefix = category_prefix(type) "#{prefix}: #{display_name(schema_id)}" end |