Sha256: f0d92625fa95d372e0194fed3e60c17793fa43137e93139891778cf5a7619745

Contents?: true

Size: 1.93 KB

Versions: 9

Compression:

Stored size: 1.93 KB

Contents

class ViewModelsGenerator < Rails::Generator::NamedBase
  def manifest
    record do |m|
      
      # Check for class naming collisions.
      #
      m.class_collisions "ViewModels::#{class_name}"
      
      # ViewModels
      #
      m.directory 'app/view_models'
      m.template "view_models/view_model.rb", "app/view_models/#{file_name}.rb"
      
      # Specs
      #
      m.directory "spec/app/view_models"
      m.template "spec/view_model_spec.rb", "spec/app/view_models/#{file_name}_spec.rb"
      
      # Views
      #
      m.directory "app/views/view_models"
      m.directory "app/views/view_models/#{file_name}"
      actions << 'list_item' if actions.empty?
      actions.each do |action|
        m.template "views/_empty.html.haml", "app/views/view_models/#{file_name}/_#{action}.html.haml"
      end
      
      # Copy collection views.
      #
      m.directory "app/views/view_models/collection"
      m.file "views/view_models/collection/_collection.html.haml", "app/views/view_models/collection/_collection.html.haml"
      m.file "views/view_models/collection/_collection.text.erb",  "app/views/view_models/collection/_collection.text.erb"
      m.file "views/view_models/collection/_list.html.haml",       "app/views/view_models/collection/_list.html.haml"
      m.file "views/view_models/collection/_list.text.erb",        "app/views/view_models/collection/_list.text.erb"
      m.file "views/view_models/collection/_pagination.html.haml", "app/views/view_models/collection/_pagination.html.haml"
      m.file "views/view_models/collection/_pagination.text.erb",  "app/views/view_models/collection/_pagination.text.erb"
      m.file "views/view_models/collection/_table.html.haml",      "app/views/view_models/collection/_table.html.haml"
      m.file "views/view_models/collection/_table.text.erb",       "app/views/view_models/collection/_table.text.erb"
      
      # Show README.
      #
      m.readme "README"
      
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
view_models-2.0.1 lib/rails2/generators/view_models/view_models_generator.rb
view_models-2.0.0.ruby19 lib/rails2/generators/view_models/view_models_generator.rb
view_models-2.0.0 lib/rails2/generators/view_models/view_models_generator.rb
view_models-1.5.7 generators/view_models/view_models_generator.rb
view_models-1.5.6 generators/view_models/view_models_generator.rb
view_models-1.5.5 generators/view_models/view_models_generator.rb
view_models-1.5.4 generators/view_models/view_models_generator.rb
view_models-1.5.3 generators/view_models/view_models_generator.rb
view_models-1.5.2 generators/view_models/view_models_generator.rb