Class: Hyrax::TestDataSeeder

Inherits:
Object
  • Object
show all
Defined in:
app/utils/hyrax/test_data_seeder.rb

Overview

This class was created for use in rake tasks and db/seeds.rb. It generates repository metadata needed for release testing. This data can also be helpful for local development testing.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger: Logger.new(STDOUT), allow_seeding_in_production: false) ⇒ TestDataSeeder

Returns a new instance of TestDataSeeder.


10
11
12
13
14
# File 'app/utils/hyrax/test_data_seeder.rb', line 10

def initialize(logger: Logger.new(STDOUT), allow_seeding_in_production: false)
  raise("TestDataSeeder is not for use in production!") if Rails.env.production? && !allow_seeding_in_production
  @logger = logger
  @allow_seeding_in_production = allow_seeding_in_production
end

Instance Attribute Details

#allow_seeding_in_productionObject

Returns the value of attribute allow_seeding_in_production.


8
9
10
# File 'app/utils/hyrax/test_data_seeder.rb', line 8

def allow_seeding_in_production
  @allow_seeding_in_production
end

#loggerObject

Returns the value of attribute logger.


8
9
10
# File 'app/utils/hyrax/test_data_seeder.rb', line 8

def logger
  @logger
end

Instance Method Details

#generate_seed_dataObject


16
17
18
19
20
21
22
# File 'app/utils/hyrax/test_data_seeder.rb', line 16

def generate_seed_data
  Hyrax::TestDataSeeders::UserSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
  Hyrax::TestDataSeeders::CollectionTypeSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
  Hyrax::TestDataSeeders::CollectionSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
  # TODO: add work seeder
  # Hyrax::TestDataSeeders::WorkSeeder.generate_seeds(logger: logger, allow_seeding_in_production: allow_seeding_in_production)
end