nanoc-core 4.12.7 → 4.12.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nanoc/core/instrumentor.rb +29 -6
- data/lib/nanoc/core/outdatedness_checker.rb +36 -37
- data/lib/nanoc/core/outdatedness_rules/not_written.rb +22 -2
- 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 +3 -3
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
|
@@ -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,38 +44,41 @@ 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
84
|
if acc.useful_to_apply?(rule)
|
@@ -93,15 +94,13 @@ module Nanoc
|
|
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
|
@@ -315,7 +315,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
315
315
|
- !ruby/object:Gem::Version
|
316
316
|
version: '0'
|
317
317
|
requirements: []
|
318
|
-
rubygems_version: 3.3.
|
318
|
+
rubygems_version: 3.3.22
|
319
319
|
signing_key:
|
320
320
|
specification_version: 4
|
321
321
|
summary: Core of Nanoc
|