Skip to content

Generators

Julie Allinson edited this page Dec 7, 2018 · 3 revisions

The Generators And What They Do

Install Generator

This generator makes the following changes to your application:

  1. Adds a dog_biscuits initializer in config/initializers/dog_biscuits.rb.
  2. Adds a dog_biscuits yml configuration file in config/dog_biscuits.yml.
  3. Includes DogBiscuits::ExtendedSolrDocument in the SolrDocument
  4. Runs the authorities, schema_org and locales generators
  5. Adds a few more files into the app, replaces the CatalogController
  6. Adds two view files as a temporary fix.

Run with:

  • rails generate dog_biscuits:install

Generate All Generator

This generator makes the following changes to your application:

  1. Runs the work generator for all selected_models configured in config/initializers/dog_biscuits.rb
  2. Runs the attribute_rows generator
  3. Runs the locales generator
  4. Runs the schema_org generator
Run:
rails generate dog_biscuits:generate_all
# Don't overwrite the models and indexers:
rails generate dog_biscuits:generate_all --skipmodel

Authority Generator:

This generator makes the following changes to your application:

  1. Copies authorities into config/authorities.
  2. Registers all subauthorities in config/intitializers/dog_biscuits.rb
  3. Sets up references to the authority concept_schemes in config/dog_biscuits.yml
  4. Copies the authority services into app/services/
Run:
rails generate dog_biscuits:authority

Catalog Controller Generator

This generator makes the following changes to your application:

  1. Creates a new app/controllers/catalog_controller.rb.
# Run:
rails generate dog_biscuits:catalog_controller

Schema Org Generator

This generator makes the following changes to your application:

  1. Creates a schema_org.yml file in ./config
# Run:
rails generate dog_biscuits:schema_org

Locales Generator

This generator can be run for an existing Model, or for All models (with All).

This generator makes the following changes to your application where information is available in property_mappings:

  1. Injects labels and help_text into the dog_biscuits.en locale
# Run all:
rails generate dog_biscuits:locales All
# Run one:
rails generate dog_biscuits:locales ConferenceItem

Attribute Rows Generator

This generator can be run for an existing Model, or for All models (with All).

This generator makes the following changes to your application:

  1. Creates an _attribute_rows.html.erb file for the given Work
# Run all:
rails generate dog_biscuits:attribute_rows All
# Run one:
rails generate dog_biscuits:attribute_rows ConferenceItem

Work Generator

This generator makes the following changes to your application:

  1. Checks that the requested Work is supported by DogBiscuits
  2. Runs the Hyrax generator for the given model
  3. Creates a new model, form, actor, presenter and indexer to replace the Hyrax one
  4. Creates an attribute_rows view file using the configured properties for the work
  5. Runs the schema_org and locales generators
# Run with the model name as an attribute:
rails generate dog_biscuits:work ConferenceItem
# Skip generating the model and indexer:
rails generate dog_biscuits:work ConferenceItem --skipmodel