module Scrivito module Generators class WidgetGenerator < ::Rails::Generators::NamedBase include ::Rails::Generators::Migration source_root File.expand_path('../templates', __FILE__) def self.next_migration_number(dirname) max = current_migration_number(dirname) Scrivito::Migration.next_migration_number(max) end def generate_model template('model.erb', "app/models/#{file_name}.rb") end def generate_views path = "app/views/#{file_name}" template('show.html.erb', "#{path}/show.html.erb") template('details.html.erb', "#{path}/details.html.erb") template('thumbnail.html.erb', "#{path}/thumbnail.html.erb") end def generate_migration base_path = Scrivito::Configuration.migration_path migration_template('migration.erb', File.join(base_path, "/create_#{file_name}.rb")) end end end end