comparison .svn/pristine/b2/b2adc52778d4d3ebd2c0c35b234944a4234c7e40.svn-base @ 909:cbb26bc654de redmine-1.3

Update to Redmine 1.3-stable branch (Redmine SVN rev 8964)
author Chris Cannam
date Fri, 24 Feb 2012 19:09:32 +0000
parents
children
comparison
equal deleted inserted replaced
908:c6c2cbd0afee 909:cbb26bc654de
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