Sha256: dd4acefa92e7ca72b84e14ed3e36fc8e1f602d4762e17cc5cbeb778772013ccb

Contents?: true

Size: 789 Bytes

Versions: 14

Compression:

Stored size: 789 Bytes

Contents

require 'rails/generators'

module Pages
  module Generators
    class HomeGenerator < ::Rails::Generators::Base
      source_root File.expand_path("../templates", __FILE__)

      desc "Create a home page"

      def create_page
        return if File.exists?('app/views/visitors/index.html.erb')
        copy_file 'index.html.erb', 'app/views/visitors/index.html.erb'
        copy_file 'visitors_controller.rb', 'app/controllers/visitors_controller.rb'
        route = "  root to: 'visitors#index'"
        inject_into_file 'config/routes.rb', route + "\n", :after => "routes.draw do\n"
      end

      def add_tests
        return unless File.exists?('spec/spec_helper.rb')
        copy_file 'home_page_spec.rb', 'spec/features/visitors/home_page_spec.rb'
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
rails_apps_pages-0.6.7 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.6.6 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.6.5 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.6.4 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.6.3 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.6.2 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.6.0 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.16 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.15 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.14 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.13 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.12 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.11 lib/generators/pages/home/home_generator.rb
rails_apps_pages-0.5.10 lib/generators/pages/home/home_generator.rb