12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/rails/generators/clearance_generator.rb', line 12
def install
template "clearance.rb", "config/initializers/clearance.rb"
inject_into_class "app/controllers/application_controller.rb", ApplicationController do
" include Clearance::Authentication\n"
end
user_model = "app/models/user.rb"
if File.exists?(user_model)
inject_into_class user_model, User do
"include Clearance::User"
end
else
template "user.rb", user_model
end
if File.exists?("spec")
template "factories.rb", "spec/factories/clearance.rb"
else
template "factories.rb", "test/factories/clearance.rb"
end
migration_template "migrations/#{migration_source_name}.rb",
"db/migrate/clearance_#{migration_target_name}"
end
|