nanoc 4.11.0 → 4.11.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/NEWS.md +6 -0
- data/lib/nanoc.rb +4 -7
- data/lib/nanoc/base.rb +3 -3
- data/lib/nanoc/base/assertions.rb +1 -1
- data/lib/nanoc/base/entities.rb +2 -20
- data/lib/nanoc/base/entities/action_sequence.rb +60 -64
- data/lib/nanoc/base/entities/checksum_collection.rb +23 -21
- data/lib/nanoc/base/entities/dependency.rb +24 -22
- data/lib/nanoc/base/entities/outdatedness_reasons.rb +74 -72
- data/lib/nanoc/base/entities/outdatedness_status.rb +19 -17
- data/lib/nanoc/base/entities/props.rb +119 -117
- data/lib/nanoc/base/entities/site.rb +46 -50
- data/lib/nanoc/base/errors.rb +183 -198
- data/lib/nanoc/base/repos.rb +4 -2
- data/lib/nanoc/base/repos/action_sequence_store.rb +44 -42
- data/lib/nanoc/base/repos/aggregate_data_source.rb +24 -22
- data/lib/nanoc/base/repos/checksum_store.rb +51 -49
- data/lib/nanoc/base/repos/compiled_content_cache.rb +47 -45
- data/lib/nanoc/base/repos/compiled_content_store.rb +76 -0
- data/lib/nanoc/base/repos/config_loader.rb +74 -72
- data/lib/nanoc/base/repos/dependency_store.rb +174 -172
- data/lib/nanoc/base/repos/in_mem_data_source.rb +17 -15
- data/lib/nanoc/base/repos/item_rep_repo.rb +26 -24
- data/lib/nanoc/base/repos/outdatedness_store.rb +50 -48
- data/lib/nanoc/base/repos/prefixed_data_source.rb +21 -19
- data/lib/nanoc/base/repos/site_loader.rb +75 -73
- data/lib/nanoc/base/repos/store.rb +93 -91
- data/lib/nanoc/base/services.rb +7 -3
- data/lib/nanoc/base/services/action_provider.rb +23 -21
- data/lib/nanoc/base/services/action_sequence_builder.rb +42 -34
- data/lib/nanoc/base/services/compilation_context.rb +49 -47
- data/lib/nanoc/base/services/compiler.rb +177 -170
- data/lib/nanoc/base/services/compiler/phases.rb +8 -1
- data/lib/nanoc/base/services/compiler/phases/abstract.rb +44 -38
- data/lib/nanoc/base/services/compiler/phases/cache.rb +34 -28
- data/lib/nanoc/base/services/compiler/phases/mark_done.rb +17 -11
- data/lib/nanoc/base/services/compiler/phases/notify.rb +21 -0
- data/lib/nanoc/base/services/compiler/phases/recalculate.rb +37 -31
- data/lib/nanoc/base/services/compiler/phases/resume.rb +47 -48
- data/lib/nanoc/base/services/compiler/phases/write.rb +65 -59
- data/lib/nanoc/base/services/compiler/stage.rb +27 -8
- data/lib/nanoc/base/services/compiler/stages.rb +7 -1
- data/lib/nanoc/base/services/compiler/stages/build_reps.rb +25 -19
- data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +34 -28
- data/lib/nanoc/base/services/compiler/stages/cleanup.rb +33 -27
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +79 -69
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +46 -40
- data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +15 -9
- data/lib/nanoc/base/services/compiler/stages/load_stores.rb +28 -22
- data/lib/nanoc/base/services/compiler/stages/postprocess.rb +16 -10
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +25 -19
- data/lib/nanoc/base/services/compiler/stages/prune.rb +23 -17
- data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +15 -9
- data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +26 -20
- data/lib/nanoc/base/services/compiler_loader.rb +26 -24
- data/lib/nanoc/base/services/dependency_tracker.rb +47 -45
- data/lib/nanoc/base/services/executor.rb +16 -15
- data/lib/nanoc/base/services/filter.rb +37 -5
- data/lib/nanoc/base/services/instrumentor.rb +12 -10
- data/lib/nanoc/base/services/item_rep_builder.rb +21 -19
- data/lib/nanoc/base/services/item_rep_router.rb +72 -70
- data/lib/nanoc/base/services/item_rep_selector.rb +48 -46
- data/lib/nanoc/base/services/item_rep_writer.rb +58 -53
- data/lib/nanoc/base/services/outdatedness_checker.rb +181 -179
- data/lib/nanoc/base/services/outdatedness_rule.rb +23 -21
- data/lib/nanoc/base/services/outdatedness_rules.rb +5 -3
- data/lib/nanoc/base/services/outdatedness_rules/attributes_modified.rb +28 -24
- data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +20 -16
- data/lib/nanoc/base/services/outdatedness_rules/content_modified.rb +13 -9
- data/lib/nanoc/base/services/outdatedness_rules/item_collection_extended.rb +12 -8
- data/lib/nanoc/base/services/outdatedness_rules/layout_collection_extended.rb +12 -8
- data/lib/nanoc/base/services/outdatedness_rules/not_written.rb +10 -6
- data/lib/nanoc/base/services/outdatedness_rules/rules_modified.rb +39 -35
- data/lib/nanoc/base/services/outdatedness_rules/uses_always_outdated_filter.rb +19 -15
- data/lib/nanoc/base/services/pruner.rb +2 -2
- data/lib/nanoc/base/views.rb +7 -0
- data/lib/nanoc/base/views/basic_item_view.rb +1 -1
- data/lib/nanoc/base/views/compilation_item_rep_view.rb +2 -2
- data/lib/nanoc/base/views/identifiable_collection_view.rb +2 -2
- data/lib/nanoc/base/views/mixins/document_view_mixin.rb +1 -1
- data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +5 -5
- data/lib/nanoc/base/views/mutable_item_collection_view.rb +3 -3
- data/lib/nanoc/base/views/mutable_layout_collection_view.rb +2 -2
- data/lib/nanoc/base/views/view_context_for_compilation.rb +6 -6
- data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +2 -2
- data/lib/nanoc/base/views/view_context_for_shell.rb +2 -2
- data/lib/nanoc/checking/check.rb +1 -1
- data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +24 -7
- data/lib/nanoc/cli/commands/compile_listeners/debug_printer.rb +79 -15
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +4 -7
- data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +15 -24
- data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +22 -18
- data/lib/nanoc/cli/commands/create-site.rb +2 -7
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/cli/commands/show-data.rb +9 -9
- data/lib/nanoc/cli/logger.rb +1 -1
- data/lib/nanoc/data_sources/filesystem.rb +8 -8
- data/lib/nanoc/filters/erb.rb +1 -1
- data/lib/nanoc/filters/erubi.rb +1 -1
- data/lib/nanoc/filters/erubis.rb +1 -1
- data/lib/nanoc/filters/haml.rb +1 -1
- data/lib/nanoc/filters/sass.rb +1 -1
- data/lib/nanoc/filters/slim.rb +1 -1
- data/lib/nanoc/helpers/breadcrumbs.rb +2 -2
- data/lib/nanoc/helpers/capturing.rb +9 -8
- data/lib/nanoc/helpers/filtering.rb +2 -2
- data/lib/nanoc/helpers/rendering.rb +1 -1
- data/lib/nanoc/rule_dsl.rb +10 -0
- data/lib/nanoc/rule_dsl/action_provider.rb +3 -3
- data/lib/nanoc/rule_dsl/action_recorder.rb +3 -3
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +7 -7
- data/lib/nanoc/rule_dsl/compilation_rule.rb +2 -2
- data/lib/nanoc/rule_dsl/compilation_rule_context.rb +9 -9
- data/lib/nanoc/rule_dsl/compiler_dsl.rb +4 -4
- data/lib/nanoc/rule_dsl/routing_rule.rb +3 -3
- data/lib/nanoc/rule_dsl/rule.rb +5 -5
- data/lib/nanoc/rule_dsl/rule_context.rb +3 -3
- data/lib/nanoc/rule_dsl/rules_collection.rb +4 -4
- data/lib/nanoc/spec.rb +15 -15
- data/lib/nanoc/version.rb +1 -1
- metadata +10 -111
- data/lib/nanoc/base/contracts_support.rb +0 -130
- data/lib/nanoc/base/core_ext.rb +0 -5
- data/lib/nanoc/base/core_ext/array.rb +0 -50
- data/lib/nanoc/base/core_ext/hash.rb +0 -54
- data/lib/nanoc/base/core_ext/string.rb +0 -16
- data/lib/nanoc/base/entities/code_snippet.rb +0 -53
- data/lib/nanoc/base/entities/configuration-schema.json +0 -122
- data/lib/nanoc/base/entities/configuration.rb +0 -206
- data/lib/nanoc/base/entities/content.rb +0 -112
- data/lib/nanoc/base/entities/context.rb +0 -70
- data/lib/nanoc/base/entities/directed_graph.rb +0 -195
- data/lib/nanoc/base/entities/document.rb +0 -125
- data/lib/nanoc/base/entities/identifiable_collection.rb +0 -141
- data/lib/nanoc/base/entities/identifier.rb +0 -222
- data/lib/nanoc/base/entities/item.rb +0 -10
- data/lib/nanoc/base/entities/item_collection.rb +0 -14
- data/lib/nanoc/base/entities/item_rep.rb +0 -91
- data/lib/nanoc/base/entities/layout.rb +0 -10
- data/lib/nanoc/base/entities/layout_collection.rb +0 -14
- data/lib/nanoc/base/entities/lazy_value.rb +0 -43
- data/lib/nanoc/base/entities/pattern.rb +0 -85
- data/lib/nanoc/base/entities/processing_action.rb +0 -21
- data/lib/nanoc/base/entities/processing_actions.rb +0 -5
- data/lib/nanoc/base/entities/processing_actions/filter.rb +0 -36
- data/lib/nanoc/base/entities/processing_actions/layout.rb +0 -36
- data/lib/nanoc/base/entities/processing_actions/snapshot.rb +0 -46
- data/lib/nanoc/base/entities/snapshot_def.rb +0 -22
- data/lib/nanoc/base/repos/data_source.rb +0 -168
- data/lib/nanoc/base/repos/snapshot_repo.rb +0 -67
- data/lib/nanoc/base/services/checksummer.rb +0 -274
- data/lib/nanoc/base/services/notification_center.rb +0 -87
- data/lib/nanoc/base/services/temp_filename_factory.rb +0 -52
@@ -12,7 +12,7 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
12
12
|
Nanoc::CLI.verbosity >= 1
|
13
13
|
end
|
14
14
|
|
15
|
-
# @param [Enumerable<Nanoc::
|
15
|
+
# @param [Enumerable<Nanoc::Core::ItemRep>] reps
|
16
16
|
def initialize(reps:)
|
17
17
|
@reps = reps
|
18
18
|
|
@@ -52,7 +52,7 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
52
52
|
@load_stores_summary.observe(duration, name: klass.to_s)
|
53
53
|
end
|
54
54
|
|
55
|
-
on(:compilation_suspended) do |rep,
|
55
|
+
on(:compilation_suspended) do |rep, _target_rep, _snapshot_name|
|
56
56
|
filter_stopwatches.fetch(rep).each(&:stop)
|
57
57
|
end
|
58
58
|
|
@@ -60,46 +60,50 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
60
60
|
filter_stopwatches.fetch(rep, []).each(&:start)
|
61
61
|
end
|
62
62
|
|
63
|
-
|
63
|
+
setup_phase_notifications
|
64
|
+
end
|
65
|
+
|
66
|
+
# @see Listener#stop
|
67
|
+
def stop
|
68
|
+
print_profiling_feedback
|
69
|
+
end
|
70
|
+
|
71
|
+
protected
|
72
|
+
|
73
|
+
def setup_phase_notifications
|
74
|
+
stopwatches = {}
|
64
75
|
|
65
76
|
on(:phase_started) do |phase_name, rep|
|
66
|
-
|
67
|
-
|
77
|
+
stopwatch = stopwatches[[phase_name, rep]] = DDMetrics::Stopwatch.new
|
78
|
+
stopwatch.start
|
68
79
|
end
|
69
80
|
|
70
81
|
on(:phase_ended) do |phase_name, rep|
|
71
|
-
stopwatch =
|
82
|
+
stopwatch = stopwatches[[phase_name, rep]]
|
72
83
|
stopwatch.stop
|
73
84
|
|
74
85
|
@phases_summary.observe(stopwatch.duration, name: phase_name)
|
75
86
|
end
|
76
87
|
|
77
88
|
on(:phase_yielded) do |phase_name, rep|
|
78
|
-
stopwatch =
|
89
|
+
stopwatch = stopwatches[[phase_name, rep]]
|
79
90
|
stopwatch.stop
|
80
91
|
end
|
81
92
|
|
82
93
|
on(:phase_resumed) do |phase_name, rep|
|
83
|
-
|
84
|
-
stopwatch
|
94
|
+
# It probably looks weird that a phase can be resumed even though it was not suspended earlier. This can happen when compilation is suspended, where you’d get the sequence started -> suspended -> started -> resumed.
|
95
|
+
stopwatch = stopwatches[[phase_name, rep]]
|
96
|
+
stopwatch.start unless stopwatch.running?
|
85
97
|
end
|
86
98
|
|
87
99
|
on(:phase_aborted) do |phase_name, rep|
|
88
|
-
stopwatch =
|
100
|
+
stopwatch = stopwatches[[phase_name, rep]]
|
89
101
|
stopwatch.stop if stopwatch.running?
|
90
102
|
|
91
103
|
@phases_summary.observe(stopwatch.duration, name: phase_name)
|
92
104
|
end
|
93
105
|
end
|
94
106
|
|
95
|
-
# @see Listener#stop
|
96
|
-
def stop
|
97
|
-
print_profiling_feedback
|
98
|
-
super
|
99
|
-
end
|
100
|
-
|
101
|
-
protected
|
102
|
-
|
103
107
|
def table_for_summary(name, summary)
|
104
108
|
headers = [name.to_s, 'count', 'min', '.50', '.90', '.95', 'max', 'tot']
|
105
109
|
|
@@ -22,7 +22,7 @@ module Nanoc::CLI::Commands
|
|
22
22
|
# A list of file extensions that Nanoc will consider to be textual rather than
|
23
23
|
# binary. If an item with an extension not in this list is found, the file
|
24
24
|
# will be considered as binary.
|
25
|
-
text_extensions: #{array_to_yaml(Nanoc::
|
25
|
+
text_extensions: #{array_to_yaml(Nanoc::Core::Configuration::DEFAULT_CONFIG[:text_extensions])}
|
26
26
|
|
27
27
|
prune:
|
28
28
|
auto_prune: true
|
@@ -227,11 +227,6 @@ module Nanoc::CLI::Commands
|
|
227
227
|
)
|
228
228
|
end
|
229
229
|
|
230
|
-
# Setup notifications
|
231
|
-
Nanoc::Int::NotificationCenter.on(:file_created) do |file_path|
|
232
|
-
Nanoc::CLI::Logger.instance.file(:high, :create, file_path)
|
233
|
-
end
|
234
|
-
|
235
230
|
# Build entire site
|
236
231
|
FileUtils.mkdir_p(path)
|
237
232
|
FileUtils.cd(File.join(path)) do
|
@@ -254,7 +249,7 @@ module Nanoc::CLI::Commands
|
|
254
249
|
|
255
250
|
def write(filename, content)
|
256
251
|
File.write(filename, content)
|
257
|
-
Nanoc::
|
252
|
+
Nanoc::CLI::Logger.instance.file(:high, :create, filename)
|
258
253
|
end
|
259
254
|
end
|
260
255
|
end
|
@@ -70,7 +70,7 @@ module Nanoc::CLI::Commands
|
|
70
70
|
sorter =
|
71
71
|
lambda do |dep|
|
72
72
|
case dep
|
73
|
-
when Nanoc::
|
73
|
+
when Nanoc::Core::Document
|
74
74
|
dep.from.identifier.to_s
|
75
75
|
else
|
76
76
|
''
|
@@ -89,15 +89,15 @@ module Nanoc::CLI::Commands
|
|
89
89
|
|
90
90
|
type =
|
91
91
|
case pred
|
92
|
-
when Nanoc::
|
92
|
+
when Nanoc::Core::Layout
|
93
93
|
'layout'
|
94
|
-
when Nanoc::
|
94
|
+
when Nanoc::Core::Item
|
95
95
|
'item'
|
96
|
-
when Nanoc::
|
96
|
+
when Nanoc::Core::Configuration
|
97
97
|
'config'
|
98
|
-
when Nanoc::
|
98
|
+
when Nanoc::Core::ItemCollection
|
99
99
|
'items'
|
100
|
-
when Nanoc::
|
100
|
+
when Nanoc::Core::LayoutCollection
|
101
101
|
'layouts'
|
102
102
|
else
|
103
103
|
raise Nanoc::Int::Errors::InternalInconsistency, "unexpected pred type #{pred}"
|
@@ -105,11 +105,11 @@ module Nanoc::CLI::Commands
|
|
105
105
|
|
106
106
|
pred_identifier =
|
107
107
|
case pred
|
108
|
-
when Nanoc::
|
108
|
+
when Nanoc::Core::Document
|
109
109
|
pred.identifier.to_s
|
110
|
-
when Nanoc::
|
110
|
+
when Nanoc::Core::Configuration
|
111
111
|
nil
|
112
|
-
when Nanoc::
|
112
|
+
when Nanoc::Core::IdentifiableCollection
|
113
113
|
case dep.props.raw_content
|
114
114
|
when true
|
115
115
|
'matching any'
|
data/lib/nanoc/cli/logger.rb
CHANGED
@@ -66,12 +66,12 @@ module Nanoc::DataSources
|
|
66
66
|
|
67
67
|
# See {Nanoc::DataSource#items}.
|
68
68
|
def items
|
69
|
-
load_objects(content_dir_name, Nanoc::
|
69
|
+
load_objects(content_dir_name, Nanoc::Core::Item)
|
70
70
|
end
|
71
71
|
|
72
72
|
# See {Nanoc::DataSource#layouts}.
|
73
73
|
def layouts
|
74
|
-
load_objects(layouts_dir_name, Nanoc::
|
74
|
+
load_objects(layouts_dir_name, Nanoc::Core::Layout)
|
75
75
|
end
|
76
76
|
|
77
77
|
def item_changes
|
@@ -141,11 +141,11 @@ module Nanoc::DataSources
|
|
141
141
|
def read_proto_document(content_filename, meta_filename, klass)
|
142
142
|
is_binary = content_filename && !@site_config[:text_extensions].include?(File.extname(content_filename)[1..-1])
|
143
143
|
|
144
|
-
if is_binary && klass == Nanoc::
|
144
|
+
if is_binary && klass == Nanoc::Core::Item
|
145
145
|
meta = (meta_filename && YAML.load_file(meta_filename)) || {}
|
146
146
|
|
147
147
|
ProtoDocument.new(is_binary: true, filename: content_filename, attributes: meta)
|
148
|
-
elsif is_binary && klass == Nanoc::
|
148
|
+
elsif is_binary && klass == Nanoc::Core::Layout
|
149
149
|
raise Errors::BinaryLayout.new(content_filename)
|
150
150
|
else
|
151
151
|
parse_result = parse(content_filename, meta_filename)
|
@@ -261,9 +261,9 @@ module Nanoc::DataSources
|
|
261
261
|
full_content_filename = content_filename && File.expand_path(content_filename)
|
262
262
|
|
263
263
|
if proto_doc.binary?
|
264
|
-
Nanoc::
|
264
|
+
Nanoc::Core::BinaryContent.new(full_content_filename)
|
265
265
|
else
|
266
|
-
Nanoc::
|
266
|
+
Nanoc::Core::TextualContent.new(proto_doc.content, filename: full_content_filename)
|
267
267
|
end
|
268
268
|
end
|
269
269
|
|
@@ -351,7 +351,7 @@ module Nanoc::DataSources
|
|
351
351
|
# can be the content filename or the meta filename.
|
352
352
|
def identifier_for_filename(filename)
|
353
353
|
if config[:identifier_type] == 'full'
|
354
|
-
return Nanoc::Identifier.new(filename)
|
354
|
+
return Nanoc::Core::Identifier.new(filename)
|
355
355
|
end
|
356
356
|
|
357
357
|
regex =
|
@@ -360,7 +360,7 @@ module Nanoc::DataSources
|
|
360
360
|
else
|
361
361
|
allow_periods_in_identifiers? ? /\.[^\/\.]+$/ : /\.[^\/]+$/
|
362
362
|
end
|
363
|
-
Nanoc::Identifier.new(filename.sub(regex, ''), type: :legacy)
|
363
|
+
Nanoc::Core::Identifier.new(filename.sub(regex, ''), type: :legacy)
|
364
364
|
end
|
365
365
|
|
366
366
|
# Returns the base name of filename, i.e. filename with the first or all
|
data/lib/nanoc/filters/erb.rb
CHANGED
@@ -22,7 +22,7 @@ module Nanoc::Filters
|
|
22
22
|
assigns.merge!(params[:locals] || {})
|
23
23
|
|
24
24
|
# Create context
|
25
|
-
context = ::Nanoc::
|
25
|
+
context = ::Nanoc::Core::Context.new(assigns)
|
26
26
|
|
27
27
|
# Get binding
|
28
28
|
proc = assigns[:content] ? -> { assigns[:content] } : nil
|
data/lib/nanoc/filters/erubi.rb
CHANGED
@@ -16,7 +16,7 @@ module Nanoc::Filters
|
|
16
16
|
# @return [String] The filtered content
|
17
17
|
def run(content, params = {})
|
18
18
|
# Create context
|
19
|
-
context = ::Nanoc::
|
19
|
+
context = ::Nanoc::Core::Context.new(assigns)
|
20
20
|
|
21
21
|
# Get binding
|
22
22
|
proc = assigns[:content] ? -> { assigns[:content] } : nil
|
data/lib/nanoc/filters/erubis.rb
CHANGED
@@ -15,7 +15,7 @@ module Nanoc::Filters
|
|
15
15
|
# @return [String] The filtered content
|
16
16
|
def run(content, _params = {})
|
17
17
|
# Create context
|
18
|
-
context = ::Nanoc::
|
18
|
+
context = ::Nanoc::Core::Context.new(assigns)
|
19
19
|
|
20
20
|
# Get binding
|
21
21
|
proc = assigns[:content] ? -> { assigns[:content] } : nil
|
data/lib/nanoc/filters/haml.rb
CHANGED
@@ -18,7 +18,7 @@ module Nanoc::Filters
|
|
18
18
|
options = params.merge(filename: filename)
|
19
19
|
|
20
20
|
# Create context
|
21
|
-
context = ::Nanoc::
|
21
|
+
context = ::Nanoc::Core::Context.new(assigns)
|
22
22
|
|
23
23
|
# Get result
|
24
24
|
proc = assigns[:content] ? -> { assigns[:content] } : nil
|
data/lib/nanoc/filters/sass.rb
CHANGED
@@ -28,7 +28,7 @@ module Nanoc::Filters
|
|
28
28
|
css_path = options.delete(:css_path) || filter.object_id.to_s
|
29
29
|
sourcemap_path = options.delete(:sourcemap_path)
|
30
30
|
if sourcemap_path == :inline
|
31
|
-
sourcemap_path = Nanoc::
|
31
|
+
sourcemap_path = Nanoc::Core::TempFilenameFactory.instance.create('sass_sourcemap')
|
32
32
|
inline = true
|
33
33
|
end
|
34
34
|
|
data/lib/nanoc/filters/slim.rb
CHANGED
@@ -20,7 +20,7 @@ module Nanoc::Filters
|
|
20
20
|
}.merge params
|
21
21
|
|
22
22
|
# Create context
|
23
|
-
context = ::Nanoc::
|
23
|
+
context = ::Nanoc::Core::Context.new(assigns)
|
24
24
|
|
25
25
|
::Slim::Template.new(filename, params) { content }.render(context) { assigns[:content] }
|
26
26
|
end
|
@@ -49,7 +49,7 @@ module Nanoc::Helpers
|
|
49
49
|
def self.patterns_for_prefix(prefix)
|
50
50
|
prefixes =
|
51
51
|
unfold(prefix) do |old_prefix|
|
52
|
-
new_prefix = Nanoc::Identifier.new(old_prefix).without_ext
|
52
|
+
new_prefix = Nanoc::Core::Identifier.new(old_prefix).without_ext
|
53
53
|
new_prefix == old_prefix ? nil : new_prefix
|
54
54
|
end
|
55
55
|
|
@@ -110,7 +110,7 @@ module Nanoc::Helpers
|
|
110
110
|
tiebreaker = Int::ERROR_TIEBREAKER if tiebreaker == :error
|
111
111
|
|
112
112
|
if @item.identifier.legacy?
|
113
|
-
prefixes.map { |pr| @items[Nanoc::Identifier.new('/' + pr, type: :legacy)] }
|
113
|
+
prefixes.map { |pr| @items[Nanoc::Core::Identifier.new('/' + pr, type: :legacy)] }
|
114
114
|
else
|
115
115
|
ancestral_prefixes = prefixes.reject { |pr| pr =~ /^\/index\./ }[0..-2]
|
116
116
|
ancestral_items =
|
@@ -20,7 +20,7 @@ module Nanoc::Helpers
|
|
20
20
|
content_string = capture(&block)
|
21
21
|
|
22
22
|
# Get existing contents and prep for store
|
23
|
-
|
23
|
+
compiled_content_store = @item._context.compiled_content_store
|
24
24
|
rep = @item.reps[:default]._unwrap
|
25
25
|
capture_name = "__capture_#{@name}".to_sym
|
26
26
|
old_content_string =
|
@@ -28,10 +28,10 @@ module Nanoc::Helpers
|
|
28
28
|
when :overwrite
|
29
29
|
''
|
30
30
|
when :append
|
31
|
-
c =
|
31
|
+
c = compiled_content_store.get(rep, capture_name)
|
32
32
|
c ? c.string : ''
|
33
33
|
when :error
|
34
|
-
contents =
|
34
|
+
contents = compiled_content_store.get(rep, capture_name)
|
35
35
|
if contents && contents.string != content_string
|
36
36
|
# FIXME: get proper exception
|
37
37
|
raise "a capture named #{@name.inspect} for #{@item.identifier} already exists"
|
@@ -44,8 +44,8 @@ module Nanoc::Helpers
|
|
44
44
|
end
|
45
45
|
|
46
46
|
# Store
|
47
|
-
new_content = Nanoc::
|
48
|
-
|
47
|
+
new_content = Nanoc::Core::TextualContent.new(old_content_string + content_string)
|
48
|
+
compiled_content_store.set(rep, capture_name, new_content)
|
49
49
|
end
|
50
50
|
end
|
51
51
|
|
@@ -67,13 +67,14 @@ module Nanoc::Helpers
|
|
67
67
|
dependency_tracker.bounce(@requested_item._unwrap, compiled_content: true)
|
68
68
|
|
69
69
|
unless rep.compiled?
|
70
|
-
|
70
|
+
# FIXME: is :last appropriate?
|
71
|
+
Fiber.yield(Nanoc::Int::Errors::UnmetDependency.new(rep, :last))
|
71
72
|
return run
|
72
73
|
end
|
73
74
|
end
|
74
75
|
|
75
|
-
|
76
|
-
content =
|
76
|
+
compiled_content_store = @config._context.compiled_content_store
|
77
|
+
content = compiled_content_store.get(rep, "__capture_#{@name}".to_sym)
|
77
78
|
content ? content.string : nil
|
78
79
|
end
|
79
80
|
end
|
@@ -30,9 +30,9 @@ module Nanoc::Helpers
|
|
30
30
|
filter = klass.new(assigns)
|
31
31
|
|
32
32
|
# Filter captured data
|
33
|
-
Nanoc::
|
33
|
+
Nanoc::Core::NotificationCenter.post(:filtering_started, @item_rep._unwrap, filter_name)
|
34
34
|
filtered_data = filter.setup_and_run(data, arguments)
|
35
|
-
Nanoc::
|
35
|
+
Nanoc::Core::NotificationCenter.post(:filtering_ended, @item_rep._unwrap, filter_name)
|
36
36
|
|
37
37
|
# Append filtered data to buffer
|
38
38
|
buffer = eval('_erbout', block.binding)
|
@@ -10,7 +10,7 @@ module Nanoc::Helpers
|
|
10
10
|
#
|
11
11
|
# @raise [Nanoc::Int::Errors::UnknownLayout]
|
12
12
|
# @raise [Nanoc::Int::Errors::CannotDetermineFilter]
|
13
|
-
# @raise [Nanoc::
|
13
|
+
# @raise [Nanoc::Filter::UnknownFilter]
|
14
14
|
#
|
15
15
|
# @return [String, nil]
|
16
16
|
def render(identifier, other_assigns = {}, &block)
|
data/lib/nanoc/rule_dsl.rb
CHANGED
@@ -20,3 +20,13 @@ require_relative 'rule_dsl/routing_rule_context'
|
|
20
20
|
require_relative 'rule_dsl/rule'
|
21
21
|
require_relative 'rule_dsl/compilation_rule'
|
22
22
|
require_relative 'rule_dsl/routing_rule'
|
23
|
+
|
24
|
+
Nanoc::Core::Checksummer.define_behavior(
|
25
|
+
Nanoc::RuleDSL::CompilationRuleContext,
|
26
|
+
Nanoc::Core::Checksummer::RuleContextUpdateBehavior,
|
27
|
+
)
|
28
|
+
|
29
|
+
Nanoc::Core::Checksummer.define_behavior(
|
30
|
+
Nanoc::RuleDSL::RulesCollection,
|
31
|
+
Nanoc::Core::Checksummer::DataUpdateBehavior,
|
32
|
+
)
|
@@ -65,7 +65,7 @@ module Nanoc::RuleDSL
|
|
65
65
|
items: site.items,
|
66
66
|
dependency_tracker: dependency_tracker,
|
67
67
|
compilation_context: compiler.compilation_context(reps: reps),
|
68
|
-
|
68
|
+
compiled_content_store: nil,
|
69
69
|
)
|
70
70
|
ctx = new_postprocessor_context(site, view_context)
|
71
71
|
|
@@ -79,7 +79,7 @@ module Nanoc::RuleDSL
|
|
79
79
|
view_context =
|
80
80
|
Nanoc::ViewContextForPreCompilation.new(items: site.items)
|
81
81
|
|
82
|
-
Nanoc::
|
82
|
+
Nanoc::Core::Context.new(
|
83
83
|
config: Nanoc::MutableConfigView.new(site.config, view_context),
|
84
84
|
items: Nanoc::MutableItemCollectionView.new(site.items, view_context),
|
85
85
|
layouts: Nanoc::MutableLayoutCollectionView.new(site.layouts, view_context),
|
@@ -88,7 +88,7 @@ module Nanoc::RuleDSL
|
|
88
88
|
|
89
89
|
# @api private
|
90
90
|
def new_postprocessor_context(site, view_context)
|
91
|
-
Nanoc::
|
91
|
+
Nanoc::Core::Context.new(
|
92
92
|
config: Nanoc::ConfigView.new(site.config, view_context),
|
93
93
|
items: Nanoc::PostCompileItemCollectionView.new(site.items, view_context),
|
94
94
|
)
|
@@ -3,9 +3,9 @@
|
|
3
3
|
module Nanoc
|
4
4
|
module RuleDSL
|
5
5
|
class ActionRecorder
|
6
|
-
include Nanoc::
|
6
|
+
include Nanoc::Core::ContractsSupport
|
7
7
|
|
8
|
-
contract Nanoc::
|
8
|
+
contract Nanoc::Core::ItemRep => C::Any
|
9
9
|
def initialize(rep)
|
10
10
|
@action_sequence_builder = Nanoc::Int::ActionSequenceBuilder.new(rep)
|
11
11
|
|
@@ -37,7 +37,7 @@ module Nanoc
|
|
37
37
|
@any_layouts = true
|
38
38
|
end
|
39
39
|
|
40
|
-
MaybePathlike = C::Or[nil, Nanoc::UNDEFINED, String, Nanoc::Identifier]
|
40
|
+
MaybePathlike = C::Or[nil, Nanoc::UNDEFINED, String, Nanoc::Core::Identifier]
|
41
41
|
contract Symbol, C::KeywordArgs[path: C::Optional[MaybePathlike]] => nil
|
42
42
|
def snapshot(snapshot_name, path: Nanoc::UNDEFINED)
|
43
43
|
unless Nanoc::UNDEFINED.equal?(path)
|