class Indexter::Config

Constants

DEFAULT_CONFIG_FILE

Attributes

config_file_path[R]
exclusions[R]
format[R]
suffixes[R]

Public Class Methods

new(config_file_path: DEFAULT_CONFIG_FILE) click to toggle source
# File lib/indexter/config.rb, line 20
def initialize(config_file_path: DEFAULT_CONFIG_FILE)
  @config_file_path = config_file_path
  configure if exists?
end

Public Instance Methods

exists?() click to toggle source
# File lib/indexter/config.rb, line 25
def exists?
  File.exists?(config_file_path)
end
to_yaml() click to toggle source
# File lib/indexter/config.rb, line 29
def to_yaml
  @data.to_yaml
end

Private Instance Methods

configure() click to toggle source
# File lib/indexter/config.rb, line 35
def configure
  @data = YAML.load_stream(File.read(config_file_path))
  return unless @data.any?

  load_format(@data)
  load_exclusions(@data)
  load_suffixes(@data)
end
load_exclusions(data) click to toggle source
# File lib/indexter/config.rb, line 48
def load_exclusions(data)
  @exclusions = data.first.fetch('exclusions', []).inject({}) do |acc, hash| 
    acc[hash['table']] = hash.fetch('columns', [])
    acc
  end
end
load_format(data) click to toggle source
# File lib/indexter/config.rb, line 44
def load_format(data)
  @format = data.first.fetch('format', nil)
end
load_suffixes(data) click to toggle source
# File lib/indexter/config.rb, line 55
def load_suffixes(data)
  @suffixes = data.first.fetch('suffixes', [])
end