class Utils::ConfigDir

def read(path, default: nil, &block)

Returns:
  • (String, nil) - the content of the file or the default value if

Other tags:
    Yield: -

Parameters:
  • default (String, nil) -- the default value to return if the file
  • path (String) -- the path to the file relative to the configuration
def read(path, default: nil, &block)
  full_path = join(path)
  if File.exist?(full_path)
    if block
      File.new(full_path, &block)
    else
      File.read(full_path, encoding: 'UTF-8')
    end
  else
    if default && block
      block.(StringIO.new(default))
    else
      default
    end
  end
end