Upgrade to Rails 2.0.2
Upgraded to Rails 2.0.2, except that we maintain vendor/rails/actionpack/lib/action_controller/routing.rb from Rail 1.2.6 (at least for now), so that Routes don't change. We still get to enjoy Rails's many new features. Also fixed a bug in Chunk-handling: disable WikiWord processing in tags (for real this time).
This commit is contained in:
parent
0f6889e09f
commit
6873fc8026
1083 changed files with 52810 additions and 41058 deletions
62
vendor/rails/railties/lib/source_annotation_extractor.rb
vendored
Normal file
62
vendor/rails/railties/lib/source_annotation_extractor.rb
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
class SourceAnnotationExtractor
|
||||
class Annotation < Struct.new(:line, :tag, :text)
|
||||
def to_s(options={})
|
||||
s = "[%3d] " % line
|
||||
s << "[#{tag}] " if options[:tag]
|
||||
s << text
|
||||
end
|
||||
end
|
||||
|
||||
def self.enumerate(tag, options={})
|
||||
extractor = new(tag)
|
||||
extractor.display(extractor.find, options)
|
||||
end
|
||||
|
||||
attr_reader :tag
|
||||
|
||||
def initialize(tag)
|
||||
@tag = tag
|
||||
end
|
||||
|
||||
def find(dirs=%w(app lib test))
|
||||
dirs.inject({}) { |h, dir| h.update(find_in(dir)) }
|
||||
end
|
||||
|
||||
def find_in(dir)
|
||||
results = {}
|
||||
|
||||
Dir.glob("#{dir}/*") do |item|
|
||||
next if File.basename(item)[0] == ?.
|
||||
|
||||
if File.directory?(item)
|
||||
results.update(find_in(item))
|
||||
elsif item =~ /\.(builder|(r(?:b|xml|js)))$/
|
||||
results.update(extract_annotations_from(item, /#\s*(#{tag}):?\s*(.*)$/))
|
||||
elsif item =~ /\.(rhtml|erb)$/
|
||||
results.update(extract_annotations_from(item, /<%\s*#\s*(#{tag}):?\s*(.*?)\s*%>/))
|
||||
end
|
||||
end
|
||||
|
||||
results
|
||||
end
|
||||
|
||||
def extract_annotations_from(file, pattern)
|
||||
lineno = 0
|
||||
result = File.readlines(file).inject([]) do |list, line|
|
||||
lineno += 1
|
||||
next list unless line =~ pattern
|
||||
list << Annotation.new(lineno, $1, $2)
|
||||
end
|
||||
result.empty? ? {} : { file => result }
|
||||
end
|
||||
|
||||
def display(results, options={})
|
||||
results.keys.sort.each do |file|
|
||||
puts "#{file}:"
|
||||
results[file].each do |note|
|
||||
puts " * #{note.to_s(options)}"
|
||||
end
|
||||
puts
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue