Skip to content

Latest commit

 

History

History
93 lines (57 loc) · 2.63 KB

README.rdoc

File metadata and controls

93 lines (57 loc) · 2.63 KB

Notes

<img src=“https://badge.fury.io/rb/notes.png” alt=“Gem Version” /> <img src=“https://travis-ci.org/vivien/notes.png” alt=“Build Status” /> <img src=“https://gemnasium.com/vivien/notes.png” alt=“Dependency Status” /> <img src=“https://codeclimate.com/github/vivien/notes.png” alt=“Code Climate” />

Stupidly grep tags in source code.

This gem provides a command line tool and a Ruby library to find tags in source code. Defaults tags are TODO, FIXME, and XXX. Custom tags can be found as well.

It’s kind of a generic version of the Ruby on Rails rake notes command, for any project/source.

Command line tool

Usage:

$ notes [options] [file...]

With no argument, notes will search recursively in the current directory. For details, see notes --help.

Examples:

$ notes
$ notes foo.h src/
$ notes --tag @@@
$ notes --no-{todo,fixme,xxx} --tag FOO

Integration with Git

A cool thing to do is to add a Git alias to parse every versionned files:

$ git config --global alias.n '!git ls-files | xargs notes'

Now, running git n in any Git repository will search notes in every files under version control!

Convention over configuration

No custom output.

It uses a grep-style display, which makes it easy to fit your needs. cut is great:

$ notes | cut -d: -f3,4-

will display TODO: /* add a cool feature */ instead of the normal output foo.c:42:TODO: /* add a cool feature */.

Notes won’t filter.

find, xargs are your friends:

$ find . -name '*.rb' | xargs notes

Or get the list of tagged files in the current directory with:

$ notes | cut -d: -f1 | sort -u

Installation

Notes is available on Rubygems.org and can be installed with:

$ [sudo] gem install notes

Or you can install from the source directory with:

$ rake install

The Notes library

The Notes module provides convenient methods.

require 'notes'

Notes.scan_file("foo.c") do |note|
  puts "#{note.tag} found at line #{note.line}!"
end

Notes can also extend an object to add a new method (see Notes#notes), or allow you to create your own scanner (see the Notes::Scanner).

For usage example of the library, you can have a look at the really basic Notes plugin for Redmine, at: github.com/vivien/redmine_notes

License

That’s free and friendly for sure! See the LICENSE file.