Class: ShopifyApp::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#create_and_inject_into_omniauth_initializerObject


24
25
26
27
28
29
30
31
32
33
34
# File 'lib/generators/shopify_app/install/install_generator.rb', line 24

def create_and_inject_into_omniauth_initializer
  unless File.exist? "config/initializers/omniauth.rb"
    copy_file 'omniauth.rb', 'config/initializers/omniauth.rb'
  end

  inject_into_file(
    'config/initializers/omniauth.rb',
    File.read(File.expand_path(find_in_source_paths('shopify_provider.rb'))),
    after: "Rails.application.config.middleware.use OmniAuth::Builder do\n"
  )
end

#create_embedded_app_layoutObject


36
37
38
39
40
41
# File 'lib/generators/shopify_app/install/install_generator.rb', line 36

def create_embedded_app_layout
  if embedded_app?
    copy_file 'embedded_app.html.erb', 'app/views/layouts/embedded_app.html.erb'
    copy_file '_flash_messages.html.erb', 'app/views/layouts/_flash_messages.html.erb'
  end
end

#create_shopify_app_initializerObject


15
16
17
18
19
20
21
22
# File 'lib/generators/shopify_app/install/install_generator.rb', line 15

def create_shopify_app_initializer
  @application_name = format_array_argument(options['application_name'])
  @api_key = options['api_key']
  @secret = options['secret']
  @scope = format_array_argument(options['scope'])

  template 'shopify_app.rb', 'config/initializers/shopify_app.rb'
end

#mount_engineObject


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

def mount_engine
  route "mount ShopifyApp::Engine, at: '/'"
end