annotate .svn/pristine/b2/b2adc52778d4d3ebd2c0c35b234944a4234c7e40.svn-base @ 1519:afce8026aaeb redmine-2.4-integration

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