Skip to content
Browse files

Adds template dependencies rake task from cache_digests gem.

This adds the rake tasks `cache_digests:dependencies` and `cache_digests:nested_dependencies` from `cache_digests` gem.
  • Loading branch information...
1 parent 3f488d4 commit 1825f6fb601b5dffc5694dc83ddd123e76961f19 @tvdeyen tvdeyen committed
Showing with 21 additions and 0 deletions.
  1. +4 −0 actionview/lib/action_view/railtie.rb
  2. +17 −0 actionview/lib/action_view/tasks/dependencies.rake
View
4 actionview/lib/action_view/railtie.rb
@@ -48,5 +48,9 @@ class Railtie < Rails::Railtie # :nodoc:
ActionMailer::Base.send(:include, ActionView::Layouts)
end
end
+
+ rake_tasks do
+ load "action_view/tasks/dependencies.rake"
+ end
end
end
View
17 actionview/lib/action_view/tasks/dependencies.rake
@@ -0,0 +1,17 @@
+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?
+ template, format = ENV['TEMPLATE'].split(".")
+ format ||= :html
+ puts JSON.pretty_generate ActionView::Digestor.new(template, format, ApplicationController.new.lookup_context).nested_dependencies
+ 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?
+ template, format = ENV['TEMPLATE'].split(".")
+ format ||= :html
+ puts JSON.pretty_generate ActionView::Digestor.new(template, format, ApplicationController.new.lookup_context).dependencies
+ end
+end

0 comments on commit 1825f6f

Please sign in to comment.
Something went wrong with that request. Please try again.