Module: Charming::Generators::AppGenerator::ViewTemplate
- Included in:
- Charming::Generators::AppGenerator
- Defined in:
- lib/charming/generators/app_generator/view_template.rb
Instance Method Summary collapse
- #application ⇒ Object
- #database_require ⇒ Object
- #executable ⇒ Object
- #model_loader ⇒ Object
- #root_file ⇒ Object
- #version ⇒ Object
- #view ⇒ Object
Instance Method Details
#application ⇒ Object
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 42 def application %(# frozen_string_literal: true module #{name.class_name} class Application < Charming::Application root File.expand_path("../..", __dir__) Charming::Presentation::UI::Theme.built_in_names.each do |theme_name| theme theme_name.to_sym, built_in: theme_name end default_theme :phosphor end end ) end |
#database_require ⇒ Object
73 74 75 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 73 def database_require database? ? %(require_relative "../config/database") : "" end |
#executable ⇒ Object
7 8 9 10 11 12 13 14 15 16 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 7 def executable %(#!/usr/bin/env ruby # frozen_string_literal: true require "bundler/setup" require "#{name.snake_name}" Charming.run(#{name.class_name}::Application.new) ) end |
#model_loader ⇒ Object
77 78 79 80 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 77 def model_loader database? ? %(loader.push_dir(File.expand_path("../app/models", __dir__), namespace: #{name.class_name}) ) : "" end |
#root_file ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 18 def root_file %(# frozen_string_literal: true require "charming" require "zeitwerk" #{database_require} module #{name.class_name} end loader = Zeitwerk::Loader.new loader.tag = "#{name.snake_name}" loader.inflector.inflect("version" => "VERSION") loader.push_dir(File.expand_path("#{name.snake_name}", __dir__), namespace: #{name.class_name}) #{model_loader}loader.push_dir(File.expand_path("../app/state", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/components", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/views", __dir__), namespace: #{name.class_name}) loader.push_dir(File.expand_path("../app/controllers", __dir__), namespace: #{name.class_name}) loader.setup require_relative "../config/routes" ) end |
#version ⇒ Object
59 60 61 62 63 64 65 66 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 59 def version %(# frozen_string_literal: true module #{name.class_name} VERSION = "0.1.0" end ) end |
#view ⇒ Object
68 69 70 71 |
# File 'lib/charming/generators/app_generator/view_template.rb', line 68 def view %(<%= render_component AppFrameComponent.new(title: home.title, theme: theme) %> ) end |