Class: Monologue::PostsSweeper
- Inherits:
-
ActionController::Caching::Sweeper
- Object
- ActionController::Caching::Sweeper
- Monologue::PostsSweeper
- Defined in:
- app/sweepers/monologue/posts_sweeper.rb
Instance Method Summary collapse
- #sweep(post) ⇒ Object (also: #after_create, #after_update, #after_destroy)
- #sweep_for_single_post(post) ⇒ Object
Instance Method Details
#sweep(post) ⇒ Object Also known as: after_create, after_update, after_destroy
4 5 6 7 8 9 10 |
# File 'app/sweepers/monologue/posts_sweeper.rb', line 4 def sweep(post) if ActionController::Base.perform_caching && Monologue::PageCache.enabled && Monologue::PageCache.wipe_enabled && Monologue::PageCache.wipe_after_save && (ActionController::Base.page_cache_directory != Rails.public_path) Monologue::TotalSweeper.wipe_all else sweep_for_single_post post end end |
#sweep_for_single_post(post) ⇒ Object
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 |
# File 'app/sweepers/monologue/posts_sweeper.rb', line 12 def sweep_for_single_post post return unless post.published root_path = Monologue::Engine.routes.url_helpers.root_path if root_path.nil? # TODO: why do I have to do this to make tests pass? There must be something much more clean to make tests pass page_cache_directory = Rails.public_path if page_cache_directory.nil? # TODO: we should not need this either... # post current_post_path = "#{page_cache_directory}#{root_path}#{post.url}.html" File.delete current_post_path if File.exists? current_post_path # tags = "#{page_cache_directory}#{root_path}tags" FileUtils.rm_rf # feed feed_file_path = "#{page_cache_directory}#{root_path}feed.rss" File.delete feed_file_path if File.exists? feed_file_path # root root_file_path = "#{page_cache_directory}#{root_path.chomp("/")}.html" root_file_path = "#{page_cache_directory}/index.html" if root_path.chomp("/") == "" # TODO: add test for that? It would need another dummy app mounted at root...? File.delete root_file_path if File.exists? root_file_path # paging FileUtils.rm_rf "#{page_cache_directory}/page" # remove pages end |