Class: Strata::CLI::Generators::Table
- Defined in:
- lib/strata/cli/generators/table.rb
Overview
Generates a semantic table model YAML file from field definitions.
Constant Summary
Constants included from Output
Instance Method Summary collapse
Methods inherited from Group
Methods included from Output
format, pastel, print_error, #print_error, print_hint, #print_hint, print_info, #print_info, print_status, #print_status, print_success, #print_success, print_warning, #print_warning, shell_for, thor_color
Instance Method Details
#create_model_file ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/strata/cli/generators/table.rb', line 21 def create_model_file # Build output path: models/<path>/tbl.<table_name>.yml # e.g., "sales/customer" -> "models/sales/tbl.customer.yml" # Filenames are standardized to lowercase path_parts = path.split("/") table_name = path_parts.last.downcase if path_parts.length > 1 # Has subdirectory: models/sales/tbl.customer.yml subdir = path_parts[0..-2].join("/") output_path = "models/#{subdir}/tbl.#{table_name}.yml" else # No subdirectory: models/tbl.customer.yml output_path = "models/tbl.#{table_name}.yml" end # Ensure directory exists empty_directory File.dirname(output_path) # Load template and update with user inputs template_content = load_template updated_content = update_template(template_content) # Write the updated template create_file output_path, updated_content Output.print_status(:created, output_path, type: :success, context: self) end |