class DogBiscuits::InstallGenerator

Public Instance Methods

banner() click to toggle source
create_app() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 27
def create_app
  directory 'app', 'app'
end
create_authorities() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 48
def create_authorities
  generate 'dog_biscuits:authority'
end
create_dog_biscuits() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 19
def create_dog_biscuits
  init_path = 'config/initializers/dog_biscuits.rb'
  yml_path = 'config/dog_biscuits.yml'

  copy_file 'config/dog_biscuits.yml', yml_path unless File.exist?(yml_path) && !options[:force]
  copy_file 'config/initializers/dog_biscuits.rb', init_path unless File.exist?(init_path) && !options[:force]
end
create_helpers() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 52
def create_helpers
  db_injection = '  include ::DogBiscuitsHelper'
  unless File.read('app/helpers/hyrax_helper.rb').include? db_injection
    inject_into_file 'app/helpers/hyrax_helper.rb', after: "Hyrax::HyraxHelperBehavior\n" do
      "#{db_injection}\n"
    end
  end
end
create_locales() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 31
def create_locales
  directory 'config/locales', 'config/locales'
end
create_schema_org() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 79
def create_schema_org
  generate 'dog_biscuits:schema_org'
end
generate_dates() click to toggle source

Make sure range is in place, if we're running install again, it could remove it

# File lib/generators/dog_biscuits/install_generator.rb, line 62
def generate_dates
  if DogBiscuits.config.date_range || DogBiscuits.config.date_picker
    generate('dog_biscuits:dates')
  end
end
generate_locales() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 75
def generate_locales
  generate 'dog_biscuits:locales', '-f'
end
update_initializer() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 35
def update_initializer
  gsub_file 'config/initializers/dog_biscuits.rb', /#   Available models are:/, "#   Available models are: #{DogBiscuits.config.available_models.join(', ')}"
end
update_solr_document() click to toggle source
# File lib/generators/dog_biscuits/install_generator.rb, line 39
def update_solr_document
  solr_doc = 'app/models/solr_document.rb'
  unless solr_doc.include? 'DogBiscuits::ExtendedSolrDocument'
    inject_into_file solr_doc, after: 'include Hyrax::SolrDocumentBehavior' do
      "\n  include DogBiscuits::ExtendedSolrDocument"
    end
  end
end
wipe_hyrax_locales() click to toggle source

Remove all blacklight labels from hyrax locales

# File lib/generators/dog_biscuits/install_generator.rb, line 69
def wipe_hyrax_locales
  Dir.entries('config/locales').select { |file| file.start_with?('hyrax.') }.each do |locale|
    gsub_file "config/locales/#{locale}", /  blacklight:(.*)  hyrax:/m, "  hyrax:"
  end
end