class TodoLint::ConfigFile

Loads the config file (.todo-lint.yml)

Attributes

config_hash[R]

Hashed form of the config file .todo-lint.yml @return [Hash] @api private

config_options[R]

Options hash for all configurations specified by yaml file @return [Hash] @api private

starting_path[R]

Starting path for all files specified in config @return [String] @api private

Public Instance Methods

read_config_file(file) click to toggle source

Parses the config file and loads the options @api public @example ConfigFile.new.read_config_file('.todo-lint.yml') @return [Hash] parsed file-options

# File lib/todo_lint/config_file.rb, line 10
def read_config_file(file)
  @config_hash = YAML.load_file(file)
  @starting_path = File.expand_path(File.split(file).first)
  @config_options = {}
  load_tags
  load_file_exclusions
  load_extension_inclusions
  config_options
end

Private Instance Methods

load_extension_inclusions() click to toggle source

Adds the desired extensions to the config_options hash @api private @return [Hash]

# File lib/todo_lint/config_file.rb, line 51
def load_extension_inclusions
  return unless config_hash["Extensions"]
  config_options[:extensions] = config_hash["Extensions"]
end
load_file_exclusions() click to toggle source

Adds the exclude file options to the config_options hash @api private @return [Hash]

# File lib/todo_lint/config_file.rb, line 40
def load_file_exclusions
  return unless config_hash["Exclude Files"]
  config_options[:excluded_files] = []
  config_hash["Exclude Files"].each do |short_file|
    config_options[:excluded_files] << File.join(starting_path, short_file)
  end
end
load_tags() click to toggle source

Load the tags from the configuration file as DueDates

@return is irrelevant @api private

# File lib/todo_lint/config_file.rb, line 60
def load_tags
  config_options[:tags] = {}
  return unless config_hash["Tags"]
  config_hash["Tags"].each do |tag, due_date|
    unless due_date.is_a? Date
      raise ArgumentError, "#{due_date} is not a date"
    end

    config_options[:tags]["##{tag}"] = DueDate.new(due_date)
  end
end