nanoc 4.11.11 → 4.11.12
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/NEWS.md +6 -0
- data/lib/nanoc/base/errors.rb +0 -6
- data/lib/nanoc/base/services.rb +0 -2
- data/lib/nanoc/base/services/compiler.rb +1 -1
- data/lib/nanoc/base/services/executor.rb +23 -11
- data/lib/nanoc/base/services/item_rep_builder.rb +1 -1
- data/lib/nanoc/base/views.rb +0 -4
- data/lib/nanoc/base/views/view.rb +8 -0
- data/lib/nanoc/checking/check.rb +5 -2
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +16 -18
- data/lib/nanoc/cli/commands/shell.rb +1 -1
- data/lib/nanoc/helpers/rendering.rb +3 -1
- data/lib/nanoc/rule_dsl/action_provider.rb +2 -2
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +2 -2
- data/lib/nanoc/rule_dsl/compilation_rule.rb +1 -1
- data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
- data/lib/nanoc/rule_dsl/routing_rule.rb +1 -1
- data/lib/nanoc/rule_dsl/rule_context.rb +1 -1
- data/lib/nanoc/spec.rb +2 -2
- data/lib/nanoc/version.rb +1 -1
- metadata +4 -9
- data/lib/nanoc/base/services/compilation_context.rb +0 -79
- data/lib/nanoc/base/services/item_rep_router.rb +0 -99
- data/lib/nanoc/base/views/view_context_for_compilation.rb +0 -29
- data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +0 -18
- data/lib/nanoc/base/views/view_context_for_shell.rb +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 022d4d52cb5ae57bd458ef8d4272d255a4845cec76627311020dbd4680143d03
|
4
|
+
data.tar.gz: 21f357e65efed5e243627a2c9aaab4e688c0cd8ec2c7d1d0d789317435f853d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d8d8d5e86ff63450ce7e4d9a80cb7c850468ebc96aebe5e0a0245dc4464a6b65a4757929ef587119942e7961e8e397e250e54f32b41b1a7afc0989857a19c48e
|
7
|
+
data.tar.gz: 36309e62ab8c585dab399ac8f5c09fe56c8ce10c19c3df86a317f07a0fd3a0d4f89eca2f0d943f4a1c918978c65f74f8ffff7d61acb8f958b33daf7c7789495b
|
data/NEWS.md
CHANGED
data/lib/nanoc/base/errors.rb
CHANGED
@@ -150,12 +150,6 @@ module Nanoc
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
-
class UndefinedFilterForLayout < Generic
|
154
|
-
def initialize(layout)
|
155
|
-
super("There is no filter defined for the layout #{layout.identifier}")
|
156
|
-
end
|
157
|
-
end
|
158
|
-
|
159
153
|
class AmbiguousMetadataAssociation < Generic
|
160
154
|
def initialize(content_filenames, meta_filename)
|
161
155
|
super("There are multiple content files (#{content_filenames.sort.join(', ')}) that could match the file containing metadata (#{meta_filename}).")
|
data/lib/nanoc/base/services.rb
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require_relative 'services/compilation_context'
|
4
3
|
require_relative 'services/compiler'
|
5
4
|
require_relative 'services/compiler_loader'
|
6
5
|
require_relative 'services/executor'
|
7
6
|
require_relative 'services/filter'
|
8
7
|
require_relative 'services/item_rep_builder'
|
9
|
-
require_relative 'services/item_rep_router'
|
10
8
|
require_relative 'services/item_rep_selector'
|
11
9
|
require_relative 'services/item_rep_writer'
|
12
10
|
require_relative 'services/pruner'
|
@@ -10,7 +10,7 @@ module Nanoc
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def filter(filter_name, filter_args = {})
|
13
|
-
filter = filter_for_filtering(
|
13
|
+
filter = filter_for_filtering(filter_name)
|
14
14
|
|
15
15
|
begin
|
16
16
|
Nanoc::Core::NotificationCenter.post(:filtering_started, @rep, filter_name)
|
@@ -36,11 +36,13 @@ module Nanoc
|
|
36
36
|
|
37
37
|
def layout(layout_identifier, extra_filter_args = nil)
|
38
38
|
layout = find_layout(layout_identifier)
|
39
|
-
|
39
|
+
filter_name_and_args = @compilation_context.filter_name_and_args_for_layout(layout)
|
40
|
+
filter_name = filter_name_and_args.name
|
40
41
|
if filter_name.nil?
|
41
42
|
raise ::Nanoc::Core::Error, "Cannot find rule for layout matching #{layout_identifier}"
|
42
43
|
end
|
43
44
|
|
45
|
+
filter_args = filter_name_and_args.args
|
44
46
|
filter_args = filter_args.merge(extra_filter_args || {})
|
45
47
|
filter_args.freeze
|
46
48
|
|
@@ -50,9 +52,8 @@ module Nanoc
|
|
50
52
|
|
51
53
|
# Create filter
|
52
54
|
klass = Nanoc::Filter.named!(filter_name)
|
53
|
-
view_context = @compilation_context.create_view_context(@dependency_tracker)
|
54
55
|
layout_view = Nanoc::LayoutView.new(layout, view_context)
|
55
|
-
filter = klass.new(
|
56
|
+
filter = klass.new(assigns.merge(layout: layout_view))
|
56
57
|
|
57
58
|
# Visit
|
58
59
|
@dependency_tracker.bounce(layout, raw_content: true)
|
@@ -79,8 +80,8 @@ module Nanoc
|
|
79
80
|
Nanoc::Core::NotificationCenter.post(:snapshot_created, @rep, snapshot_name)
|
80
81
|
end
|
81
82
|
|
82
|
-
def
|
83
|
-
|
83
|
+
def assigns
|
84
|
+
view_context.assigns_for(@rep, site: @compilation_context.site)
|
84
85
|
end
|
85
86
|
|
86
87
|
def layouts
|
@@ -89,7 +90,7 @@ module Nanoc
|
|
89
90
|
|
90
91
|
def find_layout(arg)
|
91
92
|
req_id = arg.__nanoc_cleaned_identifier
|
92
|
-
layout = layouts
|
93
|
+
layout = layouts[req_id]
|
93
94
|
return layout if layout
|
94
95
|
|
95
96
|
if use_globs?
|
@@ -101,22 +102,33 @@ module Nanoc
|
|
101
102
|
raise Nanoc::Int::Errors::UnknownLayout.new(arg)
|
102
103
|
end
|
103
104
|
|
104
|
-
def filter_for_filtering(
|
105
|
+
def filter_for_filtering(filter_name)
|
105
106
|
klass = Nanoc::Filter.named!(filter_name)
|
106
107
|
|
107
108
|
last = @compilation_context.compiled_content_store.get_current(@rep)
|
108
109
|
if klass.from_binary? && !last.binary?
|
109
|
-
raise Nanoc::Int::Errors::CannotUseBinaryFilter.new(rep, klass)
|
110
|
+
raise Nanoc::Int::Errors::CannotUseBinaryFilter.new(@rep, klass)
|
110
111
|
elsif !klass.from_binary? && last.binary?
|
111
|
-
raise Nanoc::Int::Errors::CannotUseTextualFilter.new(rep, klass)
|
112
|
+
raise Nanoc::Int::Errors::CannotUseTextualFilter.new(@rep, klass)
|
112
113
|
end
|
113
114
|
|
114
|
-
klass.new(
|
115
|
+
klass.new(assigns)
|
115
116
|
end
|
116
117
|
|
117
118
|
def use_globs?
|
118
119
|
@compilation_context.site.config[:string_pattern_type] == 'glob'
|
119
120
|
end
|
121
|
+
|
122
|
+
def view_context
|
123
|
+
@_view_context ||=
|
124
|
+
Nanoc::Core::ViewContextForCompilation.new(
|
125
|
+
reps: @compilation_context.reps,
|
126
|
+
items: @compilation_context.site.items,
|
127
|
+
dependency_tracker: @dependency_tracker,
|
128
|
+
compilation_context: @compilation_context,
|
129
|
+
compiled_content_store: @compilation_context.compiled_content_store,
|
130
|
+
)
|
131
|
+
end
|
120
132
|
end
|
121
133
|
end
|
122
134
|
end
|
@@ -22,7 +22,7 @@ module Nanoc
|
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
|
-
action_sequences = Nanoc::
|
25
|
+
action_sequences = Nanoc::Core::ItemRepRouter.new(@reps, @action_provider, @site).run
|
26
26
|
|
27
27
|
@reps.each do |rep|
|
28
28
|
rep.snapshot_defs = self.class.snapshot_defs_for(action_sequences[rep])
|
data/lib/nanoc/base/views.rb
CHANGED
@@ -3,10 +3,6 @@
|
|
3
3
|
require_relative 'views/mixins/document_view_mixin'
|
4
4
|
require_relative 'views/mixins/mutable_document_view_mixin'
|
5
5
|
|
6
|
-
require_relative 'views/view_context_for_compilation'
|
7
|
-
require_relative 'views/view_context_for_pre_compilation'
|
8
|
-
require_relative 'views/view_context_for_shell'
|
9
|
-
|
10
6
|
require_relative 'views/view'
|
11
7
|
|
12
8
|
require_relative 'views/basic_item_rep_view'
|
@@ -2,7 +2,15 @@
|
|
2
2
|
|
3
3
|
module Nanoc
|
4
4
|
class View
|
5
|
+
include Nanoc::Core::ContractsSupport
|
6
|
+
|
5
7
|
# @api private
|
8
|
+
# TODO: disallow nil
|
9
|
+
contract C::Maybe[C::Or[
|
10
|
+
Nanoc::Core::ViewContextForCompilation,
|
11
|
+
Nanoc::Core::ViewContextForPreCompilation,
|
12
|
+
Nanoc::Core::ViewContextForShell
|
13
|
+
]] => C::Any
|
6
14
|
def initialize(context)
|
7
15
|
@context = context
|
8
16
|
end
|
data/lib/nanoc/checking/check.rb
CHANGED
@@ -35,8 +35,11 @@ module Nanoc::Checking
|
|
35
35
|
compiler = Nanoc::Int::Compiler.new_for(site)
|
36
36
|
res = compiler.run_until_reps_built
|
37
37
|
reps = res.fetch(:reps)
|
38
|
-
|
39
|
-
|
38
|
+
view_context =
|
39
|
+
Nanoc::Core::ViewContextForShell.new(
|
40
|
+
items: site.items,
|
41
|
+
reps: reps,
|
42
|
+
)
|
40
43
|
|
41
44
|
context = {
|
42
45
|
items: Nanoc::PostCompileItemCollectionView.new(site.items, view_context),
|
@@ -21,29 +21,27 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
21
21
|
|
22
22
|
diffs = Diff::LCS.diff(lines_a, lines_b)
|
23
23
|
|
24
|
-
|
25
|
-
|
24
|
+
output = +''
|
25
|
+
output << "--- #{@path}\n"
|
26
|
+
output << "+++ #{@path}\n"
|
27
|
+
|
28
|
+
prev_hunk = hunk = nil
|
26
29
|
file_length_difference = 0
|
27
30
|
diffs.each do |piece|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
end
|
31
|
+
begin
|
32
|
+
hunk = Diff::LCS::Hunk.new(lines_a, lines_b, piece, 3, file_length_difference)
|
33
|
+
file_length_difference = hunk.file_length_difference
|
32
34
|
|
33
|
-
|
34
|
-
|
35
|
-
hunks.each do |hunk|
|
36
|
-
merged = merged_hunks.any? && hunk.merge(merged_hunks.last)
|
37
|
-
merged_hunks << hunk unless merged
|
38
|
-
end
|
35
|
+
next unless prev_hunk
|
36
|
+
next if hunk.merge(prev_hunk)
|
39
37
|
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
merged_hunks.each do |hunk|
|
45
|
-
output << hunk.diff(:unified) << "\n"
|
38
|
+
output << prev_hunk.diff(:unified) << "\n"
|
39
|
+
ensure
|
40
|
+
prev_hunk = hunk
|
41
|
+
end
|
46
42
|
end
|
43
|
+
last = prev_hunk.diff(:unified)
|
44
|
+
output << last << "\n"
|
47
45
|
|
48
46
|
output
|
49
47
|
end
|
@@ -40,7 +40,9 @@ module Nanoc::Helpers
|
|
40
40
|
}.merge(other_assigns)
|
41
41
|
|
42
42
|
# Get filter name
|
43
|
-
|
43
|
+
filter_name_and_args = @config._context.compilation_context.filter_name_and_args_for_layout(layout)
|
44
|
+
filter_name = filter_name_and_args.name
|
45
|
+
filter_args = filter_name_and_args.args
|
44
46
|
raise Nanoc::Int::Errors::CannotDetermineFilter.new(layout.identifier) if filter_name.nil?
|
45
47
|
|
46
48
|
# Get filter class
|
@@ -60,7 +60,7 @@ module Nanoc::RuleDSL
|
|
60
60
|
reps = res.fetch(:reps)
|
61
61
|
|
62
62
|
view_context =
|
63
|
-
Nanoc::ViewContextForCompilation.new(
|
63
|
+
Nanoc::Core::ViewContextForCompilation.new(
|
64
64
|
reps: reps,
|
65
65
|
items: site.items,
|
66
66
|
dependency_tracker: dependency_tracker,
|
@@ -77,7 +77,7 @@ module Nanoc::RuleDSL
|
|
77
77
|
# @api private
|
78
78
|
def new_preprocessor_context(site)
|
79
79
|
view_context =
|
80
|
-
Nanoc::ViewContextForPreCompilation.new(items: site.items)
|
80
|
+
Nanoc::Core::ViewContextForPreCompilation.new(items: site.items)
|
81
81
|
|
82
82
|
Nanoc::Core::Context.new(
|
83
83
|
config: Nanoc::MutableConfigView.new(site.config, view_context),
|
@@ -54,7 +54,7 @@ module Nanoc::RuleDSL
|
|
54
54
|
|
55
55
|
def new_action_sequence_for_rep(rep)
|
56
56
|
view_context =
|
57
|
-
Nanoc::ViewContextForPreCompilation.new(items: @site.items)
|
57
|
+
Nanoc::Core::ViewContextForPreCompilation.new(items: @site.items)
|
58
58
|
|
59
59
|
recorder = Nanoc::RuleDSL::ActionRecorder.new(rep)
|
60
60
|
rule = @rules_collection.compilation_rule_for(rep)
|
@@ -132,7 +132,7 @@ module Nanoc::RuleDSL
|
|
132
132
|
return nil if routing_rule.nil?
|
133
133
|
|
134
134
|
view_context =
|
135
|
-
Nanoc::ViewContextForPreCompilation.new(items: @site.items)
|
135
|
+
Nanoc::Core::ViewContextForPreCompilation.new(items: @site.items)
|
136
136
|
|
137
137
|
basic_path =
|
138
138
|
routing_rule.apply_to(
|
@@ -7,7 +7,7 @@ module Nanoc::RuleDSL
|
|
7
7
|
contract Nanoc::Core::ItemRep, C::KeywordArgs[
|
8
8
|
site: Nanoc::Core::Site,
|
9
9
|
recorder: Nanoc::RuleDSL::ActionRecorder,
|
10
|
-
view_context: Nanoc::ViewContextForPreCompilation,
|
10
|
+
view_context: Nanoc::Core::ViewContextForPreCompilation,
|
11
11
|
] => C::Any
|
12
12
|
def apply_to(rep, site:, recorder:, view_context:)
|
13
13
|
context = Nanoc::RuleDSL::CompilationRuleContext.new(
|
@@ -8,7 +8,7 @@ module Nanoc::RuleDSL
|
|
8
8
|
rep: Nanoc::Core::ItemRep,
|
9
9
|
site: Nanoc::Core::Site,
|
10
10
|
recorder: Nanoc::RuleDSL::ActionRecorder,
|
11
|
-
view_context: Nanoc::ViewContextForPreCompilation,
|
11
|
+
view_context: Nanoc::Core::ViewContextForPreCompilation,
|
12
12
|
] => C::Any
|
13
13
|
def initialize(rep:, site:, recorder:, view_context:)
|
14
14
|
@_recorder = recorder
|
@@ -16,7 +16,7 @@ module Nanoc::RuleDSL
|
|
16
16
|
|
17
17
|
contract Nanoc::Core::ItemRep, C::KeywordArgs[
|
18
18
|
site: Nanoc::Core::Site,
|
19
|
-
view_context: Nanoc::ViewContextForPreCompilation,
|
19
|
+
view_context: Nanoc::Core::ViewContextForPreCompilation,
|
20
20
|
] => C::Any
|
21
21
|
def apply_to(rep, site:, view_context:)
|
22
22
|
context = Nanoc::RuleDSL::RoutingRuleContext.new(
|
@@ -7,7 +7,7 @@ module Nanoc::RuleDSL
|
|
7
7
|
contract C::KeywordArgs[
|
8
8
|
rep: Nanoc::Core::ItemRep,
|
9
9
|
site: Nanoc::Core::Site,
|
10
|
-
view_context: Nanoc::ViewContextForPreCompilation,
|
10
|
+
view_context: Nanoc::Core::ViewContextForPreCompilation,
|
11
11
|
] => C::Any
|
12
12
|
def initialize(rep:, site:, view_context:)
|
13
13
|
super({
|
data/lib/nanoc/spec.rb
CHANGED
@@ -161,7 +161,7 @@ module Nanoc
|
|
161
161
|
|
162
162
|
def view_context
|
163
163
|
compilation_context =
|
164
|
-
Nanoc::
|
164
|
+
Nanoc::Core::CompilationContext.new(
|
165
165
|
action_provider: @action_provider,
|
166
166
|
reps: @reps,
|
167
167
|
site: site,
|
@@ -169,7 +169,7 @@ module Nanoc
|
|
169
169
|
compiled_content_store: @compiled_content_store,
|
170
170
|
)
|
171
171
|
|
172
|
-
Nanoc::ViewContextForCompilation.new(
|
172
|
+
Nanoc::Core::ViewContextForCompilation.new(
|
173
173
|
reps: @reps,
|
174
174
|
items: @items,
|
175
175
|
dependency_tracker: @dependency_tracker,
|
data/lib/nanoc/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.11.
|
4
|
+
version: 4.11.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-09-
|
11
|
+
date: 2019-09-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: addressable
|
@@ -72,14 +72,14 @@ dependencies:
|
|
72
72
|
requirements:
|
73
73
|
- - '='
|
74
74
|
- !ruby/object:Gem::Version
|
75
|
-
version: 4.11.
|
75
|
+
version: 4.11.12
|
76
76
|
type: :runtime
|
77
77
|
prerelease: false
|
78
78
|
version_requirements: !ruby/object:Gem::Requirement
|
79
79
|
requirements:
|
80
80
|
- - '='
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 4.11.
|
82
|
+
version: 4.11.12
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: parallel
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
@@ -174,7 +174,6 @@ files:
|
|
174
174
|
- lib/nanoc/base/repos/config_loader.rb
|
175
175
|
- lib/nanoc/base/repos/site_loader.rb
|
176
176
|
- lib/nanoc/base/services.rb
|
177
|
-
- lib/nanoc/base/services/compilation_context.rb
|
178
177
|
- lib/nanoc/base/services/compiler.rb
|
179
178
|
- lib/nanoc/base/services/compiler/phases.rb
|
180
179
|
- lib/nanoc/base/services/compiler/phases/abstract.rb
|
@@ -201,7 +200,6 @@ files:
|
|
201
200
|
- lib/nanoc/base/services/executor.rb
|
202
201
|
- lib/nanoc/base/services/filter.rb
|
203
202
|
- lib/nanoc/base/services/item_rep_builder.rb
|
204
|
-
- lib/nanoc/base/services/item_rep_router.rb
|
205
203
|
- lib/nanoc/base/services/item_rep_selector.rb
|
206
204
|
- lib/nanoc/base/services/item_rep_writer.rb
|
207
205
|
- lib/nanoc/base/services/outdatedness_checker.rb
|
@@ -241,9 +239,6 @@ files:
|
|
241
239
|
- lib/nanoc/base/views/post_compile_item_rep_view.rb
|
242
240
|
- lib/nanoc/base/views/post_compile_item_view.rb
|
243
241
|
- lib/nanoc/base/views/view.rb
|
244
|
-
- lib/nanoc/base/views/view_context_for_compilation.rb
|
245
|
-
- lib/nanoc/base/views/view_context_for_pre_compilation.rb
|
246
|
-
- lib/nanoc/base/views/view_context_for_shell.rb
|
247
242
|
- lib/nanoc/checking.rb
|
248
243
|
- lib/nanoc/checking/check.rb
|
249
244
|
- lib/nanoc/checking/checks.rb
|
@@ -1,79 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
class CompilationContext
|
6
|
-
include Nanoc::Core::ContractsSupport
|
7
|
-
|
8
|
-
attr_reader :site
|
9
|
-
attr_reader :compiled_content_cache
|
10
|
-
attr_reader :compiled_content_store
|
11
|
-
|
12
|
-
C_COMPILED_CONTENT_CACHE =
|
13
|
-
C::Or[
|
14
|
-
Nanoc::Core::CompiledContentCache,
|
15
|
-
Nanoc::Core::TextualCompiledContentCache,
|
16
|
-
Nanoc::Core::BinaryCompiledContentCache,
|
17
|
-
]
|
18
|
-
|
19
|
-
contract C::KeywordArgs[
|
20
|
-
action_provider: Nanoc::Core::ActionProvider,
|
21
|
-
reps: Nanoc::Core::ItemRepRepo,
|
22
|
-
site: Nanoc::Core::Site,
|
23
|
-
compiled_content_cache: C_COMPILED_CONTENT_CACHE,
|
24
|
-
compiled_content_store: Nanoc::Core::CompiledContentStore,
|
25
|
-
] => C::Any
|
26
|
-
def initialize(action_provider:, reps:, site:, compiled_content_cache:, compiled_content_store:)
|
27
|
-
@action_provider = action_provider
|
28
|
-
@reps = reps
|
29
|
-
@site = site
|
30
|
-
@compiled_content_cache = compiled_content_cache
|
31
|
-
@compiled_content_store = compiled_content_store
|
32
|
-
end
|
33
|
-
|
34
|
-
# FIXME: Expand contract
|
35
|
-
contract Nanoc::Core::Layout => C::Any
|
36
|
-
def filter_name_and_args_for_layout(layout)
|
37
|
-
seq = @action_provider.action_sequence_for(layout)
|
38
|
-
if seq.nil? || seq.size != 1 || !seq[0].is_a?(Nanoc::Core::ProcessingActions::Filter)
|
39
|
-
raise Nanoc::Int::Errors::UndefinedFilterForLayout.new(layout)
|
40
|
-
end
|
41
|
-
|
42
|
-
[seq[0].filter_name, seq[0].params]
|
43
|
-
end
|
44
|
-
|
45
|
-
contract Nanoc::Core::DependencyTracker => C::Named['Nanoc::ViewContextForCompilation']
|
46
|
-
def create_view_context(dependency_tracker)
|
47
|
-
Nanoc::ViewContextForCompilation.new(
|
48
|
-
reps: @reps,
|
49
|
-
items: @site.items,
|
50
|
-
dependency_tracker: dependency_tracker,
|
51
|
-
compilation_context: self,
|
52
|
-
compiled_content_store: @compiled_content_store,
|
53
|
-
)
|
54
|
-
end
|
55
|
-
|
56
|
-
contract Nanoc::Core::ItemRep, Nanoc::Core::DependencyTracker => Hash
|
57
|
-
def assigns_for(rep, dependency_tracker)
|
58
|
-
last_content = @compiled_content_store.get_current(rep)
|
59
|
-
content_or_filename_assigns =
|
60
|
-
if last_content.binary?
|
61
|
-
{ filename: last_content.filename }
|
62
|
-
else
|
63
|
-
{ content: last_content.string }
|
64
|
-
end
|
65
|
-
|
66
|
-
view_context = create_view_context(dependency_tracker)
|
67
|
-
|
68
|
-
content_or_filename_assigns.merge(
|
69
|
-
item: Nanoc::CompilationItemView.new(rep.item, view_context),
|
70
|
-
rep: Nanoc::CompilationItemRepView.new(rep, view_context),
|
71
|
-
item_rep: Nanoc::CompilationItemRepView.new(rep, view_context),
|
72
|
-
items: Nanoc::ItemCollectionWithRepsView.new(@site.items, view_context),
|
73
|
-
layouts: Nanoc::LayoutCollectionView.new(@site.layouts, view_context),
|
74
|
-
config: Nanoc::ConfigView.new(@site.config, view_context),
|
75
|
-
)
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
@@ -1,99 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
module Int
|
5
|
-
# Assigns paths to reps.
|
6
|
-
#
|
7
|
-
# @api private
|
8
|
-
class ItemRepRouter
|
9
|
-
include Nanoc::Core::ContractsSupport
|
10
|
-
|
11
|
-
class IdenticalRoutesError < ::Nanoc::Error
|
12
|
-
def initialize(output_path, rep_a, rep_b)
|
13
|
-
super("The item representations #{rep_a} and #{rep_b} are both routed to #{output_path}.")
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
class RouteWithoutSlashError < ::Nanoc::Error
|
18
|
-
def initialize(output_path, rep)
|
19
|
-
super("The item representation #{rep} is routed to #{output_path}, which does not start with a slash, as required.")
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
contract Nanoc::Core::ItemRepRepo, Nanoc::Core::ActionProvider, Nanoc::Core::Site => C::Any
|
24
|
-
def initialize(reps, action_provider, site)
|
25
|
-
@reps = reps
|
26
|
-
@action_provider = action_provider
|
27
|
-
@site = site
|
28
|
-
end
|
29
|
-
|
30
|
-
def run
|
31
|
-
action_sequences = {}
|
32
|
-
assigned_paths = {}
|
33
|
-
@reps.each do |rep|
|
34
|
-
# Sigh. We route reps twice, because the first time, the paths might not have converged
|
35
|
-
# yet. This isn’t ideal, but it’s the only way to work around the divergence issues that
|
36
|
-
# I can think of. For details, see
|
37
|
-
# https://github.com/nanoc/nanoc/pull/1085#issuecomment-280628426.
|
38
|
-
|
39
|
-
@action_provider.action_sequence_for(rep).paths.each do |(snapshot_names, paths)|
|
40
|
-
route_rep(rep, paths, snapshot_names, {})
|
41
|
-
end
|
42
|
-
|
43
|
-
seq = @action_provider.action_sequence_for(rep)
|
44
|
-
action_sequences[rep] = seq
|
45
|
-
seq.paths.each do |(snapshot_names, paths)|
|
46
|
-
route_rep(rep, paths, snapshot_names, assigned_paths)
|
47
|
-
end
|
48
|
-
|
49
|
-
# TODO: verify that paths converge
|
50
|
-
end
|
51
|
-
|
52
|
-
action_sequences
|
53
|
-
end
|
54
|
-
|
55
|
-
contract Nanoc::Core::ItemRep, C::IterOf[String], C::IterOf[Symbol], C::HashOf[String => Nanoc::Core::ItemRep] => C::Any
|
56
|
-
def route_rep(rep, paths, snapshot_names, assigned_paths)
|
57
|
-
# Encode
|
58
|
-
paths = paths.map { |path| path.encode('UTF-8') }
|
59
|
-
|
60
|
-
# Validate format
|
61
|
-
paths.each do |path|
|
62
|
-
unless path.start_with?('/')
|
63
|
-
raise RouteWithoutSlashError.new(path, rep)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
# Validate uniqueness
|
68
|
-
paths.each do |path|
|
69
|
-
if assigned_paths.include?(path)
|
70
|
-
# TODO: Include snapshot names in error message
|
71
|
-
reps = [assigned_paths[path], rep].sort_by { |r| [r.item.identifier, r.name] }
|
72
|
-
raise IdenticalRoutesError.new(path, *reps)
|
73
|
-
end
|
74
|
-
end
|
75
|
-
paths.each do |path|
|
76
|
-
assigned_paths[path] = rep
|
77
|
-
end
|
78
|
-
|
79
|
-
# Assign
|
80
|
-
snapshot_names.each do |snapshot_name|
|
81
|
-
rep.raw_paths[snapshot_name] = paths.map { |path| @site.config.output_dir + path }
|
82
|
-
rep.paths[snapshot_name] = paths.map { |path| strip_index_filename(path) }
|
83
|
-
end
|
84
|
-
end
|
85
|
-
|
86
|
-
contract String => String
|
87
|
-
def strip_index_filename(basic_path)
|
88
|
-
@site.config[:index_filenames].each do |index_filename|
|
89
|
-
slashed_index_filename = '/' + index_filename
|
90
|
-
if basic_path.end_with?(slashed_index_filename)
|
91
|
-
return basic_path[0..-index_filename.length - 1]
|
92
|
-
end
|
93
|
-
end
|
94
|
-
|
95
|
-
basic_path
|
96
|
-
end
|
97
|
-
end
|
98
|
-
end
|
99
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
# @api private
|
5
|
-
class ViewContextForCompilation
|
6
|
-
include Nanoc::Core::ContractsSupport
|
7
|
-
|
8
|
-
attr_reader :reps
|
9
|
-
attr_reader :items
|
10
|
-
attr_reader :dependency_tracker
|
11
|
-
attr_reader :compilation_context
|
12
|
-
attr_reader :compiled_content_store
|
13
|
-
|
14
|
-
contract C::KeywordArgs[
|
15
|
-
reps: Nanoc::Core::ItemRepRepo,
|
16
|
-
items: Nanoc::Core::IdentifiableCollection,
|
17
|
-
dependency_tracker: Nanoc::Core::DependencyTracker,
|
18
|
-
compilation_context: C::Any,
|
19
|
-
compiled_content_store: Nanoc::Core::CompiledContentStore,
|
20
|
-
] => C::Any
|
21
|
-
def initialize(reps:, items:, dependency_tracker:, compilation_context:, compiled_content_store:)
|
22
|
-
@reps = reps
|
23
|
-
@items = items
|
24
|
-
@dependency_tracker = dependency_tracker
|
25
|
-
@compilation_context = compilation_context
|
26
|
-
@compiled_content_store = compiled_content_store
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
@@ -1,18 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
# @api private
|
5
|
-
class ViewContextForPreCompilation
|
6
|
-
include Nanoc::Core::ContractsSupport
|
7
|
-
|
8
|
-
attr_reader :items
|
9
|
-
attr_reader :dependency_tracker
|
10
|
-
|
11
|
-
contract C::KeywordArgs[items: Nanoc::Core::IdentifiableCollection] => C::Any
|
12
|
-
def initialize(items:)
|
13
|
-
@items = items
|
14
|
-
|
15
|
-
@dependency_tracker = Nanoc::Core::DependencyTracker::Null.new
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Nanoc
|
4
|
-
# @api private
|
5
|
-
class ViewContextForShell
|
6
|
-
include Nanoc::Core::ContractsSupport
|
7
|
-
|
8
|
-
attr_reader :items
|
9
|
-
attr_reader :reps
|
10
|
-
attr_reader :dependency_tracker
|
11
|
-
|
12
|
-
contract C::KeywordArgs[
|
13
|
-
items: Nanoc::Core::IdentifiableCollection,
|
14
|
-
reps: Nanoc::Core::ItemRepRepo,
|
15
|
-
] => C::Any
|
16
|
-
def initialize(items:, reps:)
|
17
|
-
@items = items
|
18
|
-
@reps = reps
|
19
|
-
|
20
|
-
@dependency_tracker = Nanoc::Core::DependencyTracker::Null.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|