aboutsummaryrefslogblamecommitdiffstats
path: root/actionview/lib/action_view/tasks/cache_digests.rake
blob: d30b3f77975b135107b4a47800195f4209dd0148 (plain) (tree)
1
2
3
4
5
6
7
8
9
                           
                                                                                               
                                           
                                                                                         
                                                                                                                                   

     
                                                                                                    
                                    
                                                                                         
                                                                                                                             

     

                          
                                         
       
 


                                              

     
namespace :cache_digests do
  desc "Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)"
  task nested_dependencies: :environment do
    abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present?
    puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:to_dep_map)
  end

  desc "Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)"
  task dependencies: :environment do
    abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present?
    puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:name)
  end

  class CacheDigests
    def self.template_name
      ENV["TEMPLATE"].split(".", 2).first
    end

    def self.finder
      ApplicationController.new.lookup_context
    end
  end
end