class Fasterer::Config

Constants

EXCLUDE_PATHS_KEY
FILE_NAME
SPEEDUPS_KEY

Public Instance Methods

file() click to toggle source
# File lib/fasterer/config.rb, line 20
def file
  @file ||= begin
    return nil_file if file_location.nil?
    # Yaml.load_file returns false if the content is blank
    loaded = YAML.load_file(file_location) || nil_file
    # if the loaded file misses any of the two keys.
    loaded.merge!(nil_file) { |_k, v1, v2| v1 || v2 }
  end
end
file_location() click to toggle source
# File lib/fasterer/config.rb, line 30
def file_location
  @file_location ||=
    Pathname(Dir.pwd)
    .enum_for(:ascend)
    .map { |dir| File.join(dir.to_s, FILE_NAME) }
    .find { |f| File.exist?(f) }
end
ignored_files() click to toggle source
# File lib/fasterer/config.rb, line 15
def ignored_files
  @ignored_files ||=
    file[EXCLUDE_PATHS_KEY].flat_map { |path| Dir[path] }
end
ignored_speedups() click to toggle source
# File lib/fasterer/config.rb, line 10
def ignored_speedups
  @ignored_speedups ||=
    file[SPEEDUPS_KEY].select { |_, value| value == false }.keys.map(&:to_sym)
end
nil_file() click to toggle source
# File lib/fasterer/config.rb, line 38
def nil_file
  { SPEEDUPS_KEY => {}, EXCLUDE_PATHS_KEY => [] }
end