class Lolita::Generators::UninstallGenerator
Constants
- INCLUDE_MODULE
- MODEL_METHOD
- ROUTE_NAME
Public Instance Methods
clear_models()
click to toggle source
Remove configuration include line and lolita block or single lolita method call. Block will be removed correctly if it starts with do and ends with end.
# File lib/generators/lolita/uninstall_generator.rb, line 30 def clear_models Dir[Rails.root.join("app","models","*.rb")].each do |file_name| matched = false gsub_file file_name, /^\s*include\s+#{INCLUDE_MODULE}.*/ do |match| matched = true match.clear match end if matched new_lines = [] File.open(file_name,"r") do |file| do_count = nil file.each_line do |line| if do_count.nil? if line.match(/^(\s*)lolita\s+(do)?/) if $2 == "do" do_count = 1 else do_count = 0 end else new_lines << line end elsif do_count > 0 if line.match(/(^|\s+)do(\s+|$)/) do_count +=1 elsif line.match(/(^|\s+)end(\s+|$)/) do_count -=1 end else new_lines << line end end end File.open(file_name,"w") do |file| new_lines.each do |line| file.puts(line) end end end end end
clear_routes()
click to toggle source
Remove all not-commented lines that begins with lolita_for
# File lib/generators/lolita/uninstall_generator.rb, line 21 def clear_routes gsub_file Rails.root.join("config","routes.rb"), /^\s*#{ROUTE_NAME}.*/ do |match| match.clear match end end
remove_initializer()
click to toggle source
Remove lolita initializer file
# File lib/generators/lolita/uninstall_generator.rb, line 11 def remove_initializer remove_file "config/initializers/lolita.rb" end
remove_tinymce()
click to toggle source
Remove tinymce.yml config file
# File lib/generators/lolita/uninstall_generator.rb, line 16 def remove_tinymce remove_file "config/tinymce.yml" end