Method: Terraspace::Mod#cache_dir

Defined in:
lib/terraspace/mod.rb

#cache_dirObject

Full path with build_dir



113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
# File 'lib/terraspace/mod.rb', line 113

def cache_dir
  # config.build.cache_dir is a String or object that respond_to call. IE:
  #   :CACHE_ROOT/:REGION/:ENV/:BUILD_DIR
  #   CustomBuildDir.call
  # The call method should return a String pattern used for substitutions
  object = Terraspace.config.build.cache_dir
  pattern = if object.is_a?(String)
      object
    elsif object.respond_to?(:call)
      object.call(self)
    elsif object.public_instance_methods.include?(:call)
      instance = object.new
      instance.call(self)
    else
      raise "ERROR: config.build.cache_dir is not a String or responds to the .call method."
    end

  expander = Terraspace::Compiler::Expander.autodetect(self)
  expander.expansion(pattern) # pattern is a String that contains placeholders for substitutions
end