DRY, move logic from rake to lib, build data if needed