Class: TodoFind::Config

Inherits:
Object
  • Object
show all
Defined in:
lib/todofind/config.rb

Overview

Internal: A model for the configuration data.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ Config

Public: Create a new instance of Config

data - A hash of the data to be used

:labels - A list of labels to search for. Defaults are TODO and
          FIXME
:exclude_dirs - A list of directories to exclude from the search.
:exclude_files - A list of files to exclude from the search.

Examples:

config = TodoFind::Config.new({ :labels => ["TODO, "FIXME", "OHAI"]})


16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/todofind/config.rb', line 16

def initialize(data)
  new_data = {}
  data.each do |k, v|
    new_data[k.to_sym] = v
  end

  @labels = new_data[:labels] || %w{TODO FIXME}
  if !@labels.is_a? Array
    @labels = []
  end

  @exclude_dirs = new_data[:exclude_dirs] || []
  if !@exclude_dirs.is_a? Array
    @exclude_dirs = []
  end

  @exclude_files = new_data[:exclude_files] || []
  if !@exclude_files.is_a? Array
    @exclude_files = []
  end
end

Instance Attribute Details

#exclude_dirsObject (readonly)

Returns the value of attribute exclude_dirs.



4
5
6
# File 'lib/todofind/config.rb', line 4

def exclude_dirs
  @exclude_dirs
end

#exclude_filesObject (readonly)

Returns the value of attribute exclude_files.



4
5
6
# File 'lib/todofind/config.rb', line 4

def exclude_files
  @exclude_files
end

#labelsObject (readonly)

Returns the value of attribute labels.



4
5
6
# File 'lib/todofind/config.rb', line 4

def labels
  @labels
end