comparison lib/tasks/plugins.rake @ 0:513646585e45

* Import Redmine trunk SVN rev 3859
author Chris Cannam
date Fri, 23 Jul 2010 15:52:44 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:513646585e45
1 require 'source_annotation_extractor'
2
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.
10 def find_in(dir)
11 results = {}
12
13 Dir.glob("#{dir}/*") do |item|
14 next if File.basename(item)[0] == ?.
15
16 if File.directory?(item)
17 results.update(find_in(item))
18 elsif item =~ /(hook|test)\.rb/
19 # skip
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*%>/))
24 end
25 end
26
27 results
28 end
29 end
30
31 namespace :redmine do
32 namespace :plugins do
33 desc "Enumerate all Redmine plugin hooks and their context parameters"
34 task :hook_list do
35 PluginSourceAnnotationExtractor.enumerate 'call_hook'
36 end
37 end
38 end