Class: Nanoc::Core::BasicOutdatednessChecker

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/core/basic_outdatedness_checker.rb

Constant Summary collapse

Rules =
Nanoc::Core::OutdatednessRules
RULES_FOR_ITEM_REP =
[
  Rules::RulesModified,
  Rules::ContentModified,
  Rules::AttributesModified,
  Rules::NotWritten,
  Rules::CodeSnippetsModified,
  Rules::UsesAlwaysOutdatedFilter,
].freeze
RULES_FOR_LAYOUT =
[
  Rules::RulesModified,
  Rules::ContentModified,
  Rules::AttributesModified,
  Rules::UsesAlwaysOutdatedFilter,
].freeze
RULES_FOR_CONFIG =
[
  Rules::AttributesModified,
].freeze
RULES_FOR_ITEM_COLLECTION =
[
  Rules::ItemAdded,
].freeze
RULES_FOR_LAYOUT_COLLECTION =
[
  Rules::LayoutAdded,
].freeze
C_OBJ =
C_OBJ_MAYBE_REP =
C_ACTION_SEQUENCES =

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:) ⇒ BasicOutdatednessChecker

Returns a new instance of BasicOutdatednessChecker.



78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 78

def initialize(
  site:, checksum_store:, checksums:, dependency_store:,
  action_sequence_store:, action_sequences:, reps:
)
  @reps = reps
  @site = site
  @checksum_store = checksum_store
  @checksums = checksums
  @dependency_store = dependency_store
  @action_sequence_store = action_sequence_store
  @action_sequences = action_sequences

  # Memoize
  @_apply_rules = {}
end

Instance Attribute Details

#action_sequence_storeObject (readonly)

Returns the value of attribute action_sequence_store.



12
13
14
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 12

def action_sequence_store
  @action_sequence_store
end

#action_sequencesObject (readonly)

Returns the value of attribute action_sequences.



13
14
15
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 13

def action_sequences
  @action_sequences
end

#checksum_storeObject (readonly)

Returns the value of attribute checksum_store.



9
10
11
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 9

def checksum_store
  @checksum_store
end

#checksumsObject (readonly)

Returns the value of attribute checksums.



10
11
12
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 10

def checksums
  @checksums
end

#dependency_storeObject (readonly)

Returns the value of attribute dependency_store.



11
12
13
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 11

def dependency_store
  @dependency_store
end

#siteObject (readonly)

Returns the value of attribute site.



8
9
10
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 8

def site
  @site
end

Instance Method Details

#action_sequence_for(rep) ⇒ Object



115
116
117
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 115

def action_sequence_for(rep)
  @action_sequences.fetch(rep)
end

#outdatedness_status_for(obj) ⇒ Object



95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/nanoc/core/basic_outdatedness_checker.rb', line 95

def outdatedness_status_for(obj)
  case obj
  when Nanoc::Core::ItemRep
    apply_rules(RULES_FOR_ITEM_REP, obj)
  when Nanoc::Core::Item
    apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
  when Nanoc::Core::Layout
    apply_rules(RULES_FOR_LAYOUT, obj)
  when Nanoc::Core::Configuration
    apply_rules(RULES_FOR_CONFIG, obj)
  when Nanoc::Core::ItemCollection
    apply_rules(RULES_FOR_ITEM_COLLECTION, obj)
  when Nanoc::Core::LayoutCollection
    apply_rules(RULES_FOR_LAYOUT_COLLECTION, obj)
  else
    raise Nanoc::Core::Errors::InternalInconsistency,
          "do not know how to check outdatedness of #{obj.inspect}"
  end
end