nanoc-core 4.11.13 → 4.11.18
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.rb +1 -0
- data/lib/nanoc/core/changes_stream.rb +55 -0
- data/lib/nanoc/core/checksum_store.rb +1 -1
- data/lib/nanoc/core/checksummer.rb +2 -2
- data/lib/nanoc/core/compilation_item_rep_view.rb +7 -1
- data/lib/nanoc/core/compilation_phases/abstract.rb +1 -1
- data/lib/nanoc/core/compilation_phases/resume.rb +1 -1
- data/lib/nanoc/core/compilation_phases/write.rb +8 -48
- data/lib/nanoc/core/compiled_content_cache.rb +2 -2
- data/lib/nanoc/core/compiler_loader.rb +1 -1
- data/lib/nanoc/core/contracts_support.rb +20 -0
- data/lib/nanoc/core/dependency_store.rb +3 -3
- data/lib/nanoc/core/errors.rb +11 -0
- data/lib/nanoc/core/executor.rb +1 -1
- data/lib/nanoc/core/pruner.rb +6 -2
- data/lib/nanoc/core/version.rb +1 -1
- metadata +18 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bd4fffaf7813aba1bc2544b16ff1cf801f141a293605c4cd3a4f44d26e6baf02
|
4
|
+
data.tar.gz: a11c2bd8d095dbfcfddc00628cf2a65115184dee3cbedd3ea956d17ce0551f57
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26a6cf153b5cb6c2fc0c12e1597ab4a77dd6ff52cf95fa90e9b636f684caf819e883677cfbe3d60a179f2f87c548be5a4f436c56f2e981b2691908163844628a
|
7
|
+
data.tar.gz: 2b2dcbaf7d2b0c41a7d9558af9b33c3e7eafa5b8986ec230fb31c74c916beb4912872f80ffa63f02eea9558c60f5e4723ee08d71ece1731ae8d107b5e847b990
|
data/lib/nanoc/core.rb
CHANGED
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
module Core
|
5
|
+
class ChangesStream
|
6
|
+
class ChangesListener
|
7
|
+
def initialize(y)
|
8
|
+
@y = y
|
9
|
+
end
|
10
|
+
|
11
|
+
def unknown
|
12
|
+
@y << :unknown
|
13
|
+
end
|
14
|
+
|
15
|
+
def lib
|
16
|
+
@y << :lib
|
17
|
+
end
|
18
|
+
|
19
|
+
def to_stop(&block)
|
20
|
+
if block_given?
|
21
|
+
@to_stop = block
|
22
|
+
else
|
23
|
+
@to_stop
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def initialize(enum: nil)
|
29
|
+
@enum = enum
|
30
|
+
@enum ||=
|
31
|
+
Enumerator.new do |y|
|
32
|
+
@listener = ChangesListener.new(y)
|
33
|
+
yield(@listener)
|
34
|
+
end.lazy
|
35
|
+
end
|
36
|
+
|
37
|
+
def stop
|
38
|
+
@listener&.to_stop&.call
|
39
|
+
end
|
40
|
+
|
41
|
+
def map
|
42
|
+
self.class.new(enum: @enum.map { |e| yield(e) })
|
43
|
+
end
|
44
|
+
|
45
|
+
def to_enum
|
46
|
+
@enum
|
47
|
+
end
|
48
|
+
|
49
|
+
def each
|
50
|
+
@enum.each { |e| yield(e) }
|
51
|
+
nil
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -64,7 +64,7 @@ module Nanoc
|
|
64
64
|
|
65
65
|
@checksums = {}
|
66
66
|
new_data.each_pair do |key, checksum|
|
67
|
-
if references.include?(key) || references.include?(key.first)
|
67
|
+
if references.include?(key) || (key.respond_to?(:first) && references.include?(key.first))
|
68
68
|
@checksums[key] = checksum
|
69
69
|
end
|
70
70
|
end
|
@@ -50,8 +50,8 @@ module Nanoc
|
|
50
50
|
end
|
51
51
|
|
52
52
|
def calc_for_each_attribute_of(obj, digest_class = CompactDigest)
|
53
|
-
obj.attributes.
|
54
|
-
|
53
|
+
obj.attributes.transform_values do |value|
|
54
|
+
Nanoc::Core::Checksummer.calc(value, digest_class)
|
55
55
|
end
|
56
56
|
end
|
57
57
|
|
@@ -3,6 +3,12 @@
|
|
3
3
|
module Nanoc
|
4
4
|
module Core
|
5
5
|
class CompilationItemRepView < ::Nanoc::Core::BasicItemRepView
|
6
|
+
# How long to wait before the requested file appears.
|
7
|
+
#
|
8
|
+
# This is a bit of a hack -- ideally, Nanoc would know that the file is
|
9
|
+
# being generated, and wait the appropriate amount of time.
|
10
|
+
FILE_APPEAR_TIMEOUT = 10.0
|
11
|
+
|
6
12
|
# @abstract
|
7
13
|
def item_view_class
|
8
14
|
Nanoc::Core::CompilationItemView
|
@@ -27,7 +33,7 @@ module Nanoc
|
|
27
33
|
# Wait for file to exist
|
28
34
|
if res
|
29
35
|
start = Time.now
|
30
|
-
sleep 0.05 until File.file?(res) || Time.now - start >
|
36
|
+
sleep 0.05 until File.file?(res) || Time.now - start > FILE_APPEAR_TIMEOUT
|
31
37
|
raise Nanoc::Core::Errors::InternalInconsistency, "File did not apear in time: #{res}" unless File.file?(res)
|
32
38
|
end
|
33
39
|
|
@@ -32,7 +32,7 @@ module Nanoc
|
|
32
32
|
end
|
33
33
|
|
34
34
|
contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
35
|
-
def run(_rep, is_outdated:)
|
35
|
+
def run(_rep, is_outdated:)
|
36
36
|
raise NotImplementedError
|
37
37
|
end
|
38
38
|
|
@@ -6,45 +6,6 @@ module Nanoc
|
|
6
6
|
class Write < Abstract
|
7
7
|
include Nanoc::Core::ContractsSupport
|
8
8
|
|
9
|
-
class Worker
|
10
|
-
def initialize(queue:, compiled_content_store:)
|
11
|
-
@queue = queue
|
12
|
-
@compiled_content_store = compiled_content_store
|
13
|
-
end
|
14
|
-
|
15
|
-
def start
|
16
|
-
@thread = Thread.new do
|
17
|
-
Thread.current.abort_on_exception = true
|
18
|
-
Thread.current.priority = -1 # schedule I/O work ASAP
|
19
|
-
|
20
|
-
writer = Nanoc::Core::ItemRepWriter.new
|
21
|
-
|
22
|
-
while rep = @queue.pop # rubocop:disable Lint/AssignmentInCondition
|
23
|
-
writer.write_all(rep, @compiled_content_store)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
def join
|
29
|
-
@thread.join
|
30
|
-
end
|
31
|
-
end
|
32
|
-
|
33
|
-
class WorkerPool
|
34
|
-
def initialize(queue:, size:, compiled_content_store:)
|
35
|
-
@workers = Array.new(size) { Worker.new(queue: queue, compiled_content_store: compiled_content_store) }
|
36
|
-
end
|
37
|
-
|
38
|
-
def start
|
39
|
-
@workers.each(&:start)
|
40
|
-
end
|
41
|
-
|
42
|
-
def join
|
43
|
-
@workers.each(&:join)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
QUEUE_SIZE = 40
|
48
9
|
WORKER_POOL_SIZE = 5
|
49
10
|
|
50
11
|
def initialize(compiled_content_store:, wrapped:)
|
@@ -52,19 +13,16 @@ module Nanoc
|
|
52
13
|
|
53
14
|
@compiled_content_store = compiled_content_store
|
54
15
|
|
55
|
-
@
|
56
|
-
@worker_pool = WorkerPool.new(queue: @queue, size: WORKER_POOL_SIZE, compiled_content_store: @compiled_content_store)
|
57
|
-
end
|
16
|
+
@pool = Concurrent::FixedThreadPool.new(WORKER_POOL_SIZE)
|
58
17
|
|
59
|
-
|
60
|
-
super
|
61
|
-
@worker_pool.start
|
18
|
+
@writer = Nanoc::Core::ItemRepWriter.new
|
62
19
|
end
|
63
20
|
|
64
21
|
def stop
|
22
|
+
@pool.shutdown
|
23
|
+
@pool.wait_for_termination
|
24
|
+
|
65
25
|
super
|
66
|
-
@queue.close
|
67
|
-
@worker_pool.join
|
68
26
|
end
|
69
27
|
|
70
28
|
contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
@@ -76,7 +34,9 @@ module Nanoc
|
|
76
34
|
# notification happens before the :rep_write_enqueued one.
|
77
35
|
Nanoc::Core::NotificationCenter.post(:rep_write_enqueued, rep)
|
78
36
|
|
79
|
-
@
|
37
|
+
@pool.post do
|
38
|
+
@writer.write_all(rep, @compiled_content_store)
|
39
|
+
end
|
80
40
|
end
|
81
41
|
end
|
82
42
|
end
|
@@ -46,8 +46,8 @@ module Nanoc
|
|
46
46
|
@binary_cache[rep] = content.select { |_key, c| c.binary? }
|
47
47
|
end
|
48
48
|
|
49
|
-
def prune(
|
50
|
-
@wrapped_caches.each { |w| w.prune(
|
49
|
+
def prune(items:)
|
50
|
+
@wrapped_caches.each { |w| w.prune(items: items) }
|
51
51
|
end
|
52
52
|
|
53
53
|
# True if there is cached compiled content available for this item, and
|
@@ -103,6 +103,8 @@ module Nanoc
|
|
103
103
|
::Contracts.const_set('Named', EnabledContracts::Named)
|
104
104
|
::Contracts.const_set('IterOf', EnabledContracts::IterOf)
|
105
105
|
::Contracts.const_set('AbsolutePathString', EnabledContracts::AbsolutePathString)
|
106
|
+
|
107
|
+
warn_about_performance
|
106
108
|
end
|
107
109
|
|
108
110
|
@_contracts_support__should_enable
|
@@ -126,6 +128,24 @@ module Nanoc
|
|
126
128
|
base.const_set('C', DisabledContracts)
|
127
129
|
end
|
128
130
|
end
|
131
|
+
|
132
|
+
def self.warn_about_performance
|
133
|
+
return if ENV.key?('CI')
|
134
|
+
return if ENV.key?('NANOC_DEV_MODE')
|
135
|
+
|
136
|
+
puts '-' * 78
|
137
|
+
puts 'A NOTE ABOUT PERFORMANCE:'
|
138
|
+
puts 'The `contracts` gem is loaded, which enables extra run-time checks, but can drastically reduce Nanoc’s performance. The `contracts` gem is intended for development purposes, and is not recommended for day-to-day Nanoc usage.'
|
139
|
+
puts
|
140
|
+
|
141
|
+
if defined?(Bundler)
|
142
|
+
puts 'To speed up compilation, remove `contracts` from the Gemfile and run `bundle install`.'
|
143
|
+
else
|
144
|
+
puts 'To speed up compilation, either uninstall the `contracts` gem, or use Bundler (https://bundler.io/) with a Gemfile that doesn’t include `contracts`.'
|
145
|
+
end
|
146
|
+
|
147
|
+
puts '-' * 78
|
148
|
+
end
|
129
149
|
end
|
130
150
|
end
|
131
151
|
end
|
@@ -113,7 +113,7 @@ module Nanoc
|
|
113
113
|
src_ref = obj2ref(src)
|
114
114
|
dst_ref = obj2ref(dst)
|
115
115
|
|
116
|
-
existing_props = Nanoc::Core::DependencyProps.new(@graph.props_for(dst_ref, src_ref) || {})
|
116
|
+
existing_props = Nanoc::Core::DependencyProps.new(**(@graph.props_for(dst_ref, src_ref) || {}))
|
117
117
|
new_props = Nanoc::Core::DependencyProps.new(raw_content: raw_content, attributes: attributes, compiled_content: compiled_content, path: path)
|
118
118
|
props = existing_props.merge(new_props)
|
119
119
|
|
@@ -184,8 +184,8 @@ module Nanoc
|
|
184
184
|
@graph = Nanoc::Core::DirectedGraph.new([nil] + refs)
|
185
185
|
|
186
186
|
# Load vertices
|
187
|
-
|
188
|
-
|
187
|
+
previous_objects = refs2objs(new_data[:vertices])
|
188
|
+
previous_refs = objs2refs(previous_objects)
|
189
189
|
|
190
190
|
# Load edges
|
191
191
|
new_data[:edges].each do |edge|
|
data/lib/nanoc/core/errors.rb
CHANGED
@@ -88,6 +88,17 @@ module Nanoc
|
|
88
88
|
end
|
89
89
|
end
|
90
90
|
|
91
|
+
# Error that is raised during site compilation when a layout is compiled
|
92
|
+
# for which the filter cannot be determined. This is similar to the
|
93
|
+
# {UnknownFilter} error, but specific for filters for layouts.
|
94
|
+
class CannotDetermineFilter < ::Nanoc::Core::Error
|
95
|
+
# @param [String] layout_identifier The identifier of the layout for
|
96
|
+
# which the filter could not be determined
|
97
|
+
def initialize(layout_identifier)
|
98
|
+
super("The filter to be used for the “#{layout_identifier}” layout could not be determined. Make sure the layout does have a filter.")
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
91
102
|
# Error that is raised when the compiled content of a binary item is attempted to be accessed.
|
92
103
|
class CannotGetCompiledContentOfBinaryItem < ::Nanoc::Core::Error
|
93
104
|
# @param [Nanoc::Core::ItemRep] rep The binary item representation whose compiled content was attempted to be accessed
|
data/lib/nanoc/core/executor.rb
CHANGED
@@ -39,7 +39,7 @@ module Nanoc
|
|
39
39
|
filter_name_and_args = @compilation_context.filter_name_and_args_for_layout(layout)
|
40
40
|
filter_name = filter_name_and_args.name
|
41
41
|
if filter_name.nil?
|
42
|
-
raise
|
42
|
+
raise Nanoc::Core::Errors::CannotDetermineFilter.new(layout_identifier)
|
43
43
|
end
|
44
44
|
|
45
45
|
filter_args = filter_name_and_args.args
|
data/lib/nanoc/core/pruner.rb
CHANGED
@@ -111,8 +111,12 @@ module Nanoc
|
|
111
111
|
end
|
112
112
|
|
113
113
|
def log_delete_and_run(thing)
|
114
|
-
|
115
|
-
|
114
|
+
if @dry_run
|
115
|
+
Nanoc::Core::NotificationCenter.post(:file_listed_for_pruning, thing)
|
116
|
+
else
|
117
|
+
Nanoc::Core::NotificationCenter.post(:file_pruned, thing)
|
118
|
+
yield
|
119
|
+
end
|
116
120
|
end
|
117
121
|
end
|
118
122
|
end
|
data/lib/nanoc/core/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc-core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.11.
|
4
|
+
version: 4.11.18
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: concurrent-ruby
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '1.1'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.1'
|
13
27
|
- !ruby/object:Gem::Dependency
|
14
28
|
name: ddmemoize
|
15
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +171,7 @@ files:
|
|
157
171
|
- lib/nanoc/core/basic_item_view.rb
|
158
172
|
- lib/nanoc/core/binary_compiled_content_cache.rb
|
159
173
|
- lib/nanoc/core/binary_content.rb
|
174
|
+
- lib/nanoc/core/changes_stream.rb
|
160
175
|
- lib/nanoc/core/checksum_collection.rb
|
161
176
|
- lib/nanoc/core/checksum_store.rb
|
162
177
|
- lib/nanoc/core/checksummer.rb
|
@@ -299,7 +314,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
299
314
|
- !ruby/object:Gem::Version
|
300
315
|
version: '0'
|
301
316
|
requirements: []
|
302
|
-
rubygems_version: 3.
|
317
|
+
rubygems_version: 3.1.4
|
303
318
|
signing_key:
|
304
319
|
specification_version: 4
|
305
320
|
summary: Core of Nanoc
|