Sha256: 8c15ba57bd42fa1484eb138dd2960f1820033580b98d9fe99b26b40294b81d24

Contents?: true

Size: 1.11 KB

Versions: 15

Compression:

Stored size: 1.11 KB

Contents

module Nanoc::Int
  # @api private
  class OutdatednessStore < ::Nanoc::Int::Store
    include Nanoc::Int::ContractsSupport

    contract C::KeywordArgs[site: C::Maybe[Nanoc::Int::Site], reps: Nanoc::Int::ItemRepRepo] => C::Any
    def initialize(site: nil, reps:)
      super(Nanoc::Int::Store.tmp_path_for(site: site, store_name: 'outdatedness'), 1)

      @outdated_reps = Set.new
      @all_reps = reps
    end

    contract Nanoc::Int::ItemRep => C::Bool
    def include?(obj)
      @outdated_reps.include?(obj)
    end

    contract Nanoc::Int::ItemRep => self
    def add(obj)
      @outdated_reps << obj
      self
    end

    contract Nanoc::Int::ItemRep => self
    def remove(obj)
      @outdated_reps.delete(obj)
      self
    end

    contract C::None => C::ArrayOf[Nanoc::Int::ItemRep]
    def to_a
      @outdated_reps.to_a
    end

    protected

    def data
      @outdated_reps.map(&:reference)
    end

    def data=(new_data)
      outdated_refs = Set.new(new_data)
      all_reps = Set.new(@all_reps)

      @outdated_reps = Set.new(all_reps.select { |rep| outdated_refs.include?(rep.reference) })
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
nanoc-4.7.9 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.8 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.7 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.6 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.5 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.4 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.3 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.2 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.1 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.7.0 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.6.4 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.6.3 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.6.2 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.6.1 lib/nanoc/base/repos/outdatedness_store.rb
nanoc-4.6.0 lib/nanoc/base/repos/outdatedness_store.rb