Class: Batteries::Tasks::Notes

Inherits:
Rake::TaskLib
  • Object
show all
Defined in:
lib/batteries/tasks/notes.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name = :notes, options: {}) {|_self| ... } ⇒ Notes

Returns a new instance of Notes.

Yields:

  • (_self)

Yield Parameters:



10
11
12
13
14
15
16
17
18
19
# 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

Instance Attribute Details

#descriptionObject

Returns the value of attribute description.



8
9
10
# File 'lib/batteries/tasks/notes.rb', line 8

def description
  @description
end

#excluded_dirsObject

Returns the value of attribute excluded_dirs.



8
9
10
# File 'lib/batteries/tasks/notes.rb', line 8

def excluded_dirs
  @excluded_dirs
end

#matchersObject

Returns the value of attribute matchers.



8
9
10
# File 'lib/batteries/tasks/notes.rb', line 8

def matchers
  @matchers
end

#nameObject

Returns the value of attribute name.



8
9
10
# File 'lib/batteries/tasks/notes.rb', line 8

def name
  @name
end

Instance Method Details

#defineObject



21
22
23
24
25
26
27
28
29
30
31
32
33
# 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