Sha256: 605f991dce7edf4002a40b31fdd3410c043415c99d11a1065ddd3950ecc231a9

Contents?: true

Size: 1.22 KB

Versions: 5

Compression:

Stored size: 1.22 KB

Contents

module Portfolio
  module Generators
    class InstallGenerator < Rails::Generators::Base
      source_root File.expand_path('../templates', __FILE__)

      desc <<-DESC.strip_heredoc
        Description:
            Installs portfolio into the current app

        Example:
            rails generate portfolio:install

            This will create:
                config/initializers/portfolio.rb
            And insert into:
                config/routes.rb
                app/assets/javascripts/application.js
                app/assets/stylesheets/application.css
      DESC

      def copy_initializer_file
        copy_file 'initializer.rb', 'config/initializers/portfolio.rb'
      end

      def mount_engine
        route "\n  mount Portfolio::Engine, at: '/portfolio'\n"+
              "  # root 'portfolio/sites#default'\n\n"
      end

      def insert_javascript
        inject_into_file 'app/assets/javascripts/application.js', after: "//= require jquery\n" do
          "//= require portfolio/application\n"
        end
      end

      def insert_stylesheets
        inject_into_file 'app/assets/stylesheets/application.css', before: "\n */" do
          "\n *= require portfolio/application"
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails-portfolio-0.0.5 lib/generators/portfolio/install_generator.rb
rails-portfolio-0.0.4 lib/generators/portfolio/install_generator.rb
rails-portfolio-0.0.3 lib/generators/portfolio/install_generator.rb
rails-portfolio-0.0.2 lib/generators/portfolio/install_generator.rb
rails-portfolio-0.0.1 lib/generators/portfolio/install_generator.rb