Sha256: fb945997a018e1877e3fd19047d4c7bfcb8d34847b8ccd1adea8aea6e32ab6ee

Contents?: true

Size: 1.11 KB

Versions: 3

Compression:

Stored size: 1.11 KB

Contents

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

		def create_a_config_file
			copy_file "config/initializers/omniauth-infinum.rb", "config/initializers/omniauth-infinum.rb"
		end

		def create_the_omniauth_controller
			copy_file "app/controllers/omniauth_controller.rb", "app/controllers/omniauth_controller.rb"
		end

		def add_routes
			routes = "  get '/auth/:provider/callback', :to => 'omniauth#success'\n" +
					 "  get '/auth/failure'	, :to => 'omniauth#failure'\n" +
			 		 "  get '/logout', :to => 'omniauth#logout'\n"

			file_content = File.read('config/routes.rb')
			file_content.sub!("routes.draw do\n", "routes.draw do\n\n#{routes}")
			File.open("config/routes.rb", 'w') { |file| file.write(file_content)}	
			say_status "insert", "routes.rb file -> 'Success, failure and logout routes added.'", :green
		end

		def rails_generate_migration
			copy_file "db/migrate/add_uid_to_users.rb", "db/migrate/#{migrationNumber}_add_uid_to_users.rb"
		end

	private

		def migrationNumber
			Time.now.utc.strftime("%Y%m%d%H%M%S")
		end

	end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
omniauth-infinum-0.9.9 lib/generators/omniauth_infinum/install_generator.rb
omniauth-infinum-0.9.8 lib/generators/omniauth_infinum/install_generator.rb
omniauth-infinum-0.9.7 lib/generators/omniauth_infinum/install_generator.rb