nanoc-core 4.12.9 → 4.12.11

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 (39) hide show
  1. checksums.yaml +4 -4
  2. data/lib/nanoc/core/action_sequence.rb +1 -4
  3. data/lib/nanoc/core/action_sequence_builder.rb +8 -10
  4. data/lib/nanoc/core/basic_item_view.rb +1 -1
  5. data/lib/nanoc/core/basic_outdatedness_checker.rb +135 -0
  6. data/lib/nanoc/core/checksum_collection.rb +3 -1
  7. data/lib/nanoc/core/checksum_store.rb +11 -1
  8. data/lib/nanoc/core/compilation_stages/determine_outdatedness.rb +6 -1
  9. data/lib/nanoc/core/compilation_stages/load_stores.rb +5 -12
  10. data/lib/nanoc/core/configuration.rb +15 -0
  11. data/lib/nanoc/core/dependency_props.rb +2 -2
  12. data/lib/nanoc/core/dependency_store.rb +15 -13
  13. data/lib/nanoc/core/document.rb +5 -1
  14. data/lib/nanoc/core/executor.rb +2 -1
  15. data/lib/nanoc/core/identifiable_collection.rb +16 -33
  16. data/lib/nanoc/core/identifiable_collection_view.rb +54 -10
  17. data/lib/nanoc/core/item.rb +1 -1
  18. data/lib/nanoc/core/item_collection.rb +0 -6
  19. data/lib/nanoc/core/item_rep.rb +18 -0
  20. data/lib/nanoc/core/item_rep_builder.rb +4 -4
  21. data/lib/nanoc/core/item_rep_selector.rb +69 -17
  22. data/lib/nanoc/core/layout.rb +1 -1
  23. data/lib/nanoc/core/layout_collection.rb +0 -6
  24. data/lib/nanoc/core/mutable_document_view_mixin.rb +16 -7
  25. data/lib/nanoc/core/outdatedness_checker.rb +57 -123
  26. data/lib/nanoc/core/outdatedness_rule.rb +31 -3
  27. data/lib/nanoc/core/outdatedness_rules/attributes_modified.rb +6 -6
  28. data/lib/nanoc/core/outdatedness_rules/code_snippets_modified.rb +6 -6
  29. data/lib/nanoc/core/outdatedness_rules/content_modified.rb +3 -3
  30. data/lib/nanoc/core/outdatedness_rules/item_added.rb +3 -3
  31. data/lib/nanoc/core/outdatedness_rules/layout_added.rb +3 -3
  32. data/lib/nanoc/core/outdatedness_rules/not_written.rb +9 -9
  33. data/lib/nanoc/core/outdatedness_rules/rules_modified.rb +12 -10
  34. data/lib/nanoc/core/outdatedness_rules/uses_always_outdated_filter.rb +2 -2
  35. data/lib/nanoc/core/outdatedness_status.rb +6 -1
  36. data/lib/nanoc/core/store.rb +56 -23
  37. data/lib/nanoc/core/version.rb +1 -1
  38. data/lib/nanoc/core.rb +8 -0
  39. metadata +4 -3
@@ -13,7 +13,12 @@ module Nanoc
13
13
  end
14
14
 
15
15
  def useful_to_apply?(rule)
16
- (rule.affected_props - @props.active).any?
16
+ return true if rule.affects_raw_content? && !@props.raw_content?
17
+ return true if rule.affects_attributes? && !@props.attributes?
18
+ return true if rule.affects_compiled_content? && !@props.compiled_content?
19
+ return true if rule.affects_path? && !@props.path?
20
+
21
+ false
17
22
  end
18
23
 
19
24
  def update(reason)
@@ -7,11 +7,7 @@ module Nanoc
7
7
  # graphs.
8
8
  #
9
9
  # Each store has a version number. When attempting to load data from a store
10
- # that has an incompatible version number, no data will be loaded, but
11
- # {#version_mismatch_detected} will be called.
12
- #
13
- # @abstract Subclasses must implement {#data} and {#data=}, and may
14
- # implement {#no_data_found} and {#version_mismatch_detected}.
10
+ # that has an incompatible version number, no data will be loaded.
15
11
  #
16
12
  # @api private
17
13
  class Store
@@ -78,17 +74,8 @@ module Nanoc
78
74
  #
79
75
  # @return [void]
80
76
  def load
81
- return unless File.file?(filename)
82
-
83
- begin
84
- pstore.transaction(true) do
85
- return if pstore[:version] != version
86
-
87
- self.data = pstore[:data]
88
- end
89
- rescue
90
- FileUtils.rm_f(filename)
91
- load
77
+ Nanoc::Core::Instrumentor.call(:store_loaded, self.class) do
78
+ load_uninstrumented
92
79
  end
93
80
  end
94
81
 
@@ -97,18 +84,64 @@ module Nanoc
97
84
  #
98
85
  # @return [void]
99
86
  def store
100
- FileUtils.mkdir_p(File.dirname(filename))
101
-
102
- pstore.transaction do
103
- pstore[:data] = data
104
- pstore[:version] = version
87
+ # NOTE: Yes, the “store stored” name is a little silly. Maybe stores
88
+ # need to be renamed to databases or so.
89
+ Nanoc::Core::Instrumentor.call(:store_stored, self.class) do
90
+ store_uninstrumented
105
91
  end
106
92
  end
107
93
 
108
94
  private
109
95
 
110
- def pstore
111
- @pstore ||= PStore.new(filename)
96
+ def load_uninstrumented
97
+ unsafe_load_uninstrumented
98
+ rescue
99
+ # An error occurred! Remove the database and try again
100
+ FileUtils.rm_f(version_filename)
101
+ FileUtils.rm_f(data_filename)
102
+
103
+ # Try again
104
+ unsafe_load_uninstrumented
105
+ end
106
+
107
+ def store_uninstrumented
108
+ FileUtils.mkdir_p(File.dirname(filename))
109
+
110
+ write_obj_to_file(version_filename, version)
111
+ write_obj_to_file(data_filename, data)
112
+
113
+ # Remove old file (back from the PStore days), if there are any.
114
+ FileUtils.rm_f(filename)
115
+ end
116
+
117
+ # Unsafe, because it can throw exceptions.
118
+ def unsafe_load_uninstrumented
119
+ # If there is no database, no point in loading anything
120
+ return unless File.file?(version_filename)
121
+
122
+ # Check if store version is the expected version. If it is not, don’t
123
+ # load.
124
+ read_version = read_obj_from_file(version_filename)
125
+ return if read_version != version
126
+
127
+ # Load data
128
+ self.data = read_obj_from_file(data_filename)
129
+ end
130
+
131
+ def write_obj_to_file(fn, obj)
132
+ File.binwrite(fn, Marshal.dump(obj))
133
+ end
134
+
135
+ def read_obj_from_file(fn)
136
+ Marshal.load(File.binread(fn))
137
+ end
138
+
139
+ def version_filename
140
+ "#{filename}.version.db"
141
+ end
142
+
143
+ def data_filename
144
+ "#{filename}.data.db"
112
145
  end
113
146
  end
114
147
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.12.9'
5
+ VERSION = '4.12.11'
6
6
  end
7
7
  end
data/lib/nanoc/core.rb CHANGED
@@ -33,6 +33,14 @@ module Nanoc
33
33
  # thus cannot be used to mean the presence of nothing.
34
34
  UNDEFINED = Object.new
35
35
 
36
+ def UNDEFINED.inspect
37
+ '<UNDEFINED>'
38
+ end
39
+
40
+ def UNDEFINED.to_s
41
+ inspect
42
+ end
43
+
36
44
  # @return [String] A string containing information about this Nanoc version
37
45
  # and its environment (Ruby engine and version, Rubygems version if any).
38
46
  #
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.9
4
+ version: 4.12.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-10-08 00:00:00.000000000 Z
11
+ date: 2022-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -169,6 +169,7 @@ files:
169
169
  - lib/nanoc/core/basic_item_rep_collection_view.rb
170
170
  - lib/nanoc/core/basic_item_rep_view.rb
171
171
  - lib/nanoc/core/basic_item_view.rb
172
+ - lib/nanoc/core/basic_outdatedness_checker.rb
172
173
  - lib/nanoc/core/binary_compiled_content_cache.rb
173
174
  - lib/nanoc/core/binary_content.rb
174
175
  - lib/nanoc/core/changes_stream.rb
@@ -315,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
315
316
  - !ruby/object:Gem::Version
316
317
  version: '0'
317
318
  requirements: []
318
- rubygems_version: 3.3.22
319
+ rubygems_version: 3.3.25
319
320
  signing_key:
320
321
  specification_version: 4
321
322
  summary: Core of Nanoc