1 require 'source_annotation_extractor'
3 # Modified version of the SourceAnnotationExtractor in railties
4 # Will search for runable code that uses <tt>call_hook</tt>
5 class PluginSourceAnnotationExtractor < SourceAnnotationExtractor
6 # Returns a hash that maps filenames under +dir+ (recursively) to arrays
7 # with their annotations. Only files with annotations are included, and only
8 # those with extension +.builder+, +.rb+, +.rxml+, +.rjs+, +.rhtml+, and +.erb+
9 # are taken into account.
13 Dir.glob("#{dir}/*") do |item|
14 next if File.basename(item)[0] == ?.
16 if File.directory?(item)
17 results.update(find_in(item))
18 elsif item =~ /(hook|test)\.rb/
20 elsif item =~ /\.(builder|(r(?:b|xml|js)))$/
21 results.update(extract_annotations_from(item, /\s*(#{tag})\(?\s*(.*)$/))
22 elsif item =~ /\.(rhtml|erb)$/
23 results.update(extract_annotations_from(item, /<%=\s*\s*(#{tag})\(?\s*(.*?)\s*%>/))
33 desc "Enumerate all Redmine plugin hooks and their context parameters"
35 PluginSourceAnnotationExtractor.enumerate 'call_hook'