doido_generators/generators/
mod.rs1pub mod bootstrap_migrations;
2pub mod channel;
3pub mod controller;
4pub mod field;
5pub mod generator_gen;
6pub mod helper;
7pub mod job;
8pub mod locale;
9pub mod mailer;
10pub mod migration;
11pub mod migration_support;
12pub mod model;
13pub mod new;
14pub mod resource;
15pub mod scaffold;
16pub mod storage_adapter;
17pub mod storage_install;
18pub mod templates_gen;
19
20use doido_core::Inflector;
21
22pub fn to_snake(s: &str) -> String {
24 Inflector::underscore(s)
25}
26
27pub(crate) fn register_module(existing: &str, module: &str, marker: &str) -> String {
31 let decl = format!("pub mod {module};");
32 if existing.lines().any(|l| l.trim() == decl) {
33 return existing.to_string();
34 }
35 let mut lines: Vec<String> = existing.lines().map(String::from).collect();
36 match lines.iter().position(|l| l.contains(marker)) {
37 Some(i) => lines.insert(i, decl),
38 None => lines.push(decl),
39 }
40 let mut out = lines.join("\n");
41 out.push('\n');
42 out
43}
44
45pub fn to_pascal(s: &str) -> String {
47 Inflector::camelize(&Inflector::underscore(s))
50}
51
52pub fn to_table_name(s: &str) -> String {
55 Inflector::tableize(s)
56}