nanoc-core 4.14.6 → 4.14.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nanoc/core/action_sequence.rb +1 -1
  3. data/lib/nanoc/core/action_sequence_builder.rb +12 -4
  4. data/lib/nanoc/core/action_sequence_store.rb +8 -5
  5. data/lib/nanoc/core/assertions.rb +12 -2
  6. data/lib/nanoc/core/basic_outdatedness_checker.rb +26 -10
  7. data/lib/nanoc/core/binary_compiled_content_cache.rb +24 -10
  8. data/lib/nanoc/core/checksum_collection.rb +7 -2
  9. data/lib/nanoc/core/checksum_store.rb +26 -9
  10. data/lib/nanoc/core/checksummer.rb +63 -32
  11. data/lib/nanoc/core/compilation_stages/build_reps.rb +7 -2
  12. data/lib/nanoc/core/compilation_stages/calculate_checksums.rb +2 -0
  13. data/lib/nanoc/core/compilation_stages/cleanup.rb +8 -2
  14. data/lib/nanoc/core/compilation_stages/compile_reps.rb +78 -36
  15. data/lib/nanoc/core/compilation_stages/determine_outdatedness.rb +2 -0
  16. data/lib/nanoc/core/compilation_stages/forget_outdated_dependencies.rb +5 -1
  17. data/lib/nanoc/core/compilation_stages/load_stores.rb +6 -1
  18. data/lib/nanoc/core/compilation_stages/postprocess.rb +2 -0
  19. data/lib/nanoc/core/compilation_stages/preprocess.rb +12 -3
  20. data/lib/nanoc/core/compilation_stages/prune.rb +6 -1
  21. data/lib/nanoc/core/compilation_stages/store_post_compilation_state.rb +2 -0
  22. data/lib/nanoc/core/compilation_stages/store_pre_compilation_state.rb +6 -1
  23. data/lib/nanoc/core/compiled_content_cache.rb +7 -2
  24. data/lib/nanoc/core/compiled_content_repo.rb +13 -5
  25. data/lib/nanoc/core/compiler.rb +12 -3
  26. data/lib/nanoc/core/compiler_loader.rb +13 -4
  27. data/lib/nanoc/core/config_loader.rb +14 -4
  28. data/lib/nanoc/core/configuration.rb +35 -14
  29. data/lib/nanoc/core/content.rb +5 -1
  30. data/lib/nanoc/core/context.rb +3 -3
  31. data/lib/nanoc/core/contracts_support.rb +26 -8
  32. data/lib/nanoc/core/core_ext/hash.rb +12 -2
  33. data/lib/nanoc/core/data_source.rb +22 -6
  34. data/lib/nanoc/core/dependency.rb +8 -2
  35. data/lib/nanoc/core/dependency_props.rb +27 -8
  36. data/lib/nanoc/core/dependency_store.rb +55 -22
  37. data/lib/nanoc/core/dependency_tracker.rb +20 -4
  38. data/lib/nanoc/core/directed_graph.rb +21 -6
  39. data/lib/nanoc/core/document.rb +4 -1
  40. data/lib/nanoc/core/errors.rb +45 -12
  41. data/lib/nanoc/core/executor.rb +26 -9
  42. data/lib/nanoc/core/feature.rb +2 -1
  43. data/lib/nanoc/core/filter.rb +27 -11
  44. data/lib/nanoc/core/identifiable_collection.rb +2 -1
  45. data/lib/nanoc/core/identifier.rb +23 -8
  46. data/lib/nanoc/core/in_memory_data_source.rb +3 -1
  47. data/lib/nanoc/core/item_collection.rb +1 -1
  48. data/lib/nanoc/core/item_rep_builder.rb +14 -5
  49. data/lib/nanoc/core/item_rep_router.rb +27 -13
  50. data/lib/nanoc/core/item_rep_writer.rb +28 -5
  51. data/lib/nanoc/core/layout_collection.rb +1 -1
  52. data/lib/nanoc/core/mutable_document_view_mixin.rb +2 -4
  53. data/lib/nanoc/core/outdatedness_checker.rb +170 -95
  54. data/lib/nanoc/core/outdatedness_reasons.rb +45 -16
  55. data/lib/nanoc/core/outdatedness_rules/attributes_modified.rb +24 -10
  56. data/lib/nanoc/core/outdatedness_rules/item_added.rb +9 -4
  57. data/lib/nanoc/core/outdatedness_rules/layout_added.rb +9 -4
  58. data/lib/nanoc/core/outdatedness_rules/not_written.rb +7 -2
  59. data/lib/nanoc/core/outdatedness_rules/rules_modified.rb +14 -6
  60. data/lib/nanoc/core/outdatedness_rules/uses_always_outdated_filter.rb +1 -1
  61. data/lib/nanoc/core/outdatedness_store.rb +7 -1
  62. data/lib/nanoc/core/pattern.rb +4 -1
  63. data/lib/nanoc/core/prefixed_data_source.rb +6 -2
  64. data/lib/nanoc/core/processing_actions/filter.rb +2 -0
  65. data/lib/nanoc/core/processing_actions/layout.rb +2 -0
  66. data/lib/nanoc/core/processing_actions/snapshot.rb +12 -3
  67. data/lib/nanoc/core/pruner.rb +11 -3
  68. data/lib/nanoc/core/regexp_pattern.rb +1 -1
  69. data/lib/nanoc/core/site.rb +10 -4
  70. data/lib/nanoc/core/site_loader.rb +25 -17
  71. data/lib/nanoc/core/store.rb +33 -6
  72. data/lib/nanoc/core/string_pattern.rb +1 -1
  73. data/lib/nanoc/core/textual_compiled_content_cache.rb +60 -5
  74. data/lib/nanoc/core/textual_content.rb +4 -1
  75. data/lib/nanoc/core/version.rb +1 -1
  76. data/lib/nanoc/core/view_context_for_compilation.rb +6 -2
  77. data/lib/nanoc/core/views/basic_item_rep_collection_view.rb +11 -4
  78. data/lib/nanoc/core/views/basic_item_rep_view.rb +9 -2
  79. data/lib/nanoc/core/views/basic_item_view.rb +17 -9
  80. data/lib/nanoc/core/views/compilation_item_rep_view.rb +12 -4
  81. data/lib/nanoc/core/views/compilation_item_view.rb +3 -1
  82. data/lib/nanoc/core/views/identifiable_collection_view.rb +17 -5
  83. data/lib/nanoc/core/views/mutable_item_collection_view.rb +5 -2
  84. data/lib/nanoc/core/views/mutable_layout_collection_view.rb +5 -2
  85. data/lib/nanoc/core/views/post_compile_item_view.rb +3 -1
  86. data/lib/nanoc/core.rb +4 -4
  87. metadata +2 -8
  88. data/lib/nanoc/core/compilation_phases/abstract.rb +0 -48
  89. data/lib/nanoc/core/compilation_phases/cache.rb +0 -28
  90. data/lib/nanoc/core/compilation_phases/mark_done.rb +0 -23
  91. data/lib/nanoc/core/compilation_phases/notify.rb +0 -22
  92. data/lib/nanoc/core/compilation_phases/recalculate.rb +0 -59
  93. data/lib/nanoc/core/compilation_phases/write.rb +0 -31
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c8175e70512a2b971b62c60b31c650458e8fcef2aeb7318ccb6dbd9e76d3a25d
4
- data.tar.gz: '03478e1061f3b8324435731239def3183d77054e3bbc5b3ac3f6d5e2ab9786a7'
3
+ metadata.gz: '0842ed49f126a6c02412de3835dba441e69d4fb8d2fb8cf4bcb05dc56c8e07f6'
4
+ data.tar.gz: 740b42972643b02ec8ee939e1ccfbf3e4ce783e9098b519d1c7c38e8a8409f00
5
5
  SHA512:
6
- metadata.gz: 557b852833a1f73919076424047436280d3f7f1d3bd8e319bed4485e0828ffed2ab134afa8300b30f289e940edabc64b2dc1f8bb24077e0420d7408c2c2acfb7
7
- data.tar.gz: d5bfd697e976849b4cc5760817c257f3b032bd68b196dc3ac4d1b74ad9c57a6c80cfb262ac8f53fb86ad036e943b7c65435e5e548e70eb5d23979690732528e9
6
+ metadata.gz: 1d7eca3780c7750e200efcd31ab4490c830ada047556b39371542739579b743a10bb4391429cda7e8be5e326bf77efd64e2dce4d109215dd63f736cb0b8cdb49
7
+ data.tar.gz: a07b12e89289d45e848c884a5c6677a23f46d8a64433617d8e9beee27c81bf23d0c8ca2721b950fd0c78046c9b97c566035d453a068862da0d661aa363f17a4d
@@ -25,7 +25,7 @@ module Nanoc
25
25
 
26
26
  # contract C::None => C::ArrayOf[Nanoc::Core::ProcessingAction]
27
27
  def snapshot_actions
28
- @actions.select { |a| a.is_a?(Nanoc::Core::ProcessingActions::Snapshot) }
28
+ @actions.grep(Nanoc::Core::ProcessingActions::Snapshot)
29
29
  end
30
30
 
31
31
  # contract C::None => Array
@@ -11,7 +11,9 @@ module Nanoc
11
11
 
12
12
  contract Nanoc::Core::ItemRep, Symbol => C::Any
13
13
  def initialize(rep, snapshot)
14
- super("Attempted to create a snapshot with a duplicate name #{snapshot.inspect} for the item rep #{rep}")
14
+ super(
15
+ 'Attempted to create a snapshot with a duplicate name ' \
16
+ "#{snapshot.inspect} for the item rep #{rep}")
15
17
  end
16
18
  end
17
19
 
@@ -27,19 +29,25 @@ module Nanoc
27
29
 
28
30
  contract Symbol, Hash => self
29
31
  def add_filter(filter_name, params)
30
- @actions << Nanoc::Core::ProcessingActions::Filter.new(filter_name, params)
32
+ @actions << Nanoc::Core::ProcessingActions::Filter.new(
33
+ filter_name, params
34
+ )
31
35
  self
32
36
  end
33
37
 
34
38
  contract String, C::Maybe[Hash] => self
35
39
  def add_layout(layout_identifier, params)
36
- @actions << Nanoc::Core::ProcessingActions::Layout.new(layout_identifier, params)
40
+ @actions << Nanoc::Core::ProcessingActions::Layout.new(
41
+ layout_identifier, params
42
+ )
37
43
  self
38
44
  end
39
45
 
40
46
  def add_snapshot(snapshot_name, path, rep)
41
47
  will_add_snapshot(snapshot_name, rep)
42
- @actions << Nanoc::Core::ProcessingActions::Snapshot.new([snapshot_name], path ? [path] : [])
48
+ @actions << Nanoc::Core::ProcessingActions::Snapshot.new(
49
+ [snapshot_name], path ? [path] : []
50
+ )
43
51
  self
44
52
  end
45
53
 
@@ -11,21 +11,24 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config:, store_name: 'rule_memory'), 2)
14
+ super(
15
+ self.class.tmp_path_for(config:, store_name: 'rule_memory'),
16
+ 2,
17
+ )
15
18
 
16
19
  @action_sequences = {}
17
20
  end
18
21
 
19
- # @param [Nanoc::Core::ItemRep, Nanoc::Core::Layout] obj The item representation or
20
- # the layout to get the action sequence for
22
+ # @param [Nanoc::Core::ItemRep, Nanoc::Core::Layout] obj The item
23
+ # representation or the layout to get the action sequence for
21
24
  #
22
25
  # @return [Array] The action sequence for the given object
23
26
  def [](obj)
24
27
  @action_sequences[obj.reference]
25
28
  end
26
29
 
27
- # @param [Nanoc::Core::ItemRep, Nanoc::Core::Layout] obj The item representation or
28
- # the layout to set the action sequence for
30
+ # @param [Nanoc::Core::ItemRep, Nanoc::Core::Layout] obj The item
31
+ # representation or the layout to set the action sequence for
29
32
  #
30
33
  # @param [Array] action_sequence The new action sequence to be stored
31
34
  #
@@ -25,8 +25,16 @@ module Nanoc
25
25
  class AllItemRepsHaveCompiledContent < Nanoc::Core::Assertions::Base
26
26
  include Nanoc::Core::ContractsSupport
27
27
 
28
- contract C::KeywordArgs[compiled_content_cache: C::Or[Nanoc::Core::CompiledContentCache, Nanoc::Core::TextualCompiledContentCache], item_reps: Nanoc::Core::ItemRepRepo] => C::Any
28
+ contract C::KeywordArgs[
29
+ compiled_content_cache: C::Or[
30
+ Nanoc::Core::CompiledContentCache,
31
+ Nanoc::Core::TextualCompiledContentCache,
32
+ ],
33
+ item_reps: Nanoc::Core::ItemRepRepo,
34
+ ] => C::Any
29
35
  def initialize(compiled_content_cache:, item_reps:)
36
+ super()
37
+
30
38
  @compiled_content_cache = compiled_content_cache
31
39
  @item_reps = item_reps
32
40
  end
@@ -34,7 +42,7 @@ module Nanoc
34
42
  contract C::None => C::Bool
35
43
  def call
36
44
  @item_reps.all? do |rep|
37
- @compiled_content_cache[rep]
45
+ @compiled_content_cache.include?(rep)
38
46
  end
39
47
  end
40
48
  end
@@ -44,6 +52,8 @@ module Nanoc
44
52
 
45
53
  contract C::KeywordArgs[path: String] => C::Any
46
54
  def initialize(path:)
55
+ super()
56
+
47
57
  @path = path
48
58
  end
49
59
 
@@ -16,7 +16,6 @@ module Nanoc
16
16
 
17
17
  RULES_FOR_ITEM_REP =
18
18
  [
19
- Rules::ItemAdded,
20
19
  Rules::RulesModified,
21
20
  Rules::ContentModified,
22
21
  Rules::AttributesModified,
@@ -27,7 +26,6 @@ module Nanoc
27
26
 
28
27
  RULES_FOR_LAYOUT =
29
28
  [
30
- Rules::LayoutAdded,
31
29
  Rules::RulesModified,
32
30
  Rules::ContentModified,
33
31
  Rules::AttributesModified,
@@ -39,6 +37,16 @@ module Nanoc
39
37
  Rules::AttributesModified,
40
38
  ].freeze
41
39
 
40
+ RULES_FOR_ITEM_COLLECTION =
41
+ [
42
+ Rules::ItemAdded,
43
+ ].freeze
44
+
45
+ RULES_FOR_LAYOUT_COLLECTION =
46
+ [
47
+ Rules::LayoutAdded,
48
+ ].freeze
49
+
42
50
  C_OBJ = C::Or[
43
51
  Nanoc::Core::Item,
44
52
  Nanoc::Core::ItemRep,
@@ -67,7 +75,10 @@ module Nanoc
67
75
  action_sequences: C_ACTION_SEQUENCES,
68
76
  reps: Nanoc::Core::ItemRepRepo,
69
77
  ] => C::Any
70
- def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
78
+ def initialize(
79
+ site:, checksum_store:, checksums:, dependency_store:,
80
+ action_sequence_store:, action_sequences:, reps:
81
+ )
71
82
  @reps = reps
72
83
  @site = site
73
84
  @checksum_store = checksum_store
@@ -91,12 +102,13 @@ module Nanoc
91
102
  apply_rules(RULES_FOR_LAYOUT, obj)
92
103
  when Nanoc::Core::Configuration
93
104
  apply_rules(RULES_FOR_CONFIG, obj)
94
- when Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection
95
- # Collections are never outdated. Objects inside them might be,
96
- # however.
97
- apply_rules([], obj)
105
+ when Nanoc::Core::ItemCollection
106
+ apply_rules(RULES_FOR_ITEM_COLLECTION, obj)
107
+ when Nanoc::Core::LayoutCollection
108
+ apply_rules(RULES_FOR_LAYOUT_COLLECTION, obj)
98
109
  else
99
- raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
110
+ raise Nanoc::Core::Errors::InternalInconsistency,
111
+ "do not know how to check outdatedness of #{obj.inspect}"
100
112
  end
101
113
  end
102
114
 
@@ -106,7 +118,10 @@ module Nanoc
106
118
 
107
119
  private
108
120
 
109
- contract C::ArrayOf[Class], C_OBJ_MAYBE_REP, Nanoc::Core::OutdatednessStatus => C::Maybe[Nanoc::Core::OutdatednessStatus]
121
+ contract C::ArrayOf[Class],
122
+ C_OBJ_MAYBE_REP,
123
+ Nanoc::Core::OutdatednessStatus =>
124
+ C::Maybe[Nanoc::Core::OutdatednessStatus]
110
125
  def apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new)
111
126
  @_apply_rules[obj] ||=
112
127
  rules.inject(status) do |acc, rule|
@@ -123,7 +138,8 @@ module Nanoc
123
138
  end
124
139
  end
125
140
 
126
- contract C::ArrayOf[Class], C::ArrayOf[C_OBJ_MAYBE_REP] => C::Maybe[Nanoc::Core::OutdatednessStatus]
141
+ contract C::ArrayOf[Class], C::ArrayOf[C_OBJ_MAYBE_REP] =>
142
+ C::Maybe[Nanoc::Core::OutdatednessStatus]
127
143
  def apply_rules_multi(rules, objs)
128
144
  objs.inject(Nanoc::Core::OutdatednessStatus.new) do |acc, elem|
129
145
  apply_rules(rules, elem, acc)
@@ -11,12 +11,19 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config:, store_name: 'binary_content'), 3)
14
+ super(
15
+ self.class.tmp_path_for(
16
+ config:,
17
+ store_name: 'binary_content',
18
+ ),
19
+ 3,
20
+ )
15
21
 
16
22
  @cache = {}
17
23
  end
18
24
 
19
- contract Nanoc::Core::ItemRep => C::Maybe[C::HashOf[Symbol => Nanoc::Core::Content]]
25
+ contract Nanoc::Core::ItemRep =>
26
+ C::Maybe[C::HashOf[Symbol => Nanoc::Core::Content]]
20
27
  # Returns the cached compiled content for the given item representation.
21
28
  #
22
29
  # This cached compiled content is a hash where the keys are the snapshot
@@ -38,7 +45,9 @@ module Nanoc
38
45
  item_cache.key?(rep.name)
39
46
  end
40
47
 
41
- contract Nanoc::Core::ItemRep, C::HashOf[Symbol => Nanoc::Core::BinaryContent] => C::HashOf[Symbol => Nanoc::Core::Content]
48
+ contract Nanoc::Core::ItemRep,
49
+ C::HashOf[Symbol => Nanoc::Core::BinaryContent] =>
50
+ C::HashOf[Symbol => Nanoc::Core::Content]
42
51
  # Sets the compiled content for the given representation.
43
52
  #
44
53
  # This cached compiled content is a hash where the keys are the snapshot
@@ -50,8 +59,11 @@ module Nanoc
50
59
 
51
60
  content.each do |snapshot, binary_content|
52
61
  # Check
53
- if Nanoc::Core::ContractsSupport.enabled? && !File.file?(binary_content.filename)
54
- raise Nanoc::Core::Errors::InternalInconsistency, "Binary content at #{binary_content.filename.inspect} does not exist, but is expected to."
62
+ if Nanoc::Core::ContractsSupport.enabled? &&
63
+ !File.file?(binary_content.filename)
64
+ raise Nanoc::Core::Errors::InternalInconsistency,
65
+ "Binary content at #{binary_content.filename.inspect} " \
66
+ 'does not exist, but is expected to.'
55
67
  end
56
68
 
57
69
  filename = build_filename(rep, snapshot)
@@ -99,13 +111,12 @@ module Nanoc
99
111
  private
100
112
 
101
113
  def dirname
102
- filename + '_data'
114
+ "#{filename}_data"
103
115
  end
104
116
 
105
117
  def string_to_path_component(string)
106
- string.gsub(/[^a-zA-Z0-9]+/, '_') +
107
- '-' +
108
- Digest::SHA1.hexdigest(string)[0..9]
118
+ "#{string.gsub(/[^a-zA-Z0-9]+/, '_')}-" \
119
+ "#{Digest::SHA1.hexdigest(string)[0..9]}"
109
120
  end
110
121
 
111
122
  def dirname_for_item_identifier(item_identifier)
@@ -141,7 +152,10 @@ module Nanoc
141
152
  begin
142
153
  res = Clonefile.always(from, to)
143
154
  return if res
144
- rescue Clonefile::UnsupportedPlatform, Errno::ENOTSUP, Errno::EXDEV, Errno::EINVAL
155
+ rescue Clonefile::UnsupportedPlatform,
156
+ Errno::ENOTSUP,
157
+ Errno::EXDEV,
158
+ Errno::EINVAL
145
159
  end
146
160
  end
147
161
 
@@ -5,7 +5,11 @@ module Nanoc
5
5
  class ChecksumCollection
6
6
  include Nanoc::Core::ContractsSupport
7
7
 
8
- c_obj = C::Or[Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration, Nanoc::Core::CodeSnippet]
8
+ c_obj = C::Or[
9
+ Nanoc::Core::Item,
10
+ Nanoc::Core::Layout,
11
+ Nanoc::Core::Configuration,
12
+ Nanoc::Core::CodeSnippet]
9
13
 
10
14
  def initialize(checksums)
11
15
  @checksums = checksums
@@ -25,7 +29,8 @@ module Nanoc
25
29
 
26
30
  contract c_obj => C::Maybe[C::HashOf[Symbol, String]]
27
31
  def attributes_checksum_for(obj)
28
- @_attribute_checksums[obj] ||= @checksums[[obj.reference, :each_attribute]]
32
+ @_attribute_checksums[obj] ||=
33
+ @checksums[[obj.reference, :each_attribute]]
29
34
  end
30
35
 
31
36
  def to_h
@@ -12,11 +12,23 @@ module Nanoc
12
12
  attr_writer :checksums
13
13
  attr_accessor :objects
14
14
 
15
- c_obj = C::Or[Nanoc::Core::Item, Nanoc::Core::Layout, Nanoc::Core::Configuration, Nanoc::Core::CodeSnippet]
16
-
17
- contract C::KeywordArgs[config: Nanoc::Core::Configuration, objects: C::IterOf[c_obj]] => C::Any
15
+ c_obj = C::Or[
16
+ Nanoc::Core::Item,
17
+ Nanoc::Core::Layout,
18
+ Nanoc::Core::Configuration,
19
+ Nanoc::Core::CodeSnippet]
20
+
21
+ contract C::KeywordArgs[
22
+ config: Nanoc::Core::Configuration,
23
+ objects: C::IterOf[c_obj]] => C::Any
18
24
  def initialize(config:, objects:)
19
- super(Nanoc::Core::Store.tmp_path_for(config:, store_name: 'checksums'), 3)
25
+ super(
26
+ self.class.tmp_path_for(
27
+ config:,
28
+ store_name: 'checksums',
29
+ ),
30
+ 3,
31
+ )
20
32
 
21
33
  @objects = objects
22
34
 
@@ -33,11 +45,14 @@ module Nanoc
33
45
  contract c_obj => self
34
46
  def add(obj)
35
47
  if obj.is_a?(Nanoc::Core::Document)
36
- @checksums[[obj.reference, :content]] = Nanoc::Core::Checksummer.calc_for_content_of(obj)
48
+ @checksums[[obj.reference, :content]] =
49
+ Nanoc::Core::Checksummer.calc_for_content_of(obj)
37
50
  end
38
51
 
39
- if obj.is_a?(Nanoc::Core::Document) || obj.is_a?(Nanoc::Core::Configuration)
40
- @checksums[[obj.reference, :each_attribute]] = Nanoc::Core::Checksummer.calc_for_each_attribute_of(obj)
52
+ if obj.is_a?(Nanoc::Core::Document) ||
53
+ obj.is_a?(Nanoc::Core::Configuration)
54
+ @checksums[[obj.reference, :each_attribute]] =
55
+ Nanoc::Core::Checksummer.calc_for_each_attribute_of(obj)
41
56
  end
42
57
 
43
58
  @checksums[obj.reference] = Nanoc::Core::Checksummer.calc(obj)
@@ -52,7 +67,8 @@ module Nanoc
52
67
 
53
68
  contract c_obj => C::Maybe[C::HashOf[Symbol, String]]
54
69
  def attributes_checksum_for(obj)
55
- @_attribute_checksums[obj] ||= @checksums[[obj.reference, :each_attribute]]
70
+ @_attribute_checksums[obj] ||=
71
+ @checksums[[obj.reference, :each_attribute]]
56
72
  end
57
73
 
58
74
  protected
@@ -68,7 +84,8 @@ module Nanoc
68
84
 
69
85
  @checksums = {}
70
86
  new_data.each_pair do |key, checksum|
71
- if references.include?(key) || (key.respond_to?(:first) && references.include?(key.first))
87
+ if references.include?(key) ||
88
+ (key.respond_to?(:first) && references.include?(key.first))
72
89
  @checksums[key] = checksum
73
90
  end
74
91
  end
@@ -4,8 +4,8 @@ module Nanoc
4
4
  module Core
5
5
  # Creates checksums for given objects.
6
6
  #
7
- # A checksum is a string, such as “mL+TaqNsEeiPkWloPgCtAofT1yg=”, that is used
8
- # to determine whether a piece of data has changed.
7
+ # A checksum is a string, such as “mL+TaqNsEeiPkWloPgCtAofT1yg=”, that is
8
+ # used to determine whether a piece of data has changed.
9
9
  class Checksummer
10
10
  class VerboseDigest
11
11
  def initialize
@@ -46,7 +46,9 @@ module Nanoc
46
46
  end
47
47
 
48
48
  def calc_for_content_of(obj)
49
- obj.content_checksum_data || obj.checksum_data || Nanoc::Core::Checksummer.calc(obj.content)
49
+ obj.content_checksum_data ||
50
+ obj.checksum_data ||
51
+ Nanoc::Core::Checksummer.calc(obj.content)
50
52
  end
51
53
 
52
54
  def calc_for_each_attribute_of(obj, digest_class = CompactDigest)
@@ -64,7 +66,8 @@ module Nanoc
64
66
  def update(obj, digest, visited = {})
65
67
  num = visited[obj]
66
68
  if num
67
- # If there already is an entry for this object, refer to it by its number.
69
+ # If there already is an entry for this object, refer to it by its
70
+ # number.
68
71
  digest.update("@#{num}")
69
72
  else
70
73
  # This object isn’t known yet. Assign it a new number.
@@ -73,7 +76,9 @@ module Nanoc
73
76
 
74
77
  digest.update(obj.class.to_s)
75
78
  digest.update("##{num}<")
76
- behavior_for(obj).update(obj, digest) { |o| update(o, digest, visited) }
79
+ behavior_for(obj).update(obj, digest) do |o|
80
+ update(o, digest, visited)
81
+ end
77
82
  digest.update('>')
78
83
  end
79
84
  end
@@ -86,29 +91,51 @@ module Nanoc
86
91
  # NOTE: Other behaviors are registered elsewhere
87
92
  # (search for `define_behavior`).
88
93
 
89
- define_behavior(Array, CollectionUpdateBehavior)
90
- define_behavior(Set, SetUpdateBehavior)
91
- define_behavior(FalseClass, NoUpdateBehavior)
92
- define_behavior(Hash, HashUpdateBehavior)
93
- define_behavior(NilClass, NoUpdateBehavior)
94
- define_behavior(Numeric, RawUpdateBehavior)
95
- define_behavior(Pathname, PathnameUpdateBehavior)
96
- define_behavior(String, RawUpdateBehavior)
97
- define_behavior(Symbol, RawUpdateBehavior)
98
- define_behavior(Time, ToIToSUpdateBehavior)
99
- define_behavior(TrueClass, NoUpdateBehavior)
100
-
101
- define_behavior(Nanoc::Core::BinaryContent, BinaryContentUpdateBehavior)
102
- define_behavior(Nanoc::Core::Configuration, HashUpdateBehavior)
103
- define_behavior(Nanoc::Core::Context, ContextUpdateBehavior)
104
- define_behavior(Nanoc::Core::CodeSnippet, DataUpdateBehavior)
105
- define_behavior(Nanoc::Core::IdentifiableCollection, CollectionUpdateBehavior)
106
- define_behavior(Nanoc::Core::Identifier, ToSUpdateBehavior)
107
- define_behavior(Nanoc::Core::Item, DocumentUpdateBehavior)
108
- define_behavior(Nanoc::Core::ItemRep, ItemRepUpdateBehavior)
109
- define_behavior(Nanoc::Core::Layout, DocumentUpdateBehavior)
110
- define_behavior(Nanoc::Core::TextualContent, StringUpdateBehavior)
111
- define_behavior(Nanoc::Core::View, UnwrapUpdateBehavior)
94
+ define_behavior(Array,
95
+ CollectionUpdateBehavior)
96
+ define_behavior(Set,
97
+ SetUpdateBehavior)
98
+ define_behavior(FalseClass,
99
+ NoUpdateBehavior)
100
+ define_behavior(Hash,
101
+ HashUpdateBehavior)
102
+ define_behavior(NilClass,
103
+ NoUpdateBehavior)
104
+ define_behavior(Numeric,
105
+ RawUpdateBehavior)
106
+ define_behavior(Pathname,
107
+ PathnameUpdateBehavior)
108
+ define_behavior(String,
109
+ RawUpdateBehavior)
110
+ define_behavior(Symbol,
111
+ RawUpdateBehavior)
112
+ define_behavior(Time,
113
+ ToIToSUpdateBehavior)
114
+ define_behavior(TrueClass,
115
+ NoUpdateBehavior)
116
+
117
+ define_behavior(Nanoc::Core::BinaryContent,
118
+ BinaryContentUpdateBehavior)
119
+ define_behavior(Nanoc::Core::Configuration,
120
+ HashUpdateBehavior)
121
+ define_behavior(Nanoc::Core::Context,
122
+ ContextUpdateBehavior)
123
+ define_behavior(Nanoc::Core::CodeSnippet,
124
+ DataUpdateBehavior)
125
+ define_behavior(Nanoc::Core::IdentifiableCollection,
126
+ CollectionUpdateBehavior)
127
+ define_behavior(Nanoc::Core::Identifier,
128
+ ToSUpdateBehavior)
129
+ define_behavior(Nanoc::Core::Item,
130
+ DocumentUpdateBehavior)
131
+ define_behavior(Nanoc::Core::ItemRep,
132
+ ItemRepUpdateBehavior)
133
+ define_behavior(Nanoc::Core::Layout,
134
+ DocumentUpdateBehavior)
135
+ define_behavior(Nanoc::Core::TextualContent,
136
+ StringUpdateBehavior)
137
+ define_behavior(Nanoc::Core::View,
138
+ UnwrapUpdateBehavior)
112
139
 
113
140
  @behaviors
114
141
  end
@@ -230,17 +257,21 @@ module Nanoc
230
257
  class DocumentUpdateBehavior < UpdateBehavior
231
258
  def self.update(obj, digest)
232
259
  if obj.checksum_data
233
- digest.update('checksum_data=' + obj.checksum_data)
260
+ digest.update("checksum_data=#{obj.checksum_data}")
234
261
  else
235
262
  if obj.content_checksum_data
236
- digest.update('content_checksum_data=' + obj.content_checksum_data)
263
+ digest.update(
264
+ "content_checksum_data=#{obj.content_checksum_data}",
265
+ )
237
266
  else
238
267
  digest.update('content=')
239
268
  yield(obj.content)
240
269
  end
241
270
 
242
271
  if obj.attributes_checksum_data
243
- digest.update(',attributes_checksum_data=' + obj.attributes_checksum_data)
272
+ digest.update(
273
+ ",attributes_checksum_data=#{obj.attributes_checksum_data}",
274
+ )
244
275
  else
245
276
  digest.update(',attributes=')
246
277
  yield(obj.attributes)
@@ -266,7 +297,7 @@ module Nanoc
266
297
  filename = obj.to_s
267
298
  if File.exist?(filename)
268
299
  stat = File.stat(filename)
269
- digest.update(stat.size.to_s + '-' + stat.mtime.to_i.to_s)
300
+ digest.update("#{stat.size}-#{stat.mtime.to_i}")
270
301
  else
271
302
  digest.update('???')
272
303
  end
@@ -6,8 +6,12 @@ module Nanoc
6
6
  class BuildReps < Nanoc::Core::CompilationStage
7
7
  include Nanoc::Core::ContractsSupport
8
8
 
9
- contract C::KeywordArgs[site: Nanoc::Core::Site, action_provider: Nanoc::Core::ActionProvider] => C::Any
9
+ contract C::KeywordArgs[
10
+ site: Nanoc::Core::Site,
11
+ action_provider: Nanoc::Core::ActionProvider] => C::Any
10
12
  def initialize(site:, action_provider:)
13
+ super()
14
+
11
15
  @site = site
12
16
  @action_provider = action_provider
13
17
  end
@@ -22,7 +26,8 @@ module Nanoc
22
26
  action_sequences = builder.run
23
27
 
24
28
  @site.layouts.each do |layout|
25
- action_sequences[layout] = @action_provider.action_sequence_for(layout)
29
+ action_sequences[layout] =
30
+ @action_provider.action_sequence_for(layout)
26
31
  end
27
32
 
28
33
  {
@@ -5,6 +5,8 @@ module Nanoc
5
5
  module CompilationStages
6
6
  class CalculateChecksums < Nanoc::Core::CompilationStage
7
7
  def initialize(items:, layouts:, code_snippets:, config:)
8
+ super()
9
+
8
10
  @items = items
9
11
  @layouts = layouts
10
12
  @code_snippets = code_snippets
@@ -5,6 +5,8 @@ module Nanoc
5
5
  module CompilationStages
6
6
  class Cleanup < Nanoc::Core::CompilationStage
7
7
  def initialize(output_dirs)
8
+ super()
9
+
8
10
  @output_dirs = output_dirs
9
11
  end
10
12
 
@@ -22,7 +24,10 @@ module Nanoc
22
24
  end
23
25
 
24
26
  def cleanup_unused_stores
25
- used_paths = @output_dirs.map { |d| Nanoc::Core::Store.tmp_path_prefix(d) }
27
+ used_paths = @output_dirs.map do |d|
28
+ Nanoc::Core::Store.tmp_path_prefix(d)
29
+ end
30
+
26
31
  all_paths = Dir.glob('tmp/nanoc/*')
27
32
  (all_paths - used_paths).each do |obsolete_path|
28
33
  FileUtils.rm_rf(obsolete_path)
@@ -30,7 +35,8 @@ module Nanoc
30
35
  end
31
36
 
32
37
  def cleanup_old_stores
33
- %w[checksums compiled_content dependencies outdatedness action_sequence].each do |fn|
38
+ ['checksums', 'compiled_content', 'dependencies', 'outdatedness',
39
+ 'action_sequence'].each do |fn|
34
40
  full_fn = File.join('tmp', fn)
35
41
  if File.file?(full_fn)
36
42
  FileUtils.rm_f(full_fn)