about summary refs log tree commit diff
path: root/code2ny
blob: ed1752c46c85784deb44268da5d94508680352ae (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env ruby
# code2ny - convert fixme markers in source code to notyet todo lists

KEYWORDS = %w[todo hack xxx fixme bug]

kw = /\b#{Regexp.union(KEYWORDS.map(&:upcase))}\b.*/

single = ARGV.size <= 1

fn = nil
while line = gets
  if line =~ kw
    msg = $&
    msg.gsub!(/\s*\*\/.*/, '')  if line =~ /\/\*/

    if single
      puts "#{ARGF.filename}:#{ARGF.file.lineno}\t" \
           "- #{File.basename(ARGF.filename)}:#{msg}"
    else
      if ARGF.filename != fn
        fn = ARGF.filename
        puts "#{fn}:1\t- #{fn}:"
      end

      puts "#{fn}:#{ARGF.file.lineno}\t  - #{msg}"
    end
  end
end