class Ella::ViewGenerator

Generates views for Ella projects.

Public Instance Methods

run() click to toggle source
# File lib/ella/generator/view_generator.rb, line 6
def run
  Ella.find_root
  make_directory
  @path = "views/#{target_name}#{target_name ? '/' : ''}"
  create_subdirectory if target_name && !Dir.exist?(@path)
  create_files
  copy_templates
end

Private Instance Methods

copy_template(filename) click to toggle source
# File lib/ella/generator/view_generator.rb, line 25
def copy_template(filename)
  Ella::Template.new(full_filename(filename), template_vars: @template_vars).write
end
copy_templates() click to toggle source
# File lib/ella/generator/view_generator.rb, line 29
def copy_templates
  @templates.each { |filename| copy_template(filename) } if @templates
end
create_file(filename) click to toggle source
# File lib/ella/generator/view_generator.rb, line 21
def create_file(filename)
  Ella::Template.new(full_filename(filename), generic_template: :blank).write
end
create_files() click to toggle source
# File lib/ella/generator/view_generator.rb, line 33
def create_files
  @files.each { |filename| create_file(filename) } if @files
end
create_subdirectory() click to toggle source
# File lib/ella/generator/view_generator.rb, line 37
def create_subdirectory
  Log.create(@path)
  Dir.mkdir(@path)
end
full_filename(filename) click to toggle source
# File lib/ella/generator/view_generator.rb, line 17
def full_filename(filename)
  "#{@path}#{filename}.erb"
end