Class: SolidusRazorpay::Generators::InstallGenerator

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

Instance Method Summary collapse

Instance Method Details

#add_javascriptsObject



7
8
9
10
11
# File 'lib/generators/solidus_razorpay/install/install_generator.rb', line 7

def add_javascripts
  append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require solidus/frontend/jquery-1.12.4.min.js\n"
  append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require solidus/frontend/checkout.js\n"
  append_file 'vendor/assets/javascripts/spree/frontend/all.js', "//= require solidus/frontend/jquery.blockUI.js\n"
end

#add_migrationsObject



29
30
31
# File 'lib/generators/solidus_razorpay/install/install_generator.rb', line 29

def add_migrations
  run 'bundle exec rake railties:install:migrations FROM=solidus_razorpay'
end

#add_stylesheetsObject



13
14
15
16
17
18
19
20
21
# File 'lib/generators/solidus_razorpay/install/install_generator.rb', line 13

def add_stylesheets
  if File.exists?('vendor/assets/stylesheets/spree/frontend/all.css')
    inject_into_file 'vendor/assets/stylesheets/spree/frontend/all.css', " *= require solidus/razorpay\n", :before => /\*\//, :verbose => true
  elsif File.exists?('vendor/assets/stylesheets/spree/frontend/all.css.scss')
    append_file 'vendor/assets/stylesheets/spree/frontend/all.css.scss', "\n@import 'solidus/razorpay'\n"
  elsif File.exists?('vendor/assets/stylesheets/spree/frontend/all.scss')
    append_file 'vendor/assets/stylesheets/spree/frontend/all.scss', "\n@import 'solidus/razorpay'\n"
  end
end

#mount_engineObject



23
24
25
26
27
# File 'lib/generators/solidus_razorpay/install/install_generator.rb', line 23

def mount_engine
  insert_into_file File.join('config', 'routes.rb'), after: "Rails.application.routes.draw do\n" do
    "mount SolidusRazorpay::Engine, at: '/solidus_razorpay'\n"
  end
end

#run_migrationsObject



33
34
35
36
37
38
39
40
# File 'lib/generators/solidus_razorpay/install/install_generator.rb', line 33

def run_migrations
  run_migrations = options[:auto_run_migrations] || ['', 'y', 'Y'].include?(ask 'Would you like to run the migrations now? [Y/n]')
  if run_migrations
    run 'bundle exec rake db:migrate'
  else
    puts 'Skipping rake db:migrate, don\'t forget to run it!'
  end
end