nanoc-core 4.12.14 → 4.13.0
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/action_sequence_store.rb +1 -1
- data/lib/nanoc/core/basic_item_rep_view.rb +1 -1
- data/lib/nanoc/core/binary_compiled_content_cache.rb +1 -1
- data/lib/nanoc/core/changes_stream.rb +4 -4
- data/lib/nanoc/core/checksum_store.rb +1 -1
- data/lib/nanoc/core/checksummer.rb +16 -7
- data/lib/nanoc/core/compilation_item_rep_view.rb +2 -2
- data/lib/nanoc/core/compilation_item_view.rb +2 -2
- data/lib/nanoc/core/compilation_phases/abstract.rb +2 -2
- data/lib/nanoc/core/compilation_phases/cache.rb +2 -2
- data/lib/nanoc/core/compilation_phases/mark_done.rb +1 -1
- data/lib/nanoc/core/compilation_phases/resume.rb +1 -1
- data/lib/nanoc/core/compilation_phases/write.rb +1 -1
- data/lib/nanoc/core/compilation_stages/build_reps.rb +2 -2
- data/lib/nanoc/core/compilation_stages/compile_reps.rb +24 -7
- data/lib/nanoc/core/compiled_content_cache.rb +3 -3
- data/lib/nanoc/core/compiled_content_store.rb +1 -1
- data/lib/nanoc/core/compiler.rb +31 -29
- data/lib/nanoc/core/compiler_loader.rb +9 -8
- data/lib/nanoc/core/config_loader.rb +1 -3
- data/lib/nanoc/core/config_view.rb +3 -3
- data/lib/nanoc/core/configuration.rb +5 -5
- data/lib/nanoc/core/content.rb +13 -13
- data/lib/nanoc/core/context.rb +1 -1
- data/lib/nanoc/core/core_ext/array.rb +12 -8
- data/lib/nanoc/core/data_source.rb +3 -3
- data/lib/nanoc/core/dependency_props.rb +2 -2
- data/lib/nanoc/core/dependency_store.rb +4 -4
- data/lib/nanoc/core/dependency_tracker.rb +5 -5
- data/lib/nanoc/core/document_view_mixin.rb +1 -1
- data/lib/nanoc/core/feature.rb +2 -2
- data/lib/nanoc/core/identifiable_collection.rb +3 -3
- data/lib/nanoc/core/identifiable_collection_view.rb +2 -2
- data/lib/nanoc/core/identifier.rb +2 -2
- data/lib/nanoc/core/item.rb +7 -0
- data/lib/nanoc/core/item_rep_builder.rb +19 -19
- data/lib/nanoc/core/item_rep_repo.rb +2 -2
- data/lib/nanoc/core/layout.rb +7 -0
- data/lib/nanoc/core/mutable_identifiable_collection_view.rb +1 -1
- data/lib/nanoc/core/mutable_item_collection_view.rb +1 -1
- data/lib/nanoc/core/notification_center.rb +3 -3
- data/lib/nanoc/core/outdatedness_checker.rb +3 -3
- data/lib/nanoc/core/outdatedness_rule.rb +15 -15
- data/lib/nanoc/core/outdatedness_store.rb +1 -1
- data/lib/nanoc/core/post_compile_item_rep_view.rb +1 -1
- data/lib/nanoc/core/processing_action.rb +1 -1
- data/lib/nanoc/core/pruner.rb +1 -1
- data/lib/nanoc/core/site_loader.rb +9 -10
- data/lib/nanoc/core/store.rb +16 -16
- data/lib/nanoc/core/textual_compiled_content_cache.rb +1 -1
- data/lib/nanoc/core/version.rb +1 -1
- data/lib/nanoc/core/yaml_loader.rb +23 -0
- data/lib/nanoc/core.rb +3 -2
- metadata +32 -10
|
@@ -10,19 +10,23 @@ module Nanoc
|
|
|
10
10
|
#
|
|
11
11
|
# @return [Array] The converted array
|
|
12
12
|
def __nanoc_symbolize_keys_recursively
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
map do |element|
|
|
14
|
+
if element.respond_to?(:__nanoc_symbolize_keys_recursively)
|
|
15
|
+
element.__nanoc_symbolize_keys_recursively
|
|
16
|
+
else
|
|
17
|
+
element
|
|
18
|
+
end
|
|
16
19
|
end
|
|
17
|
-
array
|
|
18
20
|
end
|
|
19
21
|
|
|
20
22
|
def __nanoc_stringify_keys_recursively
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
map do |element|
|
|
24
|
+
if element.respond_to?(:__nanoc_stringify_keys_recursively)
|
|
25
|
+
element.__nanoc_stringify_keys_recursively
|
|
26
|
+
else
|
|
27
|
+
element
|
|
28
|
+
end
|
|
24
29
|
end
|
|
25
|
-
array
|
|
26
30
|
end
|
|
27
31
|
|
|
28
32
|
# Freezes the contents of the array, as well as all array elements. The
|
|
@@ -144,8 +144,8 @@ module Nanoc
|
|
|
144
144
|
#
|
|
145
145
|
# @param [String, nil] attributes_checksum_data
|
|
146
146
|
def new_item(content, attributes, identifier, binary: false, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
|
|
147
|
-
content = Nanoc::Core::Content.create(content, binary:
|
|
148
|
-
Nanoc::Core::Item.new(content, attributes, identifier, checksum_data
|
|
147
|
+
content = Nanoc::Core::Content.create(content, binary:)
|
|
148
|
+
Nanoc::Core::Item.new(content, attributes, identifier, checksum_data:, content_checksum_data:, attributes_checksum_data:)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
# Creates a new in-memory layout instance. This is intended for use within
|
|
@@ -163,7 +163,7 @@ module Nanoc
|
|
|
163
163
|
#
|
|
164
164
|
# @param [String, nil] attributes_checksum_data
|
|
165
165
|
def new_layout(raw_content, attributes, identifier, checksum_data: nil, content_checksum_data: nil, attributes_checksum_data: nil)
|
|
166
|
-
Nanoc::Core::Layout.new(raw_content, attributes, identifier, checksum_data
|
|
166
|
+
Nanoc::Core::Layout.new(raw_content, attributes, identifier, checksum_data:, content_checksum_data:, attributes_checksum_data:)
|
|
167
167
|
end
|
|
168
168
|
end
|
|
169
169
|
end
|
|
@@ -42,7 +42,7 @@ module Nanoc
|
|
|
42
42
|
|
|
43
43
|
contract Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection, Nanoc::Core::Configuration => C::Any
|
|
44
44
|
def initialize(items, layouts, config)
|
|
45
|
-
super(Nanoc::Core::Store.tmp_path_for(config
|
|
45
|
+
super(Nanoc::Core::Store.tmp_path_for(config:, store_name: 'dependencies'), 6)
|
|
46
46
|
|
|
47
47
|
@config = config
|
|
48
48
|
@items = items
|
|
@@ -142,10 +142,10 @@ module Nanoc
|
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
existing_props = @graph.props_for(dst_ref, src_ref)
|
|
145
|
-
new_props = Nanoc::Core::DependencyProps.new(raw_content
|
|
145
|
+
new_props = Nanoc::Core::DependencyProps.new(raw_content:, attributes:, compiled_content:, path:)
|
|
146
146
|
props = existing_props ? existing_props.merge(new_props) : new_props
|
|
147
147
|
|
|
148
|
-
@graph.add_edge(dst_ref, src_ref, props:
|
|
148
|
+
@graph.add_edge(dst_ref, src_ref, props:)
|
|
149
149
|
end
|
|
150
150
|
|
|
151
151
|
def add_vertex_for(obj)
|
|
@@ -231,7 +231,7 @@ module Nanoc
|
|
|
231
231
|
to = to_index && previous_refs[to_index]
|
|
232
232
|
props = Nanoc::Core::DependencyProps.new(**props)
|
|
233
233
|
|
|
234
|
-
@graph.add_edge(from, to, props:
|
|
234
|
+
@graph.add_edge(from, to, props:)
|
|
235
235
|
end
|
|
236
236
|
|
|
237
237
|
# Record dependency from all items on new items
|
|
@@ -49,10 +49,10 @@ module Nanoc
|
|
|
49
49
|
@dependency_store.record_dependency(
|
|
50
50
|
@stack.last,
|
|
51
51
|
obj,
|
|
52
|
-
raw_content
|
|
53
|
-
attributes
|
|
54
|
-
compiled_content
|
|
55
|
-
path
|
|
52
|
+
raw_content:,
|
|
53
|
+
attributes:,
|
|
54
|
+
compiled_content:,
|
|
55
|
+
path:,
|
|
56
56
|
)
|
|
57
57
|
end
|
|
58
58
|
|
|
@@ -66,7 +66,7 @@ module Nanoc
|
|
|
66
66
|
|
|
67
67
|
contract C_OBJ, C_ARGS => C::Any
|
|
68
68
|
def bounce(obj, raw_content: false, attributes: false, compiled_content: false, path: false)
|
|
69
|
-
enter(obj, raw_content
|
|
69
|
+
enter(obj, raw_content:, attributes:, compiled_content:, path:)
|
|
70
70
|
exit
|
|
71
71
|
end
|
|
72
72
|
|
|
@@ -48,7 +48,7 @@ module Nanoc
|
|
|
48
48
|
end
|
|
49
49
|
|
|
50
50
|
# @see Hash#fetch
|
|
51
|
-
def fetch(key, fallback = Nanoc::Core::UNDEFINED, &
|
|
51
|
+
def fetch(key, fallback = Nanoc::Core::UNDEFINED, &)
|
|
52
52
|
@context.dependency_tracker.bounce(_unwrap, attributes: [key])
|
|
53
53
|
|
|
54
54
|
if _unwrap.attributes.key?(key)
|
data/lib/nanoc/core/feature.rb
CHANGED
|
@@ -84,11 +84,11 @@ module Nanoc
|
|
|
84
84
|
def self.all_outdated
|
|
85
85
|
repo.keys.reject do |name|
|
|
86
86
|
version = repo[name]
|
|
87
|
-
Nanoc::VERSION.start_with?(version)
|
|
87
|
+
Nanoc::Core::VERSION.start_with?(version)
|
|
88
88
|
end
|
|
89
89
|
end
|
|
90
90
|
end
|
|
91
91
|
end
|
|
92
92
|
end
|
|
93
93
|
|
|
94
|
-
Nanoc::Core::Feature.define('where', version: '4.
|
|
94
|
+
Nanoc::Core::Feature.define('where', version: '4.13')
|
|
@@ -20,7 +20,7 @@ module Nanoc
|
|
|
20
20
|
# contract C::Or[Hash, C::Named['Nanoc::Core::Configuration']], C::IterOf[C::RespondTo[:identifier]], C::Maybe[String] => C::Any
|
|
21
21
|
def initialize_basic(config, objects = [], name = nil)
|
|
22
22
|
@config = config
|
|
23
|
-
@objects =
|
|
23
|
+
@objects = Immutable::Vector.new(objects)
|
|
24
24
|
@name = name
|
|
25
25
|
end
|
|
26
26
|
|
|
@@ -62,8 +62,8 @@ module Nanoc
|
|
|
62
62
|
end
|
|
63
63
|
|
|
64
64
|
# contract C::Func[C::RespondTo[:identifier] => C::Any] => self
|
|
65
|
-
def reject(&
|
|
66
|
-
self.class.new(@config, @objects.reject(&
|
|
65
|
+
def reject(&)
|
|
66
|
+
self.class.new(@config, @objects.reject(&))
|
|
67
67
|
end
|
|
68
68
|
|
|
69
69
|
def object_with_identifier(identifier)
|
|
@@ -49,10 +49,10 @@ module Nanoc
|
|
|
49
49
|
# @param [String, Regex] arg
|
|
50
50
|
#
|
|
51
51
|
# @return [Enumerable]
|
|
52
|
-
def find_all(arg = NOTHING, &
|
|
52
|
+
def find_all(arg = NOTHING, &)
|
|
53
53
|
if NOTHING.equal?(arg)
|
|
54
54
|
@context.dependency_tracker.bounce(_unwrap, raw_content: true)
|
|
55
|
-
return @objects.map { |i| view_class.new(i, @context) }.select(&
|
|
55
|
+
return @objects.map { |i| view_class.new(i, @context) }.select(&)
|
|
56
56
|
end
|
|
57
57
|
|
|
58
58
|
prop_attribute =
|
|
@@ -164,7 +164,7 @@ module Nanoc
|
|
|
164
164
|
end
|
|
165
165
|
|
|
166
166
|
s = File.extname(@string)
|
|
167
|
-
s && s[1
|
|
167
|
+
s && s[1..]
|
|
168
168
|
end
|
|
169
169
|
|
|
170
170
|
contract C::None => String
|
|
@@ -195,7 +195,7 @@ module Nanoc
|
|
|
195
195
|
if res.empty?
|
|
196
196
|
[]
|
|
197
197
|
else
|
|
198
|
-
res[1
|
|
198
|
+
res[1..]
|
|
199
199
|
end
|
|
200
200
|
end
|
|
201
201
|
|
data/lib/nanoc/core/item.rb
CHANGED
|
@@ -6,6 +6,25 @@ module Nanoc
|
|
|
6
6
|
class ItemRepBuilder
|
|
7
7
|
include Nanoc::Core::ContractsSupport
|
|
8
8
|
|
|
9
|
+
contract Nanoc::Core::ActionSequence, Nanoc::Core::ItemRep => C::ArrayOf[Nanoc::Core::SnapshotDef]
|
|
10
|
+
def self.snapshot_defs_for(action_sequence, rep)
|
|
11
|
+
is_binary = rep.item.content.binary?
|
|
12
|
+
snapshot_defs = []
|
|
13
|
+
|
|
14
|
+
action_sequence.each do |action|
|
|
15
|
+
case action
|
|
16
|
+
when Nanoc::Core::ProcessingActions::Snapshot
|
|
17
|
+
action.snapshot_names.each do |snapshot_name|
|
|
18
|
+
snapshot_defs << Nanoc::Core::SnapshotDef.new(snapshot_name, binary: is_binary)
|
|
19
|
+
end
|
|
20
|
+
when Nanoc::Core::ProcessingActions::Filter
|
|
21
|
+
is_binary = Nanoc::Core::Filter.named!(action.filter_name).to_binary?
|
|
22
|
+
end
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
snapshot_defs
|
|
26
|
+
end
|
|
27
|
+
|
|
9
28
|
attr_reader :reps
|
|
10
29
|
|
|
11
30
|
contract Nanoc::Core::Site, Nanoc::Core::ActionProvider, Nanoc::Core::ItemRepRepo => C::Any
|
|
@@ -30,25 +49,6 @@ module Nanoc
|
|
|
30
49
|
|
|
31
50
|
action_sequences
|
|
32
51
|
end
|
|
33
|
-
|
|
34
|
-
contract Nanoc::Core::ActionSequence, Nanoc::Core::ItemRep => C::ArrayOf[Nanoc::Core::SnapshotDef]
|
|
35
|
-
def self.snapshot_defs_for(action_sequence, rep)
|
|
36
|
-
is_binary = rep.item.content.binary?
|
|
37
|
-
snapshot_defs = []
|
|
38
|
-
|
|
39
|
-
action_sequence.each do |action|
|
|
40
|
-
case action
|
|
41
|
-
when Nanoc::Core::ProcessingActions::Snapshot
|
|
42
|
-
action.snapshot_names.each do |snapshot_name|
|
|
43
|
-
snapshot_defs << Nanoc::Core::SnapshotDef.new(snapshot_name, binary: is_binary)
|
|
44
|
-
end
|
|
45
|
-
when Nanoc::Core::ProcessingActions::Filter
|
|
46
|
-
is_binary = Nanoc::Core::Filter.named!(action.filter_name).to_binary?
|
|
47
|
-
end
|
|
48
|
-
end
|
|
49
|
-
|
|
50
|
-
snapshot_defs
|
|
51
|
-
end
|
|
52
52
|
end
|
|
53
53
|
end
|
|
54
54
|
end
|
data/lib/nanoc/core/layout.rb
CHANGED
|
@@ -25,7 +25,7 @@ module Nanoc
|
|
|
25
25
|
#
|
|
26
26
|
# @return [self]
|
|
27
27
|
def create(content, attributes, identifier, binary: false, filename: nil)
|
|
28
|
-
content = Nanoc::Core::Content.create(content, binary
|
|
28
|
+
content = Nanoc::Core::Content.create(content, binary:, filename:)
|
|
29
29
|
@objects = @objects.add(Nanoc::Core::Item.new(content, attributes, identifier))
|
|
30
30
|
self
|
|
31
31
|
end
|
|
@@ -53,7 +53,7 @@ module Nanoc
|
|
|
53
53
|
end
|
|
54
54
|
|
|
55
55
|
def on(name, id = nil, &block)
|
|
56
|
-
@notifications[name] << { id
|
|
56
|
+
@notifications[name] << { id:, block: }
|
|
57
57
|
end
|
|
58
58
|
|
|
59
59
|
def remove(name, id)
|
|
@@ -75,8 +75,8 @@ module Nanoc
|
|
|
75
75
|
@_instance ||= new.tap(&:start)
|
|
76
76
|
end
|
|
77
77
|
|
|
78
|
-
def on(name, id = nil, &
|
|
79
|
-
instance.on(name, id, &
|
|
78
|
+
def on(name, id = nil, &)
|
|
79
|
+
instance.on(name, id, &)
|
|
80
80
|
end
|
|
81
81
|
|
|
82
82
|
def post(name, *args)
|
|
@@ -80,8 +80,8 @@ module Nanoc
|
|
|
80
80
|
)
|
|
81
81
|
end
|
|
82
82
|
|
|
83
|
-
contract C_OBJ,
|
|
84
|
-
def outdated_due_to_dependencies?(obj, processed =
|
|
83
|
+
contract C_OBJ, Immutable::Set => C::Bool
|
|
84
|
+
def outdated_due_to_dependencies?(obj, processed = Immutable::Set.new)
|
|
85
85
|
# Convert from rep to item if necessary
|
|
86
86
|
obj = obj.item if obj.is_a?(Nanoc::Core::ItemRep)
|
|
87
87
|
|
|
@@ -168,7 +168,7 @@ module Nanoc
|
|
|
168
168
|
# outdatedness.
|
|
169
169
|
matching_objects.any? do |obj|
|
|
170
170
|
status = basic_outdatedness_statuses.fetch(obj)
|
|
171
|
-
status.reasons.any? { |r| Nanoc::Core::OutdatednessReasons::DocumentAdded
|
|
171
|
+
status.reasons.any? { |r| r == Nanoc::Core::OutdatednessReasons::DocumentAdded }
|
|
172
172
|
end
|
|
173
173
|
end
|
|
174
174
|
|
|
@@ -7,19 +7,16 @@ module Nanoc
|
|
|
7
7
|
include Nanoc::Core::ContractsSupport
|
|
8
8
|
include Singleton
|
|
9
9
|
|
|
10
|
-
def
|
|
11
|
-
|
|
12
|
-
apply(obj, outdatedness_checker)
|
|
13
|
-
end
|
|
10
|
+
def self.affects_path?
|
|
11
|
+
@affects_path
|
|
14
12
|
end
|
|
15
13
|
|
|
16
|
-
def
|
|
17
|
-
|
|
14
|
+
def self.affects_attributes?
|
|
15
|
+
@affects_attributes
|
|
18
16
|
end
|
|
19
17
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
"#{self.class.name}(#{reason})"
|
|
18
|
+
def self.affects_compiled_content?
|
|
19
|
+
@affects_compiled_content
|
|
23
20
|
end
|
|
24
21
|
|
|
25
22
|
def self.affects_props(*names)
|
|
@@ -46,16 +43,19 @@ module Nanoc
|
|
|
46
43
|
@affects_raw_content
|
|
47
44
|
end
|
|
48
45
|
|
|
49
|
-
def
|
|
50
|
-
|
|
46
|
+
def call(obj, outdatedness_checker)
|
|
47
|
+
Nanoc::Core::Instrumentor.call(:outdatedness_rule_ran, self.class) do
|
|
48
|
+
apply(obj, outdatedness_checker)
|
|
49
|
+
end
|
|
51
50
|
end
|
|
52
51
|
|
|
53
|
-
def
|
|
54
|
-
|
|
52
|
+
def apply(_obj, _outdatedness_checker)
|
|
53
|
+
raise NotImplementedError.new('Nanoc::Core::OutdatednessRule subclasses must implement #apply')
|
|
55
54
|
end
|
|
56
55
|
|
|
57
|
-
|
|
58
|
-
|
|
56
|
+
contract C::None => String
|
|
57
|
+
def inspect
|
|
58
|
+
"#{self.class.name}(#{reason})"
|
|
59
59
|
end
|
|
60
60
|
end
|
|
61
61
|
end
|
|
@@ -8,7 +8,7 @@ module Nanoc
|
|
|
8
8
|
|
|
9
9
|
contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
|
|
10
10
|
def initialize(config:)
|
|
11
|
-
super(Nanoc::Core::Store.tmp_path_for(config
|
|
11
|
+
super(Nanoc::Core::Store.tmp_path_for(config:, store_name: 'outdatedness'), 2)
|
|
12
12
|
|
|
13
13
|
@outdated_refs = Set.new
|
|
14
14
|
end
|
data/lib/nanoc/core/pruner.rb
CHANGED
|
@@ -3,17 +3,16 @@
|
|
|
3
3
|
module Nanoc
|
|
4
4
|
module Core
|
|
5
5
|
class SiteLoader
|
|
6
|
-
ENCODING_REGEX = /\A#\s+(-\*-\s+)?(en)?coding: (?<encoding>[^\s]+)(\s+-\*-\s*)?\n{0,2}
|
|
7
|
-
|
|
8
|
-
def new_from_cwd
|
|
9
|
-
site_from_config(Nanoc::Core::ConfigLoader.new.new_from_cwd)
|
|
10
|
-
end
|
|
11
|
-
|
|
6
|
+
ENCODING_REGEX = /\A#\s+(-\*-\s+)?(en)?coding: (?<encoding>[^\s]+)(\s+-\*-\s*)?\n{0,2}/
|
|
12
7
|
# @return [Boolean]
|
|
13
8
|
def self.cwd_is_nanoc_site?
|
|
14
9
|
Nanoc::Core::ConfigLoader.cwd_is_nanoc_site?
|
|
15
10
|
end
|
|
16
11
|
|
|
12
|
+
def new_from_cwd
|
|
13
|
+
site_from_config(Nanoc::Core::ConfigLoader.new.new_from_cwd)
|
|
14
|
+
end
|
|
15
|
+
|
|
17
16
|
def gen_data_source_for_config(config)
|
|
18
17
|
data_sources_to_aggregate =
|
|
19
18
|
with_data_sources(config) do |data_sources|
|
|
@@ -34,13 +33,13 @@ module Nanoc
|
|
|
34
33
|
data_source = gen_data_source_for_config(config)
|
|
35
34
|
|
|
36
35
|
Nanoc::Core::Site.new(
|
|
37
|
-
config
|
|
38
|
-
code_snippets
|
|
39
|
-
data_source
|
|
36
|
+
config:,
|
|
37
|
+
code_snippets:,
|
|
38
|
+
data_source:,
|
|
40
39
|
)
|
|
41
40
|
end
|
|
42
41
|
|
|
43
|
-
def with_data_sources(config, &
|
|
42
|
+
def with_data_sources(config, &)
|
|
44
43
|
data_sources = create_data_sources(config)
|
|
45
44
|
|
|
46
45
|
begin
|
data/lib/nanoc/core/store.rb
CHANGED
|
@@ -13,6 +13,22 @@ module Nanoc
|
|
|
13
13
|
class Store
|
|
14
14
|
include Nanoc::Core::ContractsSupport
|
|
15
15
|
|
|
16
|
+
# Logic for building tmp path from active environment and store name
|
|
17
|
+
# @api private
|
|
18
|
+
contract C::KeywordArgs[config: Nanoc::Core::Configuration, store_name: String] => C::AbsolutePathString
|
|
19
|
+
def self.tmp_path_for(store_name:, config:)
|
|
20
|
+
File.absolute_path(
|
|
21
|
+
File.join(tmp_path_prefix(config.output_dir), store_name),
|
|
22
|
+
config.dir,
|
|
23
|
+
)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
contract String => String
|
|
27
|
+
def self.tmp_path_prefix(output_dir)
|
|
28
|
+
dir = Digest::SHA1.hexdigest(output_dir)[0..12]
|
|
29
|
+
File.join('tmp', 'nanoc', dir)
|
|
30
|
+
end
|
|
31
|
+
|
|
16
32
|
# @return [String] The name of the file where data will be loaded from and
|
|
17
33
|
# stored to.
|
|
18
34
|
attr_reader :filename
|
|
@@ -35,22 +51,6 @@ module Nanoc
|
|
|
35
51
|
@version = version
|
|
36
52
|
end
|
|
37
53
|
|
|
38
|
-
# Logic for building tmp path from active environment and store name
|
|
39
|
-
# @api private
|
|
40
|
-
contract C::KeywordArgs[config: Nanoc::Core::Configuration, store_name: String] => C::AbsolutePathString
|
|
41
|
-
def self.tmp_path_for(store_name:, config:)
|
|
42
|
-
File.absolute_path(
|
|
43
|
-
File.join(tmp_path_prefix(config.output_dir), store_name),
|
|
44
|
-
config.dir,
|
|
45
|
-
)
|
|
46
|
-
end
|
|
47
|
-
|
|
48
|
-
contract String => String
|
|
49
|
-
def self.tmp_path_prefix(output_dir)
|
|
50
|
-
dir = Digest::SHA1.hexdigest(output_dir)[0..12]
|
|
51
|
-
File.join('tmp', 'nanoc', dir)
|
|
52
|
-
end
|
|
53
|
-
|
|
54
54
|
# @group Loading and storing data
|
|
55
55
|
|
|
56
56
|
# @return The data that should be written to the disk
|
|
@@ -11,7 +11,7 @@ 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
|
|
14
|
+
super(Nanoc::Core::Store.tmp_path_for(config:, store_name: 'compiled_content'), 4)
|
|
15
15
|
|
|
16
16
|
@cache = {}
|
|
17
17
|
end
|
data/lib/nanoc/core/version.rb
CHANGED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Nanoc
|
|
4
|
+
module Core
|
|
5
|
+
# @api private
|
|
6
|
+
module YamlLoader
|
|
7
|
+
OPTIONS = {
|
|
8
|
+
permitted_classes: [Symbol, Date, Time].freeze,
|
|
9
|
+
aliases: true,
|
|
10
|
+
}.freeze
|
|
11
|
+
|
|
12
|
+
private_constant :OPTIONS
|
|
13
|
+
|
|
14
|
+
def self.load(yaml_string)
|
|
15
|
+
YAML.safe_load(yaml_string, **OPTIONS)
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
def self.load_file(filename)
|
|
19
|
+
YAML.safe_load_file(filename, **OPTIONS)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
end
|
|
23
|
+
end
|
data/lib/nanoc/core.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
# Ruby stdlib
|
|
4
|
+
require 'base64'
|
|
4
5
|
require 'fiber'
|
|
5
6
|
require 'find'
|
|
6
7
|
require 'pstore'
|
|
@@ -14,7 +15,7 @@ require 'concurrent-ruby'
|
|
|
14
15
|
require 'json_schema'
|
|
15
16
|
require 'ddmetrics'
|
|
16
17
|
require 'ddplugin'
|
|
17
|
-
require '
|
|
18
|
+
require 'immutable'
|
|
18
19
|
require 'memo_wise'
|
|
19
20
|
require 'slow_enumerator_tools'
|
|
20
21
|
require 'tty-platform'
|
|
@@ -47,7 +48,7 @@ module Nanoc
|
|
|
47
48
|
#
|
|
48
49
|
# @api private
|
|
49
50
|
def self.version_information
|
|
50
|
-
"Nanoc #{Nanoc::VERSION} © 2007
|
|
51
|
+
"Nanoc #{Nanoc::Core::VERSION} © 2007–… Denis Defreyne.\n" \
|
|
51
52
|
"Running #{RUBY_ENGINE} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} with RubyGems #{Gem::VERSION}.\n"
|
|
52
53
|
end
|
|
53
54
|
|