Class: Generators::Avo::EjectGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Defined in:
lib/generators/avo/eject_generator.rb

Constant Summary collapse

TEMPLATES =
{
  sidebar: "app/views/avo/sidebar/_sidebar.html.erb",
  logo: "app/views/avo/partials/_logo.html.erb",
  head: "app/views/avo/partials/_head.html.erb",
  header: "app/views/avo/partials/_header.html.erb",
  profile_dropdown: "app/views/avo/partials/_profile_dropdown.html.erb",
  footer: "app/views/avo/partials/_footer.html.erb",
  scripts: "app/views/avo/partials/_scripts.html.erb"
}

Instance Method Summary collapse

Instance Method Details

#handleObject



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
# File 'lib/generators/avo/eject_generator.rb', line 23

def handle
  if @filename.starts_with?(":")
    template_id = path_to_sym @filename
    template_path = TEMPLATES[template_id]

    if path_exists? template_path
      eject template_path
    else
      say("Failed to find the `#{template_id.to_sym}` template.", :yellow)
    end
  elsif path_exists? @filename
    eject @filename
  else
    say("Failed to find the `#{@filename}` template.", :yellow)
  end
end