module

Altair::CLI::Generators::Base

Shared filesystem and naming helpers for generators.

Constants

VALID_TYPES = [:string, :text, :integer, :bigint, :float, :decimal, :boolean, :datetime, :json] of ::Symbol

The column types a generator argument accepts, mapped to the schema t.<type> method.

Instance methods

announce(path : Path) : Path

Echoes the file that was written to and returns it.

Source
classify(name : String) : String

Converts a model name to its camelized class form (BlogPost). Already-camelized names pass through untouched — capitalize would otherwise lowercase the tail (BlogPostBlogpost).

Source
parse_columns(args : Array(String)) : Array(Column)

Parses ["title:string", "body:text"] into columns. A name without a type defaults to :string. Raises on an unknown type.

Source
resource_path(table : String) : String

The shared URL prefix for a table's resources, e.g. blog_posts.

Source
singular(name : String) : String

Converts a model name to its singular attribute name (blog_post).

Source
tableize(name : String) : String

Converts a model name to its plural table name (blog_posts).

Source
write_file(path : Path, content : String) : Path

Writes content to path, creating parent directories. Echoes the created path. Returns the path.

Source