Class: Issuesrc::TagFinders::BluntTagFinder
- Inherits:
-
Object
- Object
- Issuesrc::TagFinders::BluntTagFinder
- Defined in:
- lib/tag_finders/blunt_tag_finder.rb
Overview
A tag finder that doesn’t do any parsing; it just bluntly traverses the source code looking for things that look like comments.
It tries to skip comments inside strings.
Defined Under Namespace
Classes: CommentFinder
Constant Summary collapse
- DEFAULT_COMMENT_MARKERS =
[['//', "\n"], ['/*', '*/']]
- DEFAULT_STRING_MARKERS =
['"', "'"]
- COMMENTS_BY_LANG =
{ 'php' => [['//', "\n"], ['/*', '*/'], ['#', "\n"]], 'html' => [['<!--', '-->']], 'sql' => [['--', "\n"]], 'sh' => [['#', "\n"]], 'hs' => [['--', "\n"], ['{-', '-}']], 'py' => [['#', "\n"]], 'rb' => [['#', "\n"]], 'clj' => [[';', "\n"]], 'coffee' => [['#', "\n"]], }
- STRINGS_BY_LANG =
{ 'go' => ['"', "'", '`'], 'rs' => ['"'], 'hs' => ['"'], }
Instance Method Summary collapse
- #accepts?(file) ⇒ Boolean
- #find_tags(file) ⇒ Object
-
#initialize(tag_extractor, args, config) ⇒ BluntTagFinder
constructor
A new instance of BluntTagFinder.
Constructor Details
#initialize(tag_extractor, args, config) ⇒ BluntTagFinder
Returns a new instance of BluntTagFinder.
32 33 34 |
# File 'lib/tag_finders/blunt_tag_finder.rb', line 32 def initialize(tag_extractor, args, config) @tag_extractor = tag_extractor end |
Instance Method Details
#accepts?(file) ⇒ Boolean
36 37 38 |
# File 'lib/tag_finders/blunt_tag_finder.rb', line 36 def accepts?(file) true end |
#find_tags(file) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/tag_finders/blunt_tag_finder.rb', line 40 def (file) find_comments(file) do |comment, nline, pos| # A tag extractor extracts from a single line, whereas comments may # span several lines. nline_offset = 0 comment.split("\n").each do |line| tag = @tag_extractor.extract(line) if !tag.nil? tag.file = file tag.line = nline + nline_offset tag.begin_pos += pos tag.end_pos += pos yield tag end pos += line.length + 1 nline_offset += 1 end end end |