Class: CoreMerchant::Generators::InstallGenerator

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

Overview

Install generator for CoreMerchant

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details



43
44
45
# File 'lib/generators/core_merchant/install_generator.rb', line 43

def self.banner
  "rails generate core_merchant:install"
end

.descriptionObject



47
48
49
50
51
# File 'lib/generators/core_merchant/install_generator.rb', line 47

def self.description
  <<~DESC
    Installs CoreMerchant into your application. This generator will create an initializer file, migration files for the subscription, subscription plan, and subscription event tables, and a locale file.
  DESC
end

.next_migration_number(_dir) ⇒ Object



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

def self.next_migration_number(_dir)
  Time.now.utc.strftime("%Y%m%d%H%M%S")
end

Instance Method Details

#copy_initializerObject



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

def copy_initializer
  template "core_merchant.rb", "config/initializers/core_merchant.rb"
end

#copy_localesObject



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

def copy_locales
  template "core_merchant.en.yml", "config/locales/core_merchant.en.yml"
end

#create_migration_fileObject



25
26
27
28
29
30
# File 'lib/generators/core_merchant/install_generator.rb', line 25

def create_migration_file
  migration_template(
    "migrate/create_core_merchant_tables.erb",
    "db/migrate/create_core_merchant_tables.rb"
  )
end

#show_post_installObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/generators/core_merchant/install_generator.rb', line 32

def show_post_install
  say "CoreMerchant has been successfully installed.", :green
  next_steps = <<~MESSAGE
    Next steps:
    1. Set the customer class in the initializer file (config/initializers/core_merchant.rb) to the class you want to use for customers.
    2. Create a subscription listener class (should include CoreMerchant::SubscriptionListener) in your app and set this class in the initializer file (config/initializers/core_merchant.rb) to the class you want to use for subscription listeners.
    3. Run `rails db:migrate` to create the subscription, subscription plan, and subscription event tables.
  MESSAGE
  say next_steps, :yellow
end