16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
# File 'lib/generators/notifykit/install_generator.rb', line 16
def generate_notifykit
generate_migration("create_notifications")
empty_directory "app"
empty_directory "app/models"
empty_directory "app/mailers"
empty_directory "app/helpers"
empty_directory "app/controllers"
empty_directory "app/views"
empty_directory "app/views/notifications_mailer"
empty_directory "spec"
empty_directory "spec/models"
empty_directory "spec/controllers"
empty_directory "spec/mailers"
template "app/models/notification.rb", "app/models/notification.rb"
template "app/mailers/notifications_mailer.rb", "app/mailers/notifications_mailer.rb"
template "app/helpers/notifications_helper.rb", "app/helpers/notifications_helper.rb"
template "app/controllers/notifications_controller.rb", "app/controllers/notifications_controller.rb"
template "spec/factories/notification.rb", "spec/factories/notification.rb"
template "spec/models/notification_spec.rb", "spec/models/notification_spec.rb"
template "spec/helpers/notifications_helper_spec.rb", "spec/helpers/notifications_helper_spec.rb"
template "spec/mailers/notifications_mailer_spec.rb", "spec/mailers/notifications_mailer_spec.rb"
template "spec/controllers/notifications_controller_spec.rb", "spec/controllers/notifications_controller_spec.rb"
copy_file "app/views/notifications_mailer/notify.html.erb", "app/views/notifications_mailer/notify.html.erb"
copy_file "app/views/notifications_mailer/notify.text.erb", "app/views/notifications_mailer/notify.text.erb"
copy_file "app/views/notifications_mailer/_welcome.html.erb", "app/views/notifications_mailer/_welcome.html.erb"
copy_file "app/views/notifications_mailer/_welcome.text.erb", "app/views/notifications_mailer/_welcome.text.erb"
route "get '/notifications/recent', to: 'notifications#recent', as: :notifications_recent"
route "get '/notifications/:token', to: 'notifications#click', as: :notification_click"
route "get '/notifications/:token/view', to: 'notifications#view', as: :notification_view"
route "get '/notifications/:token/read', to: 'notifications#read', as: :notification_read"
route "get '/notifications/:token/ignore', to: 'notifications#ignore', as: :notification_ignore"
route "get '/notifications/:token/cancel', to: 'notifications#cancel', as: :notification_cancel"
route "get '/notifications/:token/unsubscribe', to: 'notifications#unsubscribe', as: :notification_unsubscribe"
if options.test_mode?
route "root 'welcome#index'"
route "get '/help', to: 'help#index', as: :help"
route "get '/privacy', to: 'privacy#index', as: :privacy"
route "get '/terms', to: 'terms#index', as: :terms"
end
inject_into_class "app/models/user.rb", User, "has_many :notifications\n" rescue nil
insert_at_end_of_class "spec/spec_helper.rb", "spec/spec_helper.rb"
gem_group :test, :development do
gem "rspec-rails"
gem "shoulda-matchers"
gem 'factory_girl_rails'
end
end
|