Class: Nondisposable::Generators::InstallGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
ActiveRecord::Generators::Migration
Defined in:
lib/generators/nondisposable/install_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dir) ⇒ Object



13
14
15
# File 'lib/generators/nondisposable/install_generator.rb', line 13

def self.next_migration_number(dir)
  ActiveRecord::Generators::Base.next_migration_number(dir)
end

Instance Method Details

#create_database_refresh_jobObject



25
26
27
# File 'lib/generators/nondisposable/install_generator.rb', line 25

def create_database_refresh_job
  template 'disposable_email_domain_list_update_job.rb', 'app/jobs/disposable_email_domain_list_update_job.rb'
end

#create_initializerObject



21
22
23
# File 'lib/generators/nondisposable/install_generator.rb', line 21

def create_initializer
  template 'nondisposable.rb', 'config/initializers/nondisposable.rb'
end

#create_migration_fileObject



17
18
19
# File 'lib/generators/nondisposable/install_generator.rb', line 17

def create_migration_file
  migration_template 'create_nondisposable_disposable_domains.rb.erb', File.join(db_migrate_path, "create_nondisposable_disposable_domains.rb")
end

#display_post_install_messageObject



29
30
31
32
33
34
35
36
37
# File 'lib/generators/nondisposable/install_generator.rb', line 29

def display_post_install_message
  say "\tThe `nondisposable` gem has been successfully installed!", :green
  say "\nTo complete the setup:"
  say "  1. Run 'rails db:migrate' to create the necessary tables."
  say "  2. Run 'Nondisposable::DomainListUpdater.update' to populate the initial list of disposable domains."
  say "  3. Add 'validates :email, nondisposable: true' to your User model (or any model with an email field)."
  say "  4. Configure your recurrent job according to the README, and make sure you have a functional queuing system (like solid_queue) that can run jobs properly so the disposable emails list is updated regularly."
  say "\nEnjoy your new `nondisposable` users!", :green
end