Class: Nanoc3::OutdatednessChecker Private

Inherits:
Object
  • Object
show all
Extended by:
Memoization
Defined in:
lib/nanoc3/base/compilation/outdatedness_checker.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Responsible for determining whether an item or a layout is outdated.

Instance Method Summary collapse

Methods included from Memoization

memoize

Constructor Details

#initialize(params = {}) ⇒ OutdatednessChecker

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of OutdatednessChecker.

Parameters:

  • params (Hash) (defaults to: {})

    a customizable set of options

Options Hash (params):

  • :site (Nanoc3::Site) — default: nil

    The site this outdatedness checker belongs to.

  • :checksum_store (Nanoc3::ChecksumStore) — default: nil

    The checksum store where checksums of items, layouts, … are stored.

  • :dependency_tracker (Nanoc3::DependencyTracker) — default: nil

    The dependency tracker for the given site.



20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/nanoc3/base/compilation/outdatedness_checker.rb', line 20

def initialize(params={})
  @site = params[:site] or raise ArgumentError,
    'Nanoc3::OutdatednessChecker#initialize needs a :site parameter'
  @checksum_store = params[:checksum_store] or raise ArgumentError,
    'Nanoc3::OutdatednessChecker#initialize needs a :checksum_store parameter'
  @dependency_tracker = params[:dependency_tracker] or raise ArgumentError,
    'Nanoc3::OutdatednessChecker#initialize needs a :dependency_tracker parameter'

  @basic_outdatedness_reasons = {}
  @outdatedness_reasons = {}
  @objects_outdated_due_to_dependencies = {}
end

Instance Method Details

#outdated?(obj) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Checks whether the given object is outdated and therefore needs to be recompiled.

Parameters:

Returns:

  • (Boolean)

    true if the object is outdated, false otherwise



40
41
42
# File 'lib/nanoc3/base/compilation/outdatedness_checker.rb', line 40

def outdated?(obj)
  !outdatedness_reason_for(obj).nil?
end

#outdatedness_reason_for(obj) ⇒ Nanoc3::OutdatednessReasons::Generic?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Calculates the reason why the given object is outdated.

Parameters:

Returns:



51
52
53
54
55
56
57
# File 'lib/nanoc3/base/compilation/outdatedness_checker.rb', line 51

def outdatedness_reason_for(obj)
  reason = basic_outdatedness_reason_for(obj)
  if reason.nil? && outdated_due_to_dependencies?(obj)
    reason = Nanoc3::OutdatednessReasons::DependenciesOutdated
  end
  reason
end