annotate lib/tasks/plugins.rake @ 8:0c83d98252d9 yuya

* Add custom repo prefix and proper auth realm, remove auth cache (seems like an unwise feature), pass DB handle around, various other bits of tidying
author Chris Cannam
date Thu, 12 Aug 2010 15:31:37 +0100
parents 513646585e45
children
rev   line source
Chris@0 1 require 'source_annotation_extractor'
Chris@0 2
Chris@0 3 # Modified version of the SourceAnnotationExtractor in railties
Chris@0 4 # Will search for runable code that uses <tt>call_hook</tt>
Chris@0 5 class PluginSourceAnnotationExtractor < SourceAnnotationExtractor
Chris@0 6 # Returns a hash that maps filenames under +dir+ (recursively) to arrays
Chris@0 7 # with their annotations. Only files with annotations are included, and only
Chris@0 8 # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
Chris@0 9 # are taken into account.
Chris@0 10 def find_in(dir)
Chris@0 11 results = {}
Chris@0 12
Chris@0 13 Dir.glob("#{dir}/*") do |item|
Chris@0 14 next if File.basename(item)[0] == ?.
Chris@0 15
Chris@0 16 if File.directory?(item)
Chris@0 17 results.update(find_in(item))
Chris@0 18 elsif item =~ /(hook|test)\.rb/
Chris@0 19 # skip
Chris@0 20 elsif item =~ /\.(builder|(r(?:b|xml|js)))$/
Chris@0 21 results.update(extract_annotations_from(item, /\s*(#{tag})\(?\s*(.*)$/))
Chris@0 22 elsif item =~ /\.(rhtml|erb)$/
Chris@0 23 results.update(extract_annotations_from(item, /<%=\s*\s*(#{tag})\(?\s*(.*?)\s*%>/))
Chris@0 24 end
Chris@0 25 end
Chris@0 26
Chris@0 27 results
Chris@0 28 end
Chris@0 29 end
Chris@0 30
Chris@0 31 namespace :redmine do
Chris@0 32 namespace :plugins do
Chris@0 33 desc "Enumerate all Redmine plugin hooks and their context parameters"
Chris@0 34 task :hook_list do
Chris@0 35 PluginSourceAnnotationExtractor.enumerate 'call_hook'
Chris@0 36 end
Chris@0 37 end
Chris@0 38 end