Sha256: 2056bb2099983f8572b74f07ecf6088b69bcb9b1aba8f47be1df0b779f618f79
Contents?: true
Size: 1.15 KB
Versions: 2
Compression:
Stored size: 1.15 KB
Contents
# frozen_string_literal: true class SeedService PRINTSPEAK_DATA_PATH = "/Users/davidcruwys/dev/printspeak/printspeak-generator/.builders/.data/" class << self def seed(variant: :reset) service = SeedService.new service.call(variant: variant) end end def call(variant: :reset) reset if variant == :reset refresh if variant == :refresh create end private def get_data(filename) json = File.read(File.join(PRINTSPEAK_DATA_PATH, filename)) JSON.parse(json) end def reset User.delete_all RailsApp.delete_all Rubocop.delete_all TableCount.delete_all end def refresh end def create refresh_printspeak RubocopLog.refresh end def refresh_printspeak david = User.create_with(name: 'david', password: 'password').find_or_create_by(email: 'david@site.com') rails_app = RailsApp.create_with(user: david).find_or_create_by(name: 'Printspeak') puts 'Create Rubocop Data' Rubocop.create(rails_app: rails_app, data: get_data('rubocop.json')) puts 'Create Table Count Data' TableCount.create(rails_app: rails_app, data: get_data('sql_count.json')) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rails_app_generator-0.3.1 | after_templates/application/klueless/app/services/seed_service.rb |
rails_app_generator-0.3.0 | after_templates/application/klueless/app/services/seed_service.rb |