2017-07-23 11:36:41 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2013-09-26 15:19:19 -04:00
|
|
|
namespace :cache_digests do
|
2016-08-06 12:48:35 -04:00
|
|
|
desc "Lookup nested dependencies for TEMPLATE (like messages/show or comments/_comment.html)"
|
2016-08-06 13:36:34 -04:00
|
|
|
task nested_dependencies: :environment do
|
2016-08-06 12:48:35 -04:00
|
|
|
abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present?
|
2016-02-16 18:26:16 -05:00
|
|
|
puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:to_dep_map)
|
2013-09-26 15:19:19 -04:00
|
|
|
end
|
|
|
|
|
2016-08-06 12:48:35 -04:00
|
|
|
desc "Lookup first-level dependencies for TEMPLATE (like messages/show or comments/_comment.html)"
|
2016-08-06 13:36:34 -04:00
|
|
|
task dependencies: :environment do
|
2016-08-06 12:48:35 -04:00
|
|
|
abort "You must provide TEMPLATE for the task to run" unless ENV["TEMPLATE"].present?
|
2016-02-16 18:26:16 -05:00
|
|
|
puts JSON.pretty_generate ActionView::Digestor.tree(CacheDigests.template_name, CacheDigests.finder).children.map(&:name)
|
2014-06-10 07:34:14 -04:00
|
|
|
end
|
|
|
|
|
2014-09-26 14:55:40 -04:00
|
|
|
class CacheDigests
|
|
|
|
def self.template_name
|
2016-08-06 12:48:35 -04:00
|
|
|
ENV["TEMPLATE"].split(".", 2).first
|
2014-09-26 14:55:40 -04:00
|
|
|
end
|
2014-06-10 07:34:14 -04:00
|
|
|
|
2014-09-26 14:55:40 -04:00
|
|
|
def self.finder
|
|
|
|
ApplicationController.new.lookup_context
|
|
|
|
end
|
2013-09-26 15:19:19 -04:00
|
|
|
end
|
|
|
|
end
|