Class: Develoz::Generators::AuthGenerator
- Inherits:
-
Base
- Object
- Rails::Generators::Base
- Base
- Develoz::Generators::AuthGenerator
show all
- Defined in:
- lib/generators/develoz/auth/auth_generator.rb
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Base
#add_gem, #app_class, #app_name, #append_env, #apply_template, #ensure_gitignore, #inject_once, #insert_route, #migration_exists?, next_migration_timestamp
Class Method Details
.source_root ⇒ Object
8
9
10
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 8
def self.source_root
File.expand_path("templates", __dir__)
end
|
Instance Method Details
#add_bcrypt_gem ⇒ Object
12
13
14
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 12
def add_bcrypt_gem
add_gem "bcrypt"
end
|
#create_authentication_concern ⇒ Object
24
25
26
27
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 24
def create_authentication_concern
template "app/controllers/concerns/authentication.rb.tt",
"app/controllers/concerns/authentication.rb"
end
|
#create_current_model ⇒ Object
20
21
22
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 20
def create_current_model
template "app/models/current.rb.tt", "app/models/current.rb"
end
|
#create_passwords_controller ⇒ Object
34
35
36
37
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 34
def create_passwords_controller
template "app/controllers/passwords_controller.rb.tt",
"app/controllers/passwords_controller.rb"
end
|
#create_passwords_mailer ⇒ Object
39
40
41
42
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 39
def create_passwords_mailer
template "app/mailers/passwords_mailer.rb.tt",
"app/mailers/passwords_mailer.rb"
end
|
#create_passwords_mailer_views ⇒ Object
54
55
56
57
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 54
def create_passwords_mailer_views
template "app/views/passwords_mailer/reset.html.erb.tt",
"app/views/passwords_mailer/reset.html.erb"
end
|
#create_passwords_request_spec ⇒ Object
76
77
78
79
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 76
def create_passwords_request_spec
template "spec/requests/passwords_spec.rb.tt",
"spec/requests/passwords_spec.rb"
end
|
#create_passwords_views ⇒ Object
49
50
51
52
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 49
def create_passwords_views
template "app/views/passwords/edit.html.erb.tt",
"app/views/passwords/edit.html.erb"
end
|
#create_sessions_controller ⇒ Object
29
30
31
32
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 29
def create_sessions_controller
template "app/controllers/sessions_controller.rb.tt",
"app/controllers/sessions_controller.rb"
end
|
#create_sessions_request_spec ⇒ Object
71
72
73
74
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 71
def create_sessions_request_spec
template "spec/requests/sessions_spec.rb.tt",
"spec/requests/sessions_spec.rb"
end
|
#create_sessions_views ⇒ Object
44
45
46
47
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 44
def create_sessions_views
template "app/views/sessions/new.html.erb.tt",
"app/views/sessions/new.html.erb"
end
|
#create_user_model ⇒ Object
16
17
18
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 16
def create_user_model
template "app/models/user.rb.tt", "app/models/user.rb"
end
|
#create_users_migration ⇒ Object
59
60
61
62
63
64
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 59
def create_users_migration
return if migration_exists?("create_users")
template "db/migrate/create_users.rb.tt",
"db/migrate/#{next_migration_timestamp}_create_users.rb"
end
|
#insert_auth_routes ⇒ Object
66
67
68
69
|
# File 'lib/generators/develoz/auth/auth_generator.rb', line 66
def insert_auth_routes
insert_route "resource :session, only: [:new, :create, :destroy]"
insert_route "resources :passwords, param: :token, only: [:new, :create, :edit, :update]"
end
|