class EacRubyUtils::Templates::File

def apply(variables_source)

+variables_provider+ A [Hash] or object which responds to +read_entry(entry_name)+.
def apply(variables_source)
  variables_provider = ::EacRubyUtils::Templates::VariableProviders.build(variables_source)
  variables.inject(content) do |a, e|
    a.gsub(variable_pattern(e), variables_provider.variable_value(e).to_s)
  end
end

def apply_to_file(variables_source, output_file_path)

def apply_to_file(variables_source, output_file_path)
  output_file_path.to_pathname.write(apply(variables_source))
end

def content_uncached

def content_uncached
  path.read
end

def sanitize_variable_name(variable_name)

def sanitize_variable_name(variable_name)
  variable_name.to_s.downcase
end

def variable_pattern(name)

def variable_pattern(name)
  /#{VARIABLE_DELIMITER}#{::Regexp.quote(name)}#{VARIABLE_DELIMITER}/i
end

def variables_uncached

def variables_uncached
  content.scan(VARIABLE_PATTERN).map(&:first).map do |name|
    sanitize_variable_name(name)
  end.to_set
end