class Batteries::Tasks::Notes

Attributes

description[RW]
excluded_dirs[RW]
matchers[RW]
name[RW]

Public Class Methods

new(name = :notes, options: {}) { |self| ... } click to toggle source
# File lib/batteries/tasks/notes.rb, line 10
def initialize(name = :notes, options: {})
  @name           = options[:name] || name
  @description    = options.fetch(:description)   { "Notes" }
  @excluded_dirs  = options.fetch(:excluded_dirs) { %w(node_modules public) }
  @matchers       = options.fetch(:matchers)      { %w(FIXME TODO) }

  yield self if block_given?

  define
end

Public Instance Methods

define() click to toggle source
# File lib/batteries/tasks/notes.rb, line 21
def define
  desc @description
  task name do
    excludes = @excluded_dirs
               .map { |dir| "--exclude-dir '#{dir}'" }.join(" ")

    matchers = @matchers.map { |matcher| "-e '#{matcher}'" }.join(" ")

    sh "grep #{excludes} -n -R --color #{matchers} *"
  end

  self
end