Sha256: a69141e7d8751c929dc1114c1baea07bdef969befa8e1fbac9fe7a6e0a9546e6

Contents?: true

Size: 802 Bytes

Versions: 4

Compression:

Stored size: 802 Bytes

Contents

require 'rails/generators/base'

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

      desc "Creates a CurrentUser initializer and a authentication key file to your application."

      def create_authentication_key
        create_file "config/current_user/key", ::SecureRandom.hex(20)
      end

      def copy_initializer
        template "current_user.rb", "config/initializers/current_user.rb"
      end

      def mount_routing
        inject_into_file 'config/routes.rb', :after => "routes.draw do" do
          "\n  mount CurrentUser::Engine => '/current_user'\n\n"
        end
      end

      def show_readme
        readme "README" if behavior == :invoke
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
current_user-0.2.1 lib/generators/current_user/install_generator.rb
current_user-0.2.0 lib/generators/current_user/install_generator.rb
current_user-0.1.0 lib/generators/current_user/install_generator.rb
current_user-0.0.1 lib/generators/current_user/install_generator.rb