File Indexer

A simple file indexer that allows you to keep track of all the files in a directory while also extracting information about those files.

What it can do:

  • Keep an index of files in a directory
  • Associate an object with each file, storing e.g. id3-tag data, md5 digests, or anything else that is too costly to recompute over and over.
  • Keep the index synchronized to the file system by using the listen gem.
  • Use a persistent database file to avoid having to rescan the entire database every time the program loads.

Usage:

fi = FileIndexer.new(%w[~/music/], %w[mp3 wav], 'db') do |file|

  # Use a mp3 tag reading library such as taglib-ruby

  { artist: file.artist,
    title:  file.track,
    ...
  }
end

fi.watch

Documentation:

To generate documentation with e.g. yard, simply

cd file_indexer
yard server