You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: cache_helper.rb
    path of file: ./repos/transpec/spec/support
    
    the code of the file until where you have to start completion: # encoding: utf-8

require 'digest/sha1'

module CacheHelper
  module_function

  def with_cache(key)
    cache_file_path = cache_file_path(key)

    if File
    
  def with_cached_dir(dirname)
    dir_path = File.join(cache_dir, dirname)

    cached = Dir.exist?(dir_path)
    FileUtils.mkdir_p(dir_path) unless cached

    Dir.chdir(dir_path) do
      yield cached
    end
  end