Class: Foursquare::Generators::AuthenticationGenerator

Inherits:
Rails::Generators::Base
  • Object
show all
Includes:
Rails::Generators::Migration
Defined in:
lib/generators/foursquare/authentication/authentication_generator.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.next_migration_number(dirname) ⇒ Object



20
21
22
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 20

def self.next_migration_number(dirname)
	'20121103111300'
end

Instance Method Details

#add_clients_routesObject



45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 45

def add_clients_routes
	route(
%Q{
	scope module: 'clients' do
		resources :foursquare_clients, only: ['new'], path: 'clients/foursquare' do
 collection do
   get 'callback'
 end
		end
	end
}
	)
end

#add_oauth2_gemObject



15
16
17
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 15

def add_oauth2_gem
	gem 'oauth2'
end

#add_root_routesObject



41
42
43
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 41

def add_root_routes
	route "root :to => 'users#new'"
end

#add_user_routesObject



63
64
65
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 63

def add_user_routes
	route "resource :user"
end

#create_client_controllerObject



37
38
39
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 37

def create_client_controller
	template 'controllers/clients/foursquare_clients_controller.rb', File.join('app/controllers/clients', 'foursquare_clients_controller.rb')
end

#create_foursquare_client_modelObject



29
30
31
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 29

def create_foursquare_client_model
	template 'models/foursquare_client.rb', File.join('app/models/', 'foursquare_client.rb')
end

#create_foursquare_user_modelObject



24
25
26
27
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 24

def create_foursquare_user_model
	migration_template 'migrations/create_foursquare_user.rb', 'db/migrate/create_foursquare_users'
	template 'models/foursquare_user.rb', File.join('app/models/', 'foursquare_user.rb')
end

#create_users_controllerObject



59
60
61
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 59

def create_users_controller
	template 'controllers/users_controller.rb', File.join('app/controllers/', 'users_controller.rb')
end

#run_migrationsObject



33
34
35
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 33

def run_migrations
	rake 'db:migrate'
end

#validates_settingsObject



11
12
13
# File 'lib/generators/foursquare/authentication/authentication_generator.rb', line 11

def validates_settings
	raise "incorret client_id or client_secret" if settings['client_id'].blank? || settings['client_secret'].blank?
end