cacheinator_helper.rb 976 B

12345678910111213141516171819202122232425262728293031
  1. class CacheinatorHelper
  2. constructor :file_wrapper, :yaml_wrapper
  3. def diff_cached_config?(cached_filepath, hash)
  4. return true if ( not @file_wrapper.exist?(cached_filepath) )
  5. return true if ( (@file_wrapper.exist?(cached_filepath)) and (!(@yaml_wrapper.load(cached_filepath) == hash)) )
  6. return false
  7. end
  8. def diff_cached_defines?(cached_filepath, files)
  9. current_defines = COLLECTION_DEFINES_TEST_AND_VENDOR.reject(&:empty?)
  10. current_dependency = Hash[files.collect { |source| [source, current_defines.dup] }]
  11. if not @file_wrapper.exist?(cached_filepath)
  12. @yaml_wrapper.dump(cached_filepath, current_dependency)
  13. return false
  14. end
  15. dependencies = @yaml_wrapper.load(cached_filepath)
  16. if dependencies.values_at(*current_dependency.keys) != current_dependency.values
  17. dependencies.merge!(current_dependency)
  18. @yaml_wrapper.dump(cached_filepath, dependencies)
  19. return true
  20. end
  21. return false
  22. end
  23. end