class Sprangular::InstallGenerator

Public Instance Methods

add_assets() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 33
  def add_assets
    inject_into_file 'app/assets/stylesheets/application.css', " *= require sprangular\n", before: /\*\//, verbose: true
    append_file 'app/assets/javascripts/application.js', <<-eos
//= require jquery
//= require bootstrap-sass-official
//= require sprangular
//= require sprangular/host
//= require sprangular/extraRoutes
//= require_tree ./sprangular/controllers
//= require_tree ./sprangular/services
eos

    template 'host.coffee',        'app/assets/javascripts/sprangular/host.coffee'
    template 'extraRoutes.coffee', 'app/assets/javascripts/sprangular/extraRoutes.coffee'

    create_file 'app/assets/javascripts/sprangular/controllers/.keep', ''
    create_file 'app/assets/javascripts/sprangular/services/.keep', ''

    copy_file 'about.html.slim',    'app/assets/templates/static/about.html.slim'
    copy_file 'terms.html.slim',    'app/assets/templates/static/terms.html.slim'
    copy_file 'privacy.html.slim',  'app/assets/templates/static/privacy.html.slim'
  end
add_layout() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 56
def add_layout
  template 'layout.slim', 'app/views/layouts/sprangular/application.slim'
end
add_migrations() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 66
def add_migrations
  run 'bundle exec rake railties:install:migrations FROM=sprangular_engine'
end
add_routes() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 15
def add_routes
  route "mount Sprangular::Engine  => '/'"
  route "mount Spree::Core::Engine => '/spree'"
end
copy_templates() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 60
def copy_templates
  if options["copy_templates"]
    directory "../../../../../app/assets/templates", "app/assets/templates"
  end
end
remove_assets() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 20
def remove_assets
  run "rm -rf vendor/assets/images/spree/frontend"
  run "rm -rf vendor/assets/javascripts/spree/frontend"
  run "rm -rf vendor/assets/stylesheets/spree/frontend"
end
remove_spree_core_engine_route() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 11
def remove_spree_core_engine_route
  gsub_file 'config/routes.rb', /^.*Spree::Core::Engine.*\n/, ''
end
remove_spree_umbrella_gem() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 7
def remove_spree_umbrella_gem
  gsub_file 'Gemfile', /^.*gem.["']spree["'].*\n/, ''
end
remove_uneeded_js() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 26
def remove_uneeded_js
  gsub_file 'app/assets/javascripts/application.js', %r{//= require jquery\n}, ''
  gsub_file 'app/assets/javascripts/application.js', %r{//= require jquery_ujs\n}, ''
  gsub_file 'app/assets/javascripts/application.js', %r{//= require turbolinks\n}, ''
  gsub_file 'app/assets/javascripts/application.js', %r{//= require_tree .\n}, ''
end
run_migrations() click to toggle source
# File lib/generators/sprangular/install/install_generator.rb, line 70
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