nanoc 4.8.9 → 4.8.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +6 -4
- data/Gemfile +2 -1
- data/NEWS.md +7 -0
- data/README.md +1 -1
- data/lib/nanoc.rb +2 -6
- data/lib/nanoc/base/entities/site.rb +9 -5
- data/lib/nanoc/base/repos/data_source.rb +0 -15
- data/lib/nanoc/base/repos/outdatedness_store.rb +17 -15
- data/lib/nanoc/base/services/compilation_context.rb +4 -4
- data/lib/nanoc/base/services/compiler.rb +102 -103
- data/lib/nanoc/base/services/compiler/stages/build_reps.rb +7 -7
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +4 -2
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +25 -7
- data/lib/nanoc/base/services/compiler/stages/postprocess.rb +3 -3
- data/lib/nanoc/base/services/compiler/stages/preprocess.rb +3 -0
- data/lib/nanoc/base/services/compiler_loader.rb +1 -4
- data/lib/nanoc/base/views.rb +13 -6
- data/lib/nanoc/base/views/{item_rep_collection_view.rb → basic_item_rep_collection_view.rb} +6 -6
- data/lib/nanoc/base/views/{item_rep_view.rb → basic_item_rep_view.rb} +8 -29
- data/lib/nanoc/base/views/{item_without_reps_view.rb → basic_item_view.rb} +3 -3
- data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +10 -0
- data/lib/nanoc/base/views/compilation_item_rep_view.rb +42 -0
- data/lib/nanoc/base/views/{mixins/with_reps_view_mixin.rb → compilation_item_view.rb} +3 -3
- data/lib/nanoc/base/views/item_collection_with_reps_view.rb +1 -1
- data/lib/nanoc/base/views/item_collection_without_reps_view.rb +1 -1
- data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +1 -1
- data/lib/nanoc/base/views/mutable_item_view.rb +1 -1
- data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +1 -1
- data/lib/nanoc/base/views/post_compile_item_rep_view.rb +7 -2
- data/lib/nanoc/base/views/post_compile_item_view.rb +1 -1
- data/lib/nanoc/base/views/{view_context.rb → view_context_for_compilation.rb} +10 -1
- data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +18 -0
- data/lib/nanoc/base/views/view_context_for_shell.rb +23 -0
- data/lib/nanoc/checking/check.rb +5 -1
- data/lib/nanoc/checking/runner.rb +1 -1
- data/lib/nanoc/cli.rb +1 -0
- data/lib/nanoc/cli/command_runner.rb +1 -7
- data/lib/nanoc/cli/commands/check.rb +2 -2
- data/lib/nanoc/cli/commands/compile.rb +8 -47
- data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +9 -0
- data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +49 -0
- data/lib/nanoc/cli/commands/deploy.rb +2 -1
- data/lib/nanoc/cli/commands/prune.rb +5 -4
- data/lib/nanoc/cli/commands/shell.rb +4 -6
- data/lib/nanoc/cli/commands/show-data.rb +20 -27
- data/lib/nanoc/cli/commands/show-rules.rb +20 -22
- data/lib/nanoc/cli/error_handler.rb +0 -17
- data/lib/nanoc/data_sources/filesystem.rb +4 -2
- data/lib/nanoc/deploying/deployers/fog.rb +4 -1
- data/lib/nanoc/helpers/link_to.rb +1 -1
- data/lib/nanoc/rule_dsl/action_provider.rb +8 -11
- data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +14 -5
- data/lib/nanoc/rule_dsl/recording_executor.rb +4 -0
- data/lib/nanoc/rule_dsl/rule.rb +14 -9
- data/lib/nanoc/rule_dsl/rule_context.rb +4 -4
- data/lib/nanoc/spec.rb +27 -19
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/base/checksummer_spec.rb +19 -11
- data/spec/nanoc/base/compiler_spec.rb +18 -14
- data/spec/nanoc/base/filter_spec.rb +7 -6
- data/spec/nanoc/base/repos/outdatedness_store_spec.rb +3 -32
- data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +2 -1
- data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +148 -0
- data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +110 -0
- data/spec/nanoc/base/services/executor_spec.rb +6 -6
- data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +8 -0
- data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +9 -0
- data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +8 -0
- data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +136 -0
- data/spec/nanoc/base/views/config_view_spec.rb +5 -5
- data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +4 -2
- data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +4 -2
- data/spec/nanoc/base/views/item_view_spec.rb +13 -11
- data/spec/nanoc/base/views/layout_collection_view_spec.rb +3 -1
- data/spec/nanoc/base/views/layout_view_spec.rb +3 -1
- data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +5 -2
- data/spec/nanoc/base/views/mutable_item_view_spec.rb +2 -0
- data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +5 -2
- data/spec/nanoc/base/views/mutable_layout_view_spec.rb +2 -0
- data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +2 -0
- data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +9 -3
- data/spec/nanoc/base/views/{document_view_spec.rb → support/document_view_examples.rb} +5 -5
- data/spec/nanoc/base/views/{identifiable_collection_view_spec.rb → support/identifiable_collection_view_examples.rb} +4 -4
- data/spec/nanoc/base/views/{item_rep_collection_view_spec.rb → support/item_rep_collection_view_examples.rb} +3 -8
- data/spec/nanoc/base/views/{item_rep_view_spec.rb → support/item_rep_view_examples.rb} +10 -111
- data/spec/nanoc/base/views/{mutable_document_view_spec.rb → support/mutable_document_view_examples.rb} +7 -6
- data/spec/nanoc/base/views/{mutable_identifiable_collection_view_spec.rb → support/mutable_identifiable_collection_view_examples.rb} +1 -1
- data/spec/nanoc/cli/commands/compile/abstract_spec.rb +80 -0
- data/spec/nanoc/cli/commands/compile_spec.rb +30 -51
- data/spec/nanoc/cli/commands/show_data_spec.rb +2 -23
- data/spec/nanoc/cli/commands/show_rules_spec.rb +4 -2
- data/spec/nanoc/regressions/gh_767_spec.rb +1 -1
- data/spec/nanoc/regressions/gh_776_spec.rb +2 -1
- data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +25 -12
- data/spec/nanoc/rule_dsl/rule_context_spec.rb +16 -6
- data/test/base/test_data_source.rb +0 -18
- data/test/checking/checks/test_external_links.rb +4 -6
- data/test/checking/checks/test_internal_links.rb +6 -9
- data/test/cli/commands/test_compile.rb +0 -35
- data/test/cli/test_cleaning_stream.rb +1 -1
- data/test/data_sources/test_filesystem.rb +16 -0
- data/test/filters/test_kramdown.rb +4 -4
- data/test/filters/test_sass.rb +1 -1
- data/test/filters/test_slim.rb +7 -5
- data/test/filters/test_xsl.rb +10 -8
- data/test/helpers/test_blogging.rb +5 -5
- data/test/helpers/test_capturing.rb +8 -6
- data/test/helpers/test_link_to.rb +4 -4
- data/test/helpers/test_xml_sitemap.rb +19 -19
- metadata +25 -15
- data/lib/nanoc/base/views/item_with_reps_view.rb +0 -7
- data/spec/nanoc/base/core_ext/pathname_spec.rb +0 -0
@@ -10,43 +10,37 @@ Prints the rules used for all items and layouts in the current site.
|
|
10
10
|
module Nanoc::CLI::Commands
|
11
11
|
class ShowRules < ::Nanoc::CLI::CommandRunner
|
12
12
|
def run
|
13
|
-
|
13
|
+
site = load_site
|
14
14
|
|
15
|
-
|
15
|
+
res = Nanoc::Int::Compiler.new_for(site).run_until_reps_built
|
16
|
+
reps = res.fetch(:reps)
|
16
17
|
|
17
|
-
|
18
|
-
|
19
|
-
@reps = compiler.reps
|
18
|
+
action_provider = Nanoc::Int::ActionProvider.named(:rule_dsl).for(site)
|
19
|
+
rules = action_provider.rules_collection
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
raise(
|
24
|
-
::Nanoc::Int::Errors::GenericTrivial,
|
25
|
-
'The show-rules command can only be used for sites with the Rule DSL action provider.',
|
26
|
-
)
|
27
|
-
end
|
28
|
-
@rules = action_provider.rules_collection
|
21
|
+
items = site.items.sort_by(&:identifier)
|
22
|
+
layouts = site.layouts.sort_by(&:identifier)
|
29
23
|
|
30
|
-
|
31
|
-
|
24
|
+
items.each { |e| explain_item(e, rules: rules, reps: reps) }
|
25
|
+
layouts.each { |e| explain_layout(e, rules: rules) }
|
32
26
|
end
|
33
27
|
|
34
|
-
def explain_item(item)
|
35
|
-
puts
|
28
|
+
def explain_item(item, rules:, reps:)
|
29
|
+
puts(fmt_heading("Item #{item.identifier}") + ':')
|
36
30
|
|
37
|
-
|
38
|
-
rule =
|
31
|
+
reps[item].each do |rep|
|
32
|
+
rule = rules.compilation_rule_for(rep)
|
39
33
|
puts " Rep #{rep.name}: #{rule ? rule.pattern : '(none)'}"
|
40
34
|
end
|
41
35
|
|
42
36
|
puts
|
43
37
|
end
|
44
38
|
|
45
|
-
def explain_layout(layout)
|
46
|
-
puts
|
39
|
+
def explain_layout(layout, rules:)
|
40
|
+
puts(fmt_heading("Layout #{layout.identifier}") + ':')
|
47
41
|
|
48
42
|
found = false
|
49
|
-
|
43
|
+
rules.layout_filter_mapping.each_key do |pattern|
|
50
44
|
if pattern.match?(layout.identifier)
|
51
45
|
puts " #{pattern}"
|
52
46
|
found = true
|
@@ -59,6 +53,10 @@ module Nanoc::CLI::Commands
|
|
59
53
|
|
60
54
|
puts
|
61
55
|
end
|
56
|
+
|
57
|
+
def fmt_heading(s)
|
58
|
+
Nanoc::CLI::ANSIStringColorizer.c(s, :bold, :yellow)
|
59
|
+
end
|
62
60
|
end
|
63
61
|
end
|
64
62
|
|
@@ -146,23 +146,6 @@ module Nanoc::CLI
|
|
146
146
|
|
147
147
|
protected
|
148
148
|
|
149
|
-
# @return [Boolean] true if debug output is enabled, false if not
|
150
|
-
#
|
151
|
-
# @see Nanoc::CLI.debug?
|
152
|
-
def debug?
|
153
|
-
Nanoc::CLI.debug?
|
154
|
-
end
|
155
|
-
|
156
|
-
# @return [Nanoc::Int::Site] The site that is currently being processed
|
157
|
-
def site
|
158
|
-
@command&.site
|
159
|
-
end
|
160
|
-
|
161
|
-
# @return [Nanoc::Int::Compiler] The compiler for the current site
|
162
|
-
def compiler
|
163
|
-
site&.compiler
|
164
|
-
end
|
165
|
-
|
166
149
|
# @return [Hash<String, Array>] A hash containing the gem names as keys and gem versions as value
|
167
150
|
def gems_and_versions
|
168
151
|
gems = {}
|
@@ -371,15 +371,17 @@ module Nanoc::DataSources
|
|
371
371
|
ParseResult.new(content: content, attributes: meta, attributes_data: meta_raw)
|
372
372
|
end
|
373
373
|
|
374
|
+
SEPARATOR = /(-{5}|-{3})/.source
|
375
|
+
|
374
376
|
# @return [ParseResult]
|
375
377
|
def parse_with_frontmatter(content_filename)
|
376
378
|
data = read(content_filename)
|
377
379
|
|
378
|
-
if data !~ /\A
|
380
|
+
if data !~ /\A#{SEPARATOR}\s*$/
|
379
381
|
return ParseResult.new(content: data, attributes: {}, attributes_data: '')
|
380
382
|
end
|
381
383
|
|
382
|
-
pieces = data.split(
|
384
|
+
pieces = data.split(/^#{SEPARATOR}[ \t]*\r?\n?/, 3)
|
383
385
|
if pieces.size < 4
|
384
386
|
raise Errors::InvalidFormat.new(content_filename)
|
385
387
|
end
|
@@ -82,7 +82,7 @@ module Nanoc::Deploying::Deployers
|
|
82
82
|
|
83
83
|
# @see Nanoc::Deploying::Deployer#run
|
84
84
|
def run
|
85
|
-
require 'fog'
|
85
|
+
require 'fog/core'
|
86
86
|
|
87
87
|
src = File.expand_path(source_path)
|
88
88
|
bucket = config[:bucket] || config[:bucket_name]
|
@@ -126,6 +126,9 @@ module Nanoc::Deploying::Deployers
|
|
126
126
|
|
127
127
|
def connect
|
128
128
|
::Fog::Storage.new(config_for_fog)
|
129
|
+
rescue ArgumentError
|
130
|
+
require "fog/#{config[:provider]}"
|
131
|
+
::Fog::Storage.new(config_for_fog)
|
129
132
|
end
|
130
133
|
|
131
134
|
def get_or_create_bucket(connection, bucket, path)
|
@@ -17,7 +17,7 @@ module Nanoc::Helpers
|
|
17
17
|
case target
|
18
18
|
when String
|
19
19
|
target
|
20
|
-
when Nanoc::
|
20
|
+
when Nanoc::CompilationItemView, Nanoc::BasicItemView, Nanoc::BasicItemRepView
|
21
21
|
raise "Cannot create a link to #{target.inspect} because this target is not outputted (its routing rule returns nil)" if target.path.nil?
|
22
22
|
target.path
|
23
23
|
else
|
@@ -53,14 +53,18 @@ module Nanoc::RuleDSL
|
|
53
53
|
Nanoc::Int::InMemDataSource.new(ctx.items.unwrap, ctx.layouts.unwrap)
|
54
54
|
end
|
55
55
|
|
56
|
-
def postprocess(site, reps)
|
56
|
+
def postprocess(site, compiler, reps)
|
57
57
|
dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
|
58
|
+
|
59
|
+
res = compiler.run_until_reps_built
|
60
|
+
reps = res.fetch(:reps)
|
61
|
+
|
58
62
|
view_context =
|
59
|
-
Nanoc::
|
63
|
+
Nanoc::ViewContextForCompilation.new(
|
60
64
|
reps: reps,
|
61
65
|
items: site.items,
|
62
66
|
dependency_tracker: dependency_tracker,
|
63
|
-
compilation_context:
|
67
|
+
compilation_context: compiler.compilation_context(reps: reps),
|
64
68
|
snapshot_repo: nil,
|
65
69
|
)
|
66
70
|
ctx = new_postprocessor_context(site, view_context)
|
@@ -72,15 +76,8 @@ module Nanoc::RuleDSL
|
|
72
76
|
|
73
77
|
# @api private
|
74
78
|
def new_preprocessor_context(site)
|
75
|
-
dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
|
76
79
|
view_context =
|
77
|
-
Nanoc::
|
78
|
-
reps: nil,
|
79
|
-
items: nil,
|
80
|
-
dependency_tracker: dependency_tracker,
|
81
|
-
compilation_context: nil,
|
82
|
-
snapshot_repo: nil,
|
83
|
-
)
|
80
|
+
Nanoc::ViewContextForPreCompilation.new(items: site.items)
|
84
81
|
|
85
82
|
Nanoc::Int::Context.new(
|
86
83
|
config: Nanoc::MutableConfigView.new(site.config, view_context),
|
@@ -57,8 +57,8 @@ module Nanoc::RuleDSL
|
|
57
57
|
end
|
58
58
|
|
59
59
|
def new_action_sequence_for_rep(rep)
|
60
|
-
|
61
|
-
|
60
|
+
view_context =
|
61
|
+
Nanoc::ViewContextForPreCompilation.new(items: @site.items)
|
62
62
|
|
63
63
|
executor = Nanoc::RuleDSL::RecordingExecutor.new(rep)
|
64
64
|
rule = @rules_collection.compilation_rule_for(rep)
|
@@ -132,12 +132,21 @@ module Nanoc::RuleDSL
|
|
132
132
|
routing_rule = routing_rules[snapshot_name]
|
133
133
|
return nil if routing_rule.nil?
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
135
|
+
view_context =
|
136
|
+
Nanoc::ViewContextForPreCompilation.new(items: @site.items)
|
137
|
+
|
138
|
+
basic_path =
|
139
|
+
routing_rule.apply_to(
|
140
|
+
rep,
|
141
|
+
executor: nil,
|
142
|
+
site: @site,
|
143
|
+
view_context: view_context,
|
144
|
+
)
|
145
|
+
|
138
146
|
if basic_path && !basic_path.start_with?('/')
|
139
147
|
raise PathWithoutInitialSlashError.new(rep, basic_path)
|
140
148
|
end
|
149
|
+
|
141
150
|
basic_path
|
142
151
|
end
|
143
152
|
end
|
data/lib/nanoc/rule_dsl/rule.rb
CHANGED
@@ -5,6 +5,8 @@ module Nanoc::RuleDSL
|
|
5
5
|
#
|
6
6
|
# @api private
|
7
7
|
class Rule
|
8
|
+
include Nanoc::Int::ContractsSupport
|
9
|
+
|
8
10
|
# @return [Symbol] The name of the representation that will be compiled
|
9
11
|
# using this rule
|
10
12
|
attr_reader :rep_name
|
@@ -44,18 +46,21 @@ module Nanoc::RuleDSL
|
|
44
46
|
@pattern.match?(item.identifier)
|
45
47
|
end
|
46
48
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
# @param [Nanoc::ViewContext] view_context
|
53
|
-
#
|
54
|
-
# @return [void]
|
49
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[
|
50
|
+
site: Nanoc::Int::Site,
|
51
|
+
executor: C::Or[nil, Nanoc::Int::Executor, Nanoc::RuleDSL::RecordingExecutor],
|
52
|
+
view_context: Nanoc::ViewContextForPreCompilation,
|
53
|
+
] => C::Any
|
55
54
|
def apply_to(rep, site:, executor:, view_context:)
|
55
|
+
# FIXME: allowing executor to be nil is ugly
|
56
|
+
|
56
57
|
context = Nanoc::RuleDSL::RuleContext.new(
|
57
|
-
rep: rep,
|
58
|
+
rep: rep,
|
59
|
+
executor: executor,
|
60
|
+
site: site,
|
61
|
+
view_context: view_context,
|
58
62
|
)
|
63
|
+
|
59
64
|
context.instance_exec(matches(rep.item.identifier), &@block)
|
60
65
|
end
|
61
66
|
|
@@ -10,14 +10,14 @@ module Nanoc::RuleDSL
|
|
10
10
|
# @param [Nanoc::Int::ItemRep] rep
|
11
11
|
# @param [Nanoc::Int::Site] site
|
12
12
|
# @param [Nanoc::Int::Executor, Nanoc::RuleDSL::RecordingExecutor] executor
|
13
|
-
# @param [Nanoc::
|
13
|
+
# @param [Nanoc::ViewContextForCompilation] view_context
|
14
14
|
def initialize(rep:, site:, executor:, view_context:)
|
15
15
|
@_executor = executor
|
16
16
|
|
17
17
|
super({
|
18
|
-
item: Nanoc::
|
19
|
-
rep: Nanoc::
|
20
|
-
item_rep: Nanoc::
|
18
|
+
item: Nanoc::BasicItemView.new(rep.item, view_context),
|
19
|
+
rep: Nanoc::BasicItemRepView.new(rep, view_context),
|
20
|
+
item_rep: Nanoc::BasicItemRepView.new(rep, view_context),
|
21
21
|
items: Nanoc::ItemCollectionWithoutRepsView.new(site.items, view_context),
|
22
22
|
layouts: Nanoc::LayoutCollectionView.new(site.layouts, view_context),
|
23
23
|
config: Nanoc::ConfigView.new(site.config, view_context),
|
data/lib/nanoc/spec.rb
CHANGED
@@ -30,6 +30,8 @@ module Nanoc
|
|
30
30
|
@items = Nanoc::Int::ItemCollection.new(@config)
|
31
31
|
@layouts = Nanoc::Int::LayoutCollection.new(@config)
|
32
32
|
@dependency_tracker = Nanoc::Int::DependencyTracker.new(Object.new)
|
33
|
+
@snapshot_repo = Nanoc::Int::SnapshotRepo.new
|
34
|
+
@action_provider = new_action_provider
|
33
35
|
end
|
34
36
|
|
35
37
|
# Creates a new item and adds it to the site’s collection of items.
|
@@ -40,7 +42,7 @@ module Nanoc
|
|
40
42
|
#
|
41
43
|
# @param [Nanoc::Identifier, String] identifier This item's identifier
|
42
44
|
#
|
43
|
-
# @return [Nanoc::
|
45
|
+
# @return [Nanoc::CompilationItemView] A view for the newly created item
|
44
46
|
def create_item(content, attributes, identifier)
|
45
47
|
item = Nanoc::Int::Item.new(content, attributes, identifier)
|
46
48
|
@items = @items.add(item)
|
@@ -55,7 +57,7 @@ module Nanoc
|
|
55
57
|
#
|
56
58
|
# @param [Nanoc::Identifier, String] identifier This layout's identifier
|
57
59
|
#
|
58
|
-
# @return [Nanoc::
|
60
|
+
# @return [Nanoc::CompilationItemView] A view for the newly created layout
|
59
61
|
def create_layout(content, attributes, identifier)
|
60
62
|
layout = Nanoc::Int::Layout.new(content, attributes, identifier)
|
61
63
|
@layouts = @layouts.add(layout)
|
@@ -64,7 +66,7 @@ module Nanoc
|
|
64
66
|
|
65
67
|
# Creates a new representation for the given item.
|
66
68
|
#
|
67
|
-
# @param [Nanoc::
|
69
|
+
# @param [Nanoc::CompilationItemView] item The item to create a represetation for
|
68
70
|
#
|
69
71
|
# @param [String] path The path of the `:last` snapshot of this item representation
|
70
72
|
# @param [Symbol] rep The rep name to create
|
@@ -95,12 +97,12 @@ module Nanoc
|
|
95
97
|
assigns[:config]
|
96
98
|
end
|
97
99
|
|
98
|
-
# @return [Nanoc::
|
100
|
+
# @return [Nanoc::CompilationItemView, nil]
|
99
101
|
def item
|
100
102
|
assigns[:item]
|
101
103
|
end
|
102
104
|
|
103
|
-
# @return [Nanoc::
|
105
|
+
# @return [Nanoc::BasicItemRepView, nil]
|
104
106
|
def item_rep
|
105
107
|
assigns[:item_rep]
|
106
108
|
end
|
@@ -130,12 +132,21 @@ module Nanoc
|
|
130
132
|
private
|
131
133
|
|
132
134
|
def view_context
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
compilation_context =
|
136
|
+
Nanoc::Int::CompilationContext.new(
|
137
|
+
action_provider: @action_provider,
|
138
|
+
reps: @reps,
|
139
|
+
site: @site,
|
140
|
+
compiled_content_cache: :__compiled_content_cache,
|
141
|
+
snapshot_repo: @snapshot_repo,
|
142
|
+
)
|
143
|
+
|
144
|
+
Nanoc::ViewContextForCompilation.new(
|
145
|
+
reps: @reps,
|
146
|
+
items: @items,
|
147
|
+
dependency_tracker: @dependency_tracker,
|
148
|
+
compilation_context: compilation_context,
|
149
|
+
snapshot_repo: @snapshot_repo,
|
139
150
|
)
|
140
151
|
end
|
141
152
|
|
@@ -164,26 +175,23 @@ module Nanoc
|
|
164
175
|
end
|
165
176
|
|
166
177
|
def new_compiler_for(site)
|
167
|
-
Nanoc::Int::CompilerLoader.new.load(site, action_provider:
|
178
|
+
Nanoc::Int::CompilerLoader.new.load(site, action_provider: @action_provider)
|
168
179
|
end
|
169
180
|
|
170
181
|
def site
|
171
|
-
@_site ||=
|
172
|
-
|
182
|
+
@_site ||=
|
183
|
+
Nanoc::Int::Site.new(
|
173
184
|
config: @config,
|
174
185
|
code_snippets: [],
|
175
186
|
data_source: Nanoc::Int::InMemDataSource.new(@items, @layouts),
|
176
187
|
)
|
177
|
-
site.compiler = new_compiler_for(site)
|
178
|
-
site
|
179
|
-
end
|
180
188
|
end
|
181
189
|
|
182
190
|
def assigns
|
183
191
|
{
|
184
192
|
config: Nanoc::MutableConfigView.new(@config, view_context),
|
185
|
-
item_rep: @item_rep ? Nanoc::
|
186
|
-
item: @item ? Nanoc::
|
193
|
+
item_rep: @item_rep ? Nanoc::CompilationItemRepView.new(@item_rep, view_context) : nil,
|
194
|
+
item: @item ? Nanoc::CompilationItemView.new(@item, view_context) : nil,
|
187
195
|
items: Nanoc::ItemCollectionWithRepsView.new(@items, view_context),
|
188
196
|
layouts: Nanoc::LayoutCollectionView.new(@layouts, view_context),
|
189
197
|
_erbout: @erbout,
|
data/lib/nanoc/version.rb
CHANGED
@@ -252,11 +252,11 @@ describe Nanoc::Int::Checksummer do
|
|
252
252
|
end
|
253
253
|
end
|
254
254
|
|
255
|
-
context 'Nanoc::
|
256
|
-
let(:obj) { Nanoc::
|
255
|
+
context 'Nanoc::CompilationItemView' do
|
256
|
+
let(:obj) { Nanoc::CompilationItemView.new(item, nil) }
|
257
257
|
let(:item) { Nanoc::Int::Item.new('asdf', {}, '/foo.md') }
|
258
258
|
|
259
|
-
it { is_expected.to eql('Nanoc::
|
259
|
+
it { is_expected.to eql('Nanoc::CompilationItemView<Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>>') }
|
260
260
|
end
|
261
261
|
|
262
262
|
context 'Nanoc::Int::ItemRep' do
|
@@ -266,19 +266,27 @@ describe Nanoc::Int::Checksummer do
|
|
266
266
|
it { is_expected.to eql('Nanoc::Int::ItemRep<item=Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>,name=Symbol<pdf>>') }
|
267
267
|
end
|
268
268
|
|
269
|
-
context 'Nanoc::
|
270
|
-
let(:obj) { Nanoc::
|
269
|
+
context 'Nanoc::BasicItemRepView' do
|
270
|
+
let(:obj) { Nanoc::BasicItemRepView.new(rep, :_unused_context) }
|
271
271
|
let(:rep) { Nanoc::Int::ItemRep.new(item, :pdf) }
|
272
272
|
let(:item) { Nanoc::Int::Item.new('asdf', {}, '/foo.md') }
|
273
273
|
|
274
|
-
it { is_expected.to eql('Nanoc::
|
274
|
+
it { is_expected.to eql('Nanoc::BasicItemRepView<Nanoc::Int::ItemRep<item=Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>,name=Symbol<pdf>>>') }
|
275
275
|
end
|
276
276
|
|
277
|
-
context 'Nanoc::
|
278
|
-
let(:obj) { Nanoc::
|
277
|
+
context 'Nanoc::CompilationItemRepView' do
|
278
|
+
let(:obj) { Nanoc::CompilationItemRepView.new(rep, :_unused_context) }
|
279
|
+
let(:rep) { Nanoc::Int::ItemRep.new(item, :pdf) }
|
280
|
+
let(:item) { Nanoc::Int::Item.new('asdf', {}, '/foo.md') }
|
281
|
+
|
282
|
+
it { is_expected.to eql('Nanoc::CompilationItemRepView<Nanoc::Int::ItemRep<item=Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>,name=Symbol<pdf>>>') }
|
283
|
+
end
|
284
|
+
|
285
|
+
context 'Nanoc::BasicItemView' do
|
286
|
+
let(:obj) { Nanoc::BasicItemView.new(item, nil) }
|
279
287
|
let(:item) { Nanoc::Int::Item.new('asdf', {}, '/foo.md') }
|
280
288
|
|
281
|
-
it { is_expected.to eql('Nanoc::
|
289
|
+
it { is_expected.to eql('Nanoc::BasicItemView<Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>>') }
|
282
290
|
end
|
283
291
|
|
284
292
|
context 'Nanoc::LayoutView' do
|
@@ -362,9 +370,9 @@ describe Nanoc::Int::Checksummer do
|
|
362
370
|
[
|
363
371
|
'Nanoc::RuleDSL::RuleContext<',
|
364
372
|
'item=',
|
365
|
-
'Nanoc::
|
373
|
+
'Nanoc::BasicItemView<' + expected_item_checksum + '>',
|
366
374
|
',rep=',
|
367
|
-
'Nanoc::
|
375
|
+
'Nanoc::BasicItemRepView<' + expected_item_rep_checksum + '>',
|
368
376
|
',items=',
|
369
377
|
'Nanoc::ItemCollectionWithoutRepsView<Array<' + expected_item_checksum + ',>>',
|
370
378
|
',layouts=',
|