Sha256: b4d219ab5a5973e62668eff82732980766f641100019ac777a630c969d538025

Contents?: true

Size: 460 Bytes

Versions: 1

Compression:

Stored size: 460 Bytes

Contents

module Feed2Gram
  Cache = Struct.new(:updated_at, :posted, :failed, :skipped, keyword_init: true) do
    def as_yaml
      to_h.transform_keys(&:to_s).to_yaml.gsub(/^---\n/, "")
    end
  end

  class LoadsCache
    def load(cache_path)
      if File.exist?(cache_path)
        yaml = YAML.load_file(cache_path, permitted_classes: [Time])
        Cache.new(**yaml)
      else
        Cache.new(posted: [], failed: [], skipped: [])
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
feed2gram-0.0.2 lib/feed2gram/loads_cache.rb