class Sufia::Install

Public Instance Methods

add_sufia_collection_indexer() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 127
def add_sufia_collection_indexer
  inject_into_file 'app/models/collection.rb', after: 'include CurationConcerns::BasicMetadata' do
    "\n  self.indexer = Sufia::CollectionIndexer"
  end
end
banner() click to toggle source
catalog_controller() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 89
def catalog_controller
  copy_file "catalog_controller.rb", "app/controllers/catalog_controller.rb"
end
configure_usage_stats() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 66
def configure_usage_stats
  copy_file 'config/analytics.yml', 'config/analytics.yml'
end
copy_helper() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 93
def copy_helper
  copy_file 'sufia_helper.rb', 'app/helpers/sufia_helper.rb'
end
copy_migrations() click to toggle source

Setup the database migrations

# File lib/generators/sufia/install_generator.rb, line 34
def copy_migrations
  rake 'sufia:install:migrations'
end
create_workflow() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 154
def create_workflow
  template('workflow.json.erb', "config/workflows/one_step_mediated_deposit_workflow.json")
end
datatables() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 150
def datatables
  generate 'jquery:datatables:install bootstrap3'
end
inject_routes() click to toggle source

The engine routes have to come after the devise routes so that /users/sign_in will work

# File lib/generators/sufia/install_generator.rb, line 98
def inject_routes
  gsub_file 'config/routes.rb', /root (:to =>|to:) "catalog#index"/, ''
  gsub_file 'config/routes.rb', /'welcome#index'/, "'sufia/homepage#index'" # Replace the root path injected by CurationConcerns
  routing_code = "\n  mount Sufia::Engine, at: '/'\n"
  sentinel = /\s+mount CurationConcerns::Engine/
  inject_into_file 'config/routes.rb', routing_code, before: sentinel, verbose: false
end
inject_sufia_application_controller_behavior() click to toggle source

Add behaviors to the application controller

# File lib/generators/sufia/install_generator.rb, line 77
def inject_sufia_application_controller_behavior
  file_path = "app/controllers/application_controller.rb"
  if File.exist?(file_path)
    insert_into_file file_path, after: 'CurationConcerns::ApplicationControllerBehavior' do
      "  \n  # Adds Sufia behaviors into the application controller \n" \
      "  include Sufia::Controller\n"
    end
  else
    puts "     \e[31mFailure\e[0m  Could not find #{file_path}.  To add Sufia behaviors to your Controllers, you must include the Sufia::Controller module in the Controller class definition."
  end
end
inject_sufia_file_set_behavior() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 56
def inject_sufia_file_set_behavior
  insert_into_file 'app/models/file_set.rb', after: 'include ::CurationConcerns::FileSetBehavior' do
    "\n  include Sufia::FileSetBehavior"
  end
end
inject_sufia_solr_document_behavior() click to toggle source

Add behaviors to the SolrDocument model

# File lib/generators/sufia/install_generator.rb, line 107
def inject_sufia_solr_document_behavior
  file_path = "app/models/solr_document.rb"
  if File.exist?(file_path)
    inject_into_file file_path, after: /include CurationConcerns::SolrDocumentBehavior/ do
      "\n  # Adds Sufia behaviors to the SolrDocument.\n" \
        "  include Sufia::SolrDocumentBehavior\n"
    end
  else
    puts "     \e[31mFailure\e[0m  Sufia requires a SolrDocument object. This generator assumes that the model is defined in the file #{file_path}, which does not exist."
  end
end
inject_sufia_user_behaviors() click to toggle source

Add behaviors to the user model

# File lib/generators/sufia/install_generator.rb, line 43
def inject_sufia_user_behaviors
  file_path = "app/models/#{model_name.underscore}.rb"
  if File.exist?(file_path)
    inject_into_file file_path, after: /include CurationConcerns\:\:User.*$/ do
      "\n  # Connects this user object to Sufia behaviors." \
      "\n  include Sufia::User" \
      "\n  include Sufia::UserUsageStats\n"
    end
  else
    puts "     \e[31mFailure\e[0m  Sufia requires a user object. This generators assumes that the model is defined in the file #{file_path}, which does not exist.  If you used a different name, please re-run the generator and provide that name as an argument. Such as \b  rails -g sufia:install client"
  end
end
insert_abilities() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 70
def insert_abilities
  insert_into_file 'app/models/ability.rb', after: /CurationConcerns::Ability/ do
    "\n  include Sufia::Ability\n"
  end
end
install_assets() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 123
def install_assets
  generate "sufia:assets"
end
install_batch_edit() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 133
def install_batch_edit
  generate "hydra_batch_edit:install"
end
install_config() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 38
def install_config
  generate "sufia:config"
end
install_mailboxer() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 62
def install_mailboxer
  generate "mailboxer:install"
end
install_sufia_700() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 119
def install_sufia_700
  generate "sufia:upgrade700"
end
run_required_generators() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 29
def run_required_generators
  generate "curation_concerns:install --skip-assets -f" unless options[:skip_curation_concerns]
end
use_browser_validations() click to toggle source
# File lib/generators/sufia/install_generator.rb, line 137
def use_browser_validations
  gsub_file 'config/initializers/simple_form.rb',
            /browser_validations = false/,
            'browser_validations = true'
end