Class: SeemsRateable::Generators::UninstallOld
- Inherits:
-
Rails::Generators::Base
- Object
- Rails::Generators::Base
- SeemsRateable::Generators::UninstallOld
- Includes:
- MigrationHelpers
- Defined in:
- lib/generators/seems_rateable/uninstall_old/uninstall_old_generator.rb
Instance Method Summary collapse
- #comment_seems_rateable_in_models ⇒ Object
- #drop_tables ⇒ Object
- #remove_initializer ⇒ Object
- #remove_javascripts ⇒ Object
- #remove_stylesheet_include_in_template ⇒ Object
Instance Method Details
#comment_seems_rateable_in_models ⇒ Object
41 42 43 44 45 |
# File 'lib/generators/seems_rateable/uninstall_old/uninstall_old_generator.rb', line 41 def comment_seems_rateable_in_models Dir.glob('app/models/*').keep_if { |f| File.extname(f) == '.rb' }.each do |model| comment_lines model, /seems_rateable/ end end |
#drop_tables ⇒ Object
10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/generators/seems_rateable/uninstall_old/uninstall_old_generator.rb', line 10 def drop_tables (ActiveRecord::Migration.tables & %w[seems_rateable_rates seems_rateable_cached_ratings]).each do |table| migration_template "drop_#{table}_table.rb", "db/migrate/drop_#{table}_table" end rake 'db:migrate' if yes?('Run rake db:migrate? To drop seems_rateable tables') Dir.glob('db/migrate/*').keep_if { |f| f.include?('seems_rateable') }.each do |file| remove_file(file) end if yes?('Remove also remaining seems_rateable migration files?') end |
#remove_initializer ⇒ Object
22 23 24 |
# File 'lib/generators/seems_rateable/uninstall_old/uninstall_old_generator.rb', line 22 def remove_initializer remove_file 'config/initializers/seems_rateable.rb' end |
#remove_javascripts ⇒ Object
26 27 28 |
# File 'lib/generators/seems_rateable/uninstall_old/uninstall_old_generator.rb', line 26 def remove_javascripts remove_dir 'app/assets/javascripts/rateable/' end |
#remove_stylesheet_include_in_template ⇒ Object
30 31 32 33 34 35 36 37 38 39 |
# File 'lib/generators/seems_rateable/uninstall_old/uninstall_old_generator.rb', line 30 def remove_stylesheet_include_in_template %w[erb haml slim].each do |extension| file = 'app/views/layouts/application.html.' + extension if File.exists?(file) gsub_file file, /seems_rateable_stylesheet/, '' end end end |