Sha256: 3b2aaaa744d87112117008de4db2ac1f946fbaf399f3d5713c27dc400423769a

Contents?: true

Size: 913 Bytes

Versions: 1

Compression:

Stored size: 913 Bytes

Contents

class MiuControllerGenerator < Rails::Generators::Base
  source_root File.expand_path("../templates", __FILE__)

  desc "This generator creates the mark it up controller, view and route"

  def create_miucontroller
    copy_file 'app/controllers/mark_it_up_controller.rb', 'app/controllers/mark_it_up_controller.rb'
    copy_file 'app/views/mark_it_up/preview.html.erb', 'app/views/mark_it_up/preview.html.erb'
    add_route
    copy_assets
  end

  private
  def add_route
    preview_route = %{match "mark_it_up/preview" => "mark_it_up#preview"}
    route(preview_route)
  end

  def copy_assets
    src = File.expand_path("../../public/mark_it_up", __FILE__)
    dest = "#{Rails.root}/public/mark_it_up"
    puts "* Copying assets to #{dest}"
    FileUtils.cp_r(src, dest)
    puts "* Run 'script/generate miu_controller' to generate MarkItUpController and to be able to use default preview parser"
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
mark_it_up-0.0.2 lib/generators/miu_controller_generator.rb