nanoc-core 4.12.6 → 4.12.8
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.
- checksums.yaml +4 -4
- data/lib/nanoc/core/action_sequence.rb +4 -4
- data/lib/nanoc/core/basic_item_rep_view.rb +1 -1
- data/lib/nanoc/core/changes_stream.rb +4 -4
- data/lib/nanoc/core/compilation_phases/resume.rb +2 -2
- data/lib/nanoc/core/compilation_stages/compile_reps.rb +1 -3
- data/lib/nanoc/core/config_loader.rb +3 -1
- data/lib/nanoc/core/configuration.rb +3 -3
- data/lib/nanoc/core/contracts_support.rb +1 -1
- data/lib/nanoc/core/document.rb +1 -1
- data/lib/nanoc/core/document_view_mixin.rb +1 -1
- data/lib/nanoc/core/identifier.rb +7 -7
- data/lib/nanoc/core/instrumentor.rb +29 -6
- data/lib/nanoc/core/outdatedness_checker.rb +39 -40
- data/lib/nanoc/core/outdatedness_rules/not_written.rb +22 -2
- data/lib/nanoc/core/processing_actions/filter.rb +1 -1
- data/lib/nanoc/core/processing_actions/layout.rb +1 -1
- data/lib/nanoc/core/processing_actions/snapshot.rb +1 -1
- data/lib/nanoc/core/store.rb +1 -1
- data/lib/nanoc/core/temp_filename_factory.rb +2 -3
- data/lib/nanoc/core/version.rb +1 -1
- metadata +18 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a29a2064140d04c44df1122dc537ca800a3ed7c20bfb740c4009f3b976067ebb
|
4
|
+
data.tar.gz: 6fc3869373babe4c16671b15747d0d3da4b291e4f6434cf1af6e5fbe05c99799
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bd1fd013b69ae47c40b8a1c5558729314603ceadabdadf3eb7b117b810988a7f7d777d5f3d6dba9f3e4f899763064c073ddd1e808f7d1e0f8aae8d52dc0c1e43
|
7
|
+
data.tar.gz: a11a2202ed08c519e151f097aee47ee16e189a969169fb09ca29162acb99436531007c8c943b6dea892be702454e518376a16253dc9f181069625305e1f09554
|
@@ -46,16 +46,16 @@ module Nanoc
|
|
46
46
|
end
|
47
47
|
|
48
48
|
# contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self
|
49
|
-
def each
|
50
|
-
@actions.each
|
49
|
+
def each(&block)
|
50
|
+
@actions.each(&block)
|
51
51
|
self
|
52
52
|
end
|
53
53
|
|
54
54
|
# contract C::Func[Nanoc::Core::ProcessingAction => C::Any] => self
|
55
|
-
def map
|
55
|
+
def map(&block)
|
56
56
|
self.class.new(
|
57
57
|
@item_rep,
|
58
|
-
actions: @actions.map
|
58
|
+
actions: @actions.map(&block),
|
59
59
|
)
|
60
60
|
end
|
61
61
|
end
|
@@ -38,16 +38,16 @@ module Nanoc
|
|
38
38
|
@listener&.to_stop&.call
|
39
39
|
end
|
40
40
|
|
41
|
-
def map
|
42
|
-
self.class.new(enum: @enum.map
|
41
|
+
def map(&block)
|
42
|
+
self.class.new(enum: @enum.map(&block))
|
43
43
|
end
|
44
44
|
|
45
45
|
def to_enum
|
46
46
|
@enum
|
47
47
|
end
|
48
48
|
|
49
|
-
def each
|
50
|
-
@enum.each
|
49
|
+
def each(&block)
|
50
|
+
@enum.each(&block)
|
51
51
|
nil
|
52
52
|
end
|
53
53
|
end
|
@@ -10,8 +10,8 @@ module Nanoc
|
|
10
10
|
DONE = Object.new
|
11
11
|
|
12
12
|
contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
13
|
-
def run(rep, is_outdated
|
14
|
-
fiber = fiber_for(rep, is_outdated: is_outdated)
|
13
|
+
def run(rep, is_outdated:, &block)
|
14
|
+
fiber = fiber_for(rep, is_outdated: is_outdated, &block)
|
15
15
|
while fiber.alive?
|
16
16
|
res = fiber.resume
|
17
17
|
|
@@ -84,11 +84,9 @@ module Nanoc
|
|
84
84
|
outdatedness_store: @outdatedness_store,
|
85
85
|
)
|
86
86
|
|
87
|
-
|
87
|
+
Nanoc::Core::CompilationPhases::Notify.new(
|
88
88
|
wrapped: mark_done_phase,
|
89
89
|
)
|
90
|
-
|
91
|
-
notify_phrase
|
92
90
|
end
|
93
91
|
end
|
94
92
|
end
|
@@ -4,6 +4,8 @@ module Nanoc
|
|
4
4
|
module Core
|
5
5
|
# @api private
|
6
6
|
class ConfigLoader
|
7
|
+
PERMITTED_YAML_CLASSES = [Symbol, Date, Time].freeze
|
8
|
+
|
7
9
|
class NoConfigFileFoundError < ::Nanoc::Core::Error
|
8
10
|
def initialize
|
9
11
|
super('No configuration file found')
|
@@ -54,7 +56,7 @@ module Nanoc
|
|
54
56
|
end
|
55
57
|
|
56
58
|
def load_file(filename)
|
57
|
-
YAML.
|
59
|
+
YAML.safe_load_file(filename, permitted_classes: PERMITTED_YAML_CLASSES)
|
58
60
|
end
|
59
61
|
|
60
62
|
# @api private
|
@@ -45,7 +45,7 @@ module Nanoc
|
|
45
45
|
NANOC_ENV_DEFAULT = 'default'
|
46
46
|
|
47
47
|
contract C::KeywordArgs[hash: C::Optional[Hash], env_name: C::Maybe[String], dir: C::AbsolutePathString] => C::Any
|
48
|
-
def initialize(hash: {},
|
48
|
+
def initialize(dir:, hash: {}, env_name: nil)
|
49
49
|
@env_name = env_name
|
50
50
|
@wrapped = hash.__nanoc_symbolize_keys_recursively
|
51
51
|
@dir = dir
|
@@ -136,8 +136,8 @@ module Nanoc
|
|
136
136
|
end
|
137
137
|
|
138
138
|
contract C::Func[C::Any, C::Any => C::Any] => self
|
139
|
-
def each
|
140
|
-
@wrapped.each
|
139
|
+
def each(&block)
|
140
|
+
@wrapped.each(&block)
|
141
141
|
self
|
142
142
|
end
|
143
143
|
|
data/lib/nanoc/core/document.rb
CHANGED
@@ -88,7 +88,7 @@ module Nanoc
|
|
88
88
|
|
89
89
|
contract C::None => C::Num
|
90
90
|
def hash
|
91
|
-
self.class
|
91
|
+
[self.class, to_s].hash
|
92
92
|
end
|
93
93
|
|
94
94
|
contract C::Any => C::Maybe[C::Num]
|
@@ -149,10 +149,10 @@ module Nanoc
|
|
149
149
|
|
150
150
|
extname = File.extname(@string)
|
151
151
|
|
152
|
-
if
|
153
|
-
@string[0..-extname.size - 1]
|
154
|
-
else
|
152
|
+
if extname.empty?
|
155
153
|
@string
|
154
|
+
else
|
155
|
+
@string[0..-extname.size - 1]
|
156
156
|
end
|
157
157
|
end
|
158
158
|
|
@@ -171,10 +171,10 @@ module Nanoc
|
|
171
171
|
# The identifier, as string, with all extensions removed
|
172
172
|
def without_exts
|
173
173
|
extname = exts.join('.')
|
174
|
-
if
|
175
|
-
@string[0..-extname.size - 2]
|
176
|
-
else
|
174
|
+
if extname.empty?
|
177
175
|
@string
|
176
|
+
else
|
177
|
+
@string[0..-extname.size - 2]
|
178
178
|
end
|
179
179
|
end
|
180
180
|
|
@@ -4,13 +4,36 @@ module Nanoc
|
|
4
4
|
module Core
|
5
5
|
# @api private
|
6
6
|
class Instrumentor
|
7
|
+
@enabled = false
|
8
|
+
|
9
|
+
def self.enable
|
10
|
+
if block_given?
|
11
|
+
begin
|
12
|
+
enable
|
13
|
+
yield
|
14
|
+
ensure
|
15
|
+
disable
|
16
|
+
end
|
17
|
+
else
|
18
|
+
@enabled = true
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.disable
|
23
|
+
@enabled = false
|
24
|
+
end
|
25
|
+
|
7
26
|
def self.call(key, *args)
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
27
|
+
return yield unless @enabled
|
28
|
+
|
29
|
+
begin
|
30
|
+
stopwatch = DDMetrics::Stopwatch.new
|
31
|
+
stopwatch.start
|
32
|
+
yield
|
33
|
+
ensure
|
34
|
+
stopwatch.stop
|
35
|
+
Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *args)
|
36
|
+
end
|
14
37
|
end
|
15
38
|
end
|
16
39
|
end
|
@@ -7,9 +7,7 @@ module Nanoc
|
|
7
7
|
# @api private
|
8
8
|
class OutdatednessChecker
|
9
9
|
class Basic
|
10
|
-
|
11
|
-
|
12
|
-
# include Nanoc::Core::ContractsSupport
|
10
|
+
include Nanoc::Core::ContractsSupport
|
13
11
|
|
14
12
|
Rules = Nanoc::Core::OutdatednessRules
|
15
13
|
|
@@ -46,62 +44,63 @@ module Nanoc
|
|
46
44
|
Rules::LayoutCollectionExtended,
|
47
45
|
].freeze
|
48
46
|
|
49
|
-
|
47
|
+
C_OBJ_MAYBE_REP = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep, Nanoc::Core::Configuration, Nanoc::Core::Layout, Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection]
|
50
48
|
|
51
|
-
|
49
|
+
contract C::KeywordArgs[outdatedness_checker: OutdatednessChecker, reps: Nanoc::Core::ItemRepRepo] => C::Any
|
52
50
|
def initialize(outdatedness_checker:, reps:)
|
53
51
|
@outdatedness_checker = outdatedness_checker
|
54
52
|
@reps = reps
|
53
|
+
|
54
|
+
# Memoize
|
55
|
+
@_outdatedness_status_for = {}
|
55
56
|
end
|
56
57
|
|
57
|
-
|
58
|
+
contract C_OBJ_MAYBE_REP => C::Maybe[Nanoc::Core::OutdatednessStatus]
|
58
59
|
def outdatedness_status_for(obj)
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
60
|
+
@_outdatedness_status_for[obj] ||=
|
61
|
+
case obj
|
62
|
+
when Nanoc::Core::ItemRep
|
63
|
+
apply_rules(RULES_FOR_ITEM_REP, obj)
|
64
|
+
when Nanoc::Core::Item
|
65
|
+
apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
|
66
|
+
when Nanoc::Core::Layout
|
67
|
+
apply_rules(RULES_FOR_LAYOUT, obj)
|
68
|
+
when Nanoc::Core::Configuration
|
69
|
+
apply_rules(RULES_FOR_CONFIG, obj)
|
70
|
+
when Nanoc::Core::ItemCollection
|
71
|
+
apply_rules(RULES_FOR_ITEM_COLLECTION, obj)
|
72
|
+
when Nanoc::Core::LayoutCollection
|
73
|
+
apply_rules(RULES_FOR_LAYOUT_COLLECTION, obj)
|
74
|
+
else
|
75
|
+
raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
|
76
|
+
end
|
75
77
|
end
|
76
|
-
memo_wise :outdatedness_status_for
|
77
78
|
|
78
79
|
private
|
79
80
|
|
80
|
-
|
81
|
+
contract C::ArrayOf[Class], C_OBJ_MAYBE_REP, Nanoc::Core::OutdatednessStatus => C::Maybe[Nanoc::Core::OutdatednessStatus]
|
81
82
|
def apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new)
|
82
83
|
rules.inject(status) do |acc, rule|
|
83
|
-
if
|
84
|
-
acc
|
85
|
-
else
|
84
|
+
if acc.useful_to_apply?(rule)
|
86
85
|
reason = rule.instance.call(obj, @outdatedness_checker)
|
87
86
|
if reason
|
88
87
|
acc.update(reason)
|
89
88
|
else
|
90
89
|
acc
|
91
90
|
end
|
91
|
+
else
|
92
|
+
acc
|
92
93
|
end
|
93
94
|
end
|
94
95
|
end
|
95
96
|
|
96
|
-
|
97
|
+
contract C::ArrayOf[Class], C::ArrayOf[C_OBJ_MAYBE_REP] => C::Maybe[Nanoc::Core::OutdatednessStatus]
|
97
98
|
def apply_rules_multi(rules, objs)
|
98
99
|
objs.inject(Nanoc::Core::OutdatednessStatus.new) { |acc, elem| apply_rules(rules, elem, acc) }
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
|
-
|
103
|
-
|
104
|
-
# include Nanoc::Core::ContractsSupport
|
103
|
+
include Nanoc::Core::ContractsSupport
|
105
104
|
|
106
105
|
attr_reader :checksum_store
|
107
106
|
attr_reader :checksums
|
@@ -112,11 +111,11 @@ module Nanoc
|
|
112
111
|
|
113
112
|
Reasons = Nanoc::Core::OutdatednessReasons
|
114
113
|
|
115
|
-
|
116
|
-
|
117
|
-
|
114
|
+
C_OBJ = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep, Nanoc::Core::Configuration, Nanoc::Core::Layout, Nanoc::Core::ItemCollection]
|
115
|
+
C_ITEM_OR_REP = C::Or[Nanoc::Core::Item, Nanoc::Core::ItemRep]
|
116
|
+
C_ACTION_SEQUENCES = C::HashOf[C_OBJ => Nanoc::Core::ActionSequence]
|
118
117
|
|
119
|
-
|
118
|
+
contract C::KeywordArgs[site: Nanoc::Core::Site, checksum_store: Nanoc::Core::ChecksumStore, checksums: Nanoc::Core::ChecksumCollection, dependency_store: Nanoc::Core::DependencyStore, action_sequence_store: Nanoc::Core::ActionSequenceStore, action_sequences: C_ACTION_SEQUENCES, reps: Nanoc::Core::ItemRepRepo] => C::Any
|
120
119
|
def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
|
121
120
|
@site = site
|
122
121
|
@checksum_store = checksum_store
|
@@ -133,12 +132,12 @@ module Nanoc
|
|
133
132
|
@action_sequences.fetch(rep)
|
134
133
|
end
|
135
134
|
|
136
|
-
|
135
|
+
contract C_OBJ => C::Bool
|
137
136
|
def outdated?(obj)
|
138
137
|
outdatedness_reasons_for(obj).any?
|
139
138
|
end
|
140
139
|
|
141
|
-
|
140
|
+
contract C_OBJ => C::IterOf[Reasons::Generic]
|
142
141
|
def outdatedness_reasons_for(obj)
|
143
142
|
reasons = basic.outdatedness_status_for(obj).reasons
|
144
143
|
if reasons.any?
|
@@ -152,12 +151,12 @@ module Nanoc
|
|
152
151
|
|
153
152
|
private
|
154
153
|
|
155
|
-
|
154
|
+
contract C::None => Basic
|
156
155
|
def basic
|
157
156
|
@_basic ||= Basic.new(outdatedness_checker: self, reps: @reps)
|
158
157
|
end
|
159
158
|
|
160
|
-
|
159
|
+
contract C_OBJ, Hamster::Set => C::Bool
|
161
160
|
def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
|
162
161
|
# Convert from rep to item if necessary
|
163
162
|
obj = obj.item if obj.is_a?(Nanoc::Core::ItemRep)
|
@@ -189,7 +188,7 @@ module Nanoc
|
|
189
188
|
is_outdated
|
190
189
|
end
|
191
190
|
|
192
|
-
|
191
|
+
contract Nanoc::Core::Dependency => C::Bool
|
193
192
|
def dependency_causes_outdatedness?(dependency)
|
194
193
|
return true if dependency.from.nil?
|
195
194
|
|
@@ -6,11 +6,31 @@ module Nanoc
|
|
6
6
|
class NotWritten < Nanoc::Core::OutdatednessRule
|
7
7
|
affects_props :raw_content, :attributes, :compiled_content, :path
|
8
8
|
|
9
|
-
def apply(obj,
|
10
|
-
if obj.raw_paths.values.flatten.compact.any? { |fn| !
|
9
|
+
def apply(obj, outdatedness_checker)
|
10
|
+
if obj.raw_paths.values.flatten.compact.any? { |fn| !exist?(fn, outdatedness_checker) }
|
11
11
|
Nanoc::Core::OutdatednessReasons::NotWritten
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
private
|
16
|
+
|
17
|
+
def exist?(fn, outdatedness_checker)
|
18
|
+
all(outdatedness_checker).include?(fn)
|
19
|
+
end
|
20
|
+
|
21
|
+
def all(outdatedness_checker)
|
22
|
+
# NOTE: Cached per outdatedness checker, so that unrelated invocations
|
23
|
+
# later on don’t reuse an old cache.
|
24
|
+
|
25
|
+
@all ||= {}
|
26
|
+
@all[outdatedness_checker] ||= Set.new(
|
27
|
+
Dir.glob("#{site_root(outdatedness_checker)}/**/*", File::FNM_DOTMATCH),
|
28
|
+
)
|
29
|
+
end
|
30
|
+
|
31
|
+
def site_root(outdatedness_checker)
|
32
|
+
outdatedness_checker.site.config.output_dir
|
33
|
+
end
|
14
34
|
end
|
15
35
|
end
|
16
36
|
end
|
data/lib/nanoc/core/store.rb
CHANGED
data/lib/nanoc/core/version.rb
CHANGED
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.
|
4
|
+
version: 4.12.8
|
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-
|
11
|
+
date: 2022-10-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: concurrent-ruby
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: '1.5'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: psych
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - "~>"
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '4.0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - "~>"
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '4.0'
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: slow_enumerator_tools
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -294,14 +308,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
294
308
|
requirements:
|
295
309
|
- - ">="
|
296
310
|
- !ruby/object:Gem::Version
|
297
|
-
version: '2.
|
311
|
+
version: '2.7'
|
298
312
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
299
313
|
requirements:
|
300
314
|
- - ">="
|
301
315
|
- !ruby/object:Gem::Version
|
302
316
|
version: '0'
|
303
317
|
requirements: []
|
304
|
-
rubygems_version: 3.3.
|
318
|
+
rubygems_version: 3.3.22
|
305
319
|
signing_key:
|
306
320
|
specification_version: 4
|
307
321
|
summary: Core of Nanoc
|