跳至内容 跳至搜索
方法
D
E
R
T

类公共方法

directories()

# File railties/lib/rails/source_annotation_extractor.rb, line 72
def self.directories
  @@directories ||= %w(app config db lib test)
end

extensions()

# File railties/lib/rails/source_annotation_extractor.rb, line 92
def self.extensions
  @@extensions ||= {}
end

register_directories(*dirs)

注册要包含的额外目录

Rails::SourceAnnotationExtractor::Annotation.register_directories("spec", "another")
# File railties/lib/rails/source_annotation_extractor.rb, line 78
def self.register_directories(*dirs)
  directories.push(*dirs)
end

register_extensions(*exts, &block)

注册新的 Annotations File 扩展

Rails::SourceAnnotationExtractor::Annotation.register_extensions("css", "scss", "sass", "less", "js") { |tag| /\/\/\s*(#{tag}):?\s*(.*)$/ }
# File railties/lib/rails/source_annotation_extractor.rb, line 98
def self.register_extensions(*exts, &block)
  extensions[/\.(#{exts.join("|")})$/] = block
end

register_tags(*additional_tags)

注册额外的标签

Rails::SourceAnnotationExtractor::Annotation.register_tags("TESTME", "DEPRECATEME")
# File railties/lib/rails/source_annotation_extractor.rb, line 88
def self.register_tags(*additional_tags)
  tags.push(*additional_tags)
end

tags()

# File railties/lib/rails/source_annotation_extractor.rb, line 82
def self.tags
  @@tags ||= %w(OPTIMIZE FIXME TODO)
end

实例公共方法

to_s(options = {})

返回注解的表示形式,如下所示

[126] [TODO] This algorithm is simple and clearly correct, make it faster.

如果 options 有一个标志 :tag,则标签将如上例所示。否则字符串只包含行和文本。

# File railties/lib/rails/source_annotation_extractor.rb, line 124
def to_s(options = {})
  s = +"[#{line.to_s.rjust(options[:indent])}] "
  s << "[#{tag}] " if options[:tag]
  s << text
end