Application & Configuration
Charming::Application is the root object of every Charming app: it owns the routes, the logger, the registered themes, and the persistent session. You subclass it once, configure it with the class-level DSL below, and hand an instance to Charming.run to start the app. Everything else — controllers, views, components — hangs off this object at runtime.
Charming::Application
Inherit from Charming::Application:
class MyApp::Application < Charming::Application
root File.expand_path("../..", __dir__)
end
Generated apps define routes separately in config/routes.rb:
MyApp::Application.routes do
root "home#show"
end
Routes can also be defined inline on the application class:
class MyApp::Application < Charming::Application
root File.expand_path("../..", __dir__)
routes do
root "home#show"
end
end
Class APIs
Routing and structure — where the app lives and how screens are reached:
routes { ... }defines routes with the router DSL.root pathsets the application root path used for resolving relative files and templates.namespacereturns the application namespace used for controller and template binding lookup.
Logging:
logger valuesets the application logger. The default logger writes toFile::NULL.
Themes — register and pick the app’s look (tokens are covered in UI & Themes):
theme name, built_in: "phosphor"registers a built-in JSON theme (phosphor,catppuccin-mocha,catppuccin-latte,gruvbox-dark,nord,tokyonight).theme name, from: "config/themes/custom.json"registers an app-local theme file.theme name, extends: :parent, overrides: {token => spec}derives a theme from a registered one.default_theme namesets the default theme.theme_for nameresolves a theme object.
Session and input behavior:
persist_session to: "tmp/session.json"opts into JSON session persistence across restarts (framework-internal keys and non-JSON-safe values are excluded).coalesce_input truecollapses held-key auto-repeat bursts into one dispatch (off by default).mouse_motion :allenables buttonless hover reporting (:drag, the default, reports motion only while a button is held).
Instance APIs
routesreturns the app router.loggerreturns the application logger.logger=overrides the logger for this application instance.sessionreturns persistent app session state.save_sessionwrites the session to the configured path (the runtime calls this on exit).themereturns the active theme.use_theme nameswitches the active theme.
Environment
Charming.envreturns the current environment as a string inquirer (fromCHARMING_ENV, default"development"):Charming.env.test?,Charming.env.production?.
Entrypoint
Start the runtime by handing it an application instance:
Charming.run(MyApp::Application.new)