Sha256: e15097454b84a33a3320ee15f0a2fdbc53a47bf1f190077c26b436ae0707eec4

Contents?: true

Size: 796 Bytes

Versions: 11

Compression:

Stored size: 796 Bytes

Contents

module Scrivito
  module Generators
    class WidgetGenerator < ::Rails::Generators::NamedBase
      source_root File.expand_path('../templates', __FILE__)

      def create_model
        template 'model.erb', "app/models/#{file_name}.rb"
      end

      def create_views
        template 'show.html.erb', "app/views/#{file_name}/show.html.erb"
        template 'details.html.erb', "app/views/#{file_name}/details.html.erb"
        template 'thumbnail.html.erb', "app/views/#{file_name}/thumbnail.html.erb"
      end

      def file_name
        super.ends_with?('_widget') ? super : "#{super}_widget"
      end

      def class_name
        super.ends_with?('Widget') ? super : "#{super}Widget"
      end

      def human_name
        class_name.underscore.humanize
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
scrivito_sdk-0.66.0 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.66.0.rc2 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.65.2 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.66.0.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.65.1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.65.0 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.65.0.rc2 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.65.0.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.60.0 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.60.0.rc2 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-0.60.0.rc1 lib/generators/scrivito/widget/widget_generator.rb