Sha256: 541fc0c0ff644069c25d4c41c11d2356fefca27626ef37ee05e685eeee4bf097
Contents?: true
Size: 1.38 KB
Versions: 3
Compression:
Stored size: 1.38 KB
Contents
require 'rails/generators' require 'rails/generators/migration' module Aai class InstallGenerator < Rails::Generators::Base include Rails::Generators::Migration desc "Generate Config Files / User / Session and Routes" class_option :persist, :type => :boolean, :default => true, :desc => "Set to false if you don't want persistent User" def self.source_root @source_root ||= File.join(File.dirname(__FILE__), 'templates') end def copy_initializer_file copy_file "omniauth.rb", "config/initializers/omniauth.rb" end def copy_session_controller_file if true template "session_controller.rb", "app/controllers/session_controller.rb" route("match '/auth/:provider/callback', :to => 'session#create', :as => 'auth_callback'") route("match '/auth/failure', :to => 'session#failure', :as => 'auth_failure'") route("match '/auth/logout', :to => 'session#destroy', :as => 'logout'") end end def copy_user_file template "user.rb", "app/models/user.rb" migration_template "migration.rb", "db/migrate/aai_create_user.rb" if options[:persist] end def self.next_migration_number(dirname) orm = Rails.configuration.generators.options[:rails][:orm] require "rails/generators/#{orm}" "#{orm.to_s.camelize}::Generators::Base".constantize.next_migration_number(dirname) end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
omniauth-aai-0.5.2 | lib/generators/aai/install_generator.rb |
omniauth-aai-0.5.1 | lib/generators/aai/install_generator.rb |
omniauth-aai-0.5 | lib/generators/aai/install_generator.rb |