class Generators::Avo::ToolGenerator
def controller_name
def controller_name file_name.to_s end
def file_name
def file_name name.to_s.underscore end
def handle
def handle # Sidebar items template "tool/sidebar_item.tt", "app/views/avo/sidebar/items/_#{file_name}.html.erb" # Add controller if it doesn't exist controller_path = "app/controllers/avo/tools_controller.rb" unless File.file?(Rails.root.join(controller_path)) template "tool/controller.tt", controller_path end # Add controller method inject_into_class controller_path, "Avo::ToolsController" do <<-METHOD #{file_name} age_title = "#{human_name}" d_breadcrumb "#{human_name}" METHOD end # Add view file template "tool/view.tt", "app/views/avo/tools/#{file_name}.html.erb" if ::Avo.configuration.root_path == "" route <<-ROUTE "#{file_name}", to: "avo/tools##{file_name}" ROUTE else route <<-ROUTE :#{::Avo.configuration.namespace} do "#{file_name}", to: "avo/tools##{file_name}" ROUTE end end
def human_name
def human_name file_name.humanize end
def in_code(text)
def in_code(text) "<code class='p-1 rounded bg-gray-500 text-white text-sm'>#{text}</code>" end