Sha256: 251fa753bd6aa0abd579a28504ff2f89f0f9d318df04ec4f342c3c8b8eb1b9ae

Contents?: true

Size: 1.77 KB

Versions: 3

Compression:

Stored size: 1.77 KB

Contents

module SocialFramework
  module Generators
    # Generator to add the principal files and configurations
    class InstallGenerator < Rails::Generators::Base

      source_root File.expand_path('../../templates/', __FILE__)

      desc "Init devise configurations with social_framework.rb, devise.rb, routes and principal views"

      # Copy social_framework.rb file to app, this file is used to define social_framework configurations
      def copy_social_framework_setup
        copy_file "initializers/social_framework.rb", "config/initializers/social_framework.rb"
      end
      
      # Copy devise.rb file to app, this file is used to define devise configurations
      def copy_devise_setup
        copy_file "initializers/devise.rb", "config/initializers/devise.rb"
      end

      # Copy translate file to app, this file is used to define devise configurations
      def copy_translate_file
        copy_file "../../../config/locales/devise.en.yml", "config/locales/devise.en.yml"
      end

      # Add devise routes to app maped to framework controllers
      def add_devise_routes
      	devise_route = "devise_for :users, class_name: 'SocialFramework::User',\n" <<
          "\t\tcontrollers: {sessions: 'users/sessions',\n"<<
          "\t\t\t\t\t\t\t\t\tregistrations: 'users/registrations',\n"<<
          "\t\t\t\t\t\t\t\t\tpasswords: 'users/passwords'}"
        
        route devise_route
      end

      # Add the principal devise views (registrations and sessions),
      # whith this it's possible register, update and authenticate users
      def add_views
        directory "views/registrations", "app/views/devise/registrations"
        directory "views/sessions", "app/views/devise/sessions"
        directory "views/shared", "app/views/devise/shared"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
social_framework-1.0.1 lib/generators/social_framework/install_generator.rb
social_framework-0.0.3 lib/generators/social_framework/install_generator.rb
social_framework-0.0.2 lib/generators/social_framework/install_generator.rb