module Shoestrap class AppBuilder < Rails::AppBuilder def readme template 'README.md.erb', 'README.md' end def gemfile template 'Gemfile.erb', 'Gemfile' end def bundle bundle_command 'install' bundle_command 'show rspec' end def setup_bdd_env setup_rspec setup_cucumber setup_guard setup_mail_interceptor end def setup_database rake 'db:create' rake 'db:migrate' rake 'db:seed' end def configure_generators # depends on haml-rails and bootstrap-sass copy_file 'bootstrap_and_overrides.css.sass', 'app/assets/stylesheets/bootstrap_and_overrides.css.sass' generate 'simple_form:install --bootstrap' remove_file 'lib/templates/haml/scaffold/_form.html.haml' remove_file 'config/locales/simple_form.en.yml' inject_into_file 'config/application.rb', :after => "config.assets.version = '1.0'" do <<-eos.gsub(/^ {6}/, '').chomp # Configure Generators config.generators do |g| g.template_engine :haml g.test_framework :rspec g.stylesheets false g.javascripts false g.assets false g.helper false end eos end inject_into_file 'app/assets/javascripts/application.js', "\n//= require bootstrap\n", :before => '//= require_tree .' end def configure_application gsub_file 'config/application.rb', '# config.autoload_paths += %W(#{config.root}/extras)' do <<-'eos'.gsub(/^ {10}/, '').chomp config.autoload_paths += %W(#{config.root}/lib) eos end gsub_file 'config/application.rb', ' # config.i18n.default_locale = :de' do <<-'eos'.gsub(/^ {6}/, '').chomp config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s] config.i18n.available_locales = [:de] config.i18n.default_locale = :de eos end empty_directory 'config/locales/de/views/cms' copy_file 'shoestrap.yml', 'config/locales/de/views/cms/shoestrap.yml' template 'application.html.haml', 'app/views/layouts/application.html.haml' remove_file 'app/views/layouts/application.html.erb' end def remove_files_we_dont_need remove_rails_logo_image remove_public_index end def install_kuhsaft # depends on kuhsaft rake 'kuhsaft:install:migrations' route 'mount Kuhsaft::Engine => "/"' copy_file 'kuhsaft.css.sass', 'app/assets/stylesheets/kuhsaft.css.sass' copy_file 'cms_navigation.rb', 'config/cms_navigation.rb' inject_into_file 'app/assets/javascripts/application.js', "\n//= require 'kuhsaft/application'\n", :before => '//= require_tree .' empty_directory 'app/views/kuhsaft/cms/admin/' template '_main_navigation.html.haml.erb', 'app/views/kuhsaft/cms/admin/_main_navigation.html.haml' end def setup_deployment generate 'shoestrap:deployment' end def outro say 'Application is ready!' end private def setup_mail_interceptor # depends on mail gem copy_file 'development_mail_interceptor.rb', 'lib/development_mail_interceptor.rb' copy_file 'setup_mail.rb', 'config/initializers/setup_mail.rb' end def setup_rspec # depends on rspec-rails gem generate 'rspec:install' end def setup_cucumber # depends on cucumber gem generate 'cucumber:install' end def setup_guard # depends on guard, guard-rspec, guard-cucumber template 'Guardfile' end def remove_public_index remove_file 'public/index.html' end def remove_rails_logo_image remove_file 'app/assets/images/rails.png' end end end