Sha256: 6e662ae4f99f50f3d944aa0424669a4dd32d48badaffd88645c496b7019edbb9

Contents?: true

Size: 654 Bytes

Versions: 3

Compression:

Stored size: 654 Bytes

Contents

# frozen_string_literal: true

require 'seo_cache/page_caching'
require 'seo_cache/page_render'

module SeoCache
  class PopulateCache
    def initialize(host, paths, options = {})
      @host         = host
      @paths        = paths
      @page_render  = PageRender.new
      @page_caching = PageCaching.new

      @force_cache = options.fetch(:force_cache, false)
    end

    def perform
      @paths.each do |path|
        next if @page_caching.cache_exists?(path) && !@force_cache

        page_source = @page_render.get(@host + path)
        @page_caching.cache(page_source, path)
      end

      @page_render.close_connection
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
seo_cache-0.11.0 lib/seo_cache/populate_cache.rb
seo_cache-0.10.0 lib/seo_cache/populate_cache.rb
seo_cache-0.9.0 lib/seo_cache/populate_cache.rb