Sha256: 7be43103cc9b05fd2499f6b031ef91da5c087c3f08c7c4b52c857b4f031a77dc

Contents?: true

Size: 857 Bytes

Versions: 80

Compression:

Stored size: 857 Bytes

Contents

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

      argument :name, type: :string
      argument :attributes, type: :array, default: [], banner: 'attribute:type attribute:type'

      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
    end
  end
end

Version data entries

80 entries across 80 versions & 1 rubygems

Version Path
scrivito_sdk-1.5.5 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.1.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.5.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.4.3 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.4 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.7.0.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.0 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.0.rc5 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.4.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.0.rc4 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.0.rc3 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.3 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.0.rc2 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.3.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.6.0.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.2 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.2.rc1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.1 lib/generators/scrivito/widget/widget_generator.rb
scrivito_sdk-1.5.1.rc2 lib/generators/scrivito/widget/widget_generator.rb