nanoc 4.8.9 → 4.8.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +6 -4
  3. data/Gemfile +2 -1
  4. data/NEWS.md +7 -0
  5. data/README.md +1 -1
  6. data/lib/nanoc.rb +2 -6
  7. data/lib/nanoc/base/entities/site.rb +9 -5
  8. data/lib/nanoc/base/repos/data_source.rb +0 -15
  9. data/lib/nanoc/base/repos/outdatedness_store.rb +17 -15
  10. data/lib/nanoc/base/services/compilation_context.rb +4 -4
  11. data/lib/nanoc/base/services/compiler.rb +102 -103
  12. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +7 -7
  13. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +4 -2
  14. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +25 -7
  15. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +3 -3
  16. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +3 -0
  17. data/lib/nanoc/base/services/compiler_loader.rb +1 -4
  18. data/lib/nanoc/base/views.rb +13 -6
  19. data/lib/nanoc/base/views/{item_rep_collection_view.rb → basic_item_rep_collection_view.rb} +6 -6
  20. data/lib/nanoc/base/views/{item_rep_view.rb → basic_item_rep_view.rb} +8 -29
  21. data/lib/nanoc/base/views/{item_without_reps_view.rb → basic_item_view.rb} +3 -3
  22. data/lib/nanoc/base/views/compilation_item_rep_collection_view.rb +10 -0
  23. data/lib/nanoc/base/views/compilation_item_rep_view.rb +42 -0
  24. data/lib/nanoc/base/views/{mixins/with_reps_view_mixin.rb → compilation_item_view.rb} +3 -3
  25. data/lib/nanoc/base/views/item_collection_with_reps_view.rb +1 -1
  26. data/lib/nanoc/base/views/item_collection_without_reps_view.rb +1 -1
  27. data/lib/nanoc/base/views/mixins/mutable_document_view_mixin.rb +1 -1
  28. data/lib/nanoc/base/views/mutable_item_view.rb +1 -1
  29. data/lib/nanoc/base/views/post_compile_item_rep_collection_view.rb +1 -1
  30. data/lib/nanoc/base/views/post_compile_item_rep_view.rb +7 -2
  31. data/lib/nanoc/base/views/post_compile_item_view.rb +1 -1
  32. data/lib/nanoc/base/views/{view_context.rb → view_context_for_compilation.rb} +10 -1
  33. data/lib/nanoc/base/views/view_context_for_pre_compilation.rb +18 -0
  34. data/lib/nanoc/base/views/view_context_for_shell.rb +23 -0
  35. data/lib/nanoc/checking/check.rb +5 -1
  36. data/lib/nanoc/checking/runner.rb +1 -1
  37. data/lib/nanoc/cli.rb +1 -0
  38. data/lib/nanoc/cli/command_runner.rb +1 -7
  39. data/lib/nanoc/cli/commands/check.rb +2 -2
  40. data/lib/nanoc/cli/commands/compile.rb +8 -47
  41. data/lib/nanoc/cli/commands/compile_listeners/abstract.rb +9 -0
  42. data/lib/nanoc/cli/commands/compile_listeners/aggregate.rb +49 -0
  43. data/lib/nanoc/cli/commands/deploy.rb +2 -1
  44. data/lib/nanoc/cli/commands/prune.rb +5 -4
  45. data/lib/nanoc/cli/commands/shell.rb +4 -6
  46. data/lib/nanoc/cli/commands/show-data.rb +20 -27
  47. data/lib/nanoc/cli/commands/show-rules.rb +20 -22
  48. data/lib/nanoc/cli/error_handler.rb +0 -17
  49. data/lib/nanoc/data_sources/filesystem.rb +4 -2
  50. data/lib/nanoc/deploying/deployers/fog.rb +4 -1
  51. data/lib/nanoc/helpers/link_to.rb +1 -1
  52. data/lib/nanoc/rule_dsl/action_provider.rb +8 -11
  53. data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +14 -5
  54. data/lib/nanoc/rule_dsl/recording_executor.rb +4 -0
  55. data/lib/nanoc/rule_dsl/rule.rb +14 -9
  56. data/lib/nanoc/rule_dsl/rule_context.rb +4 -4
  57. data/lib/nanoc/spec.rb +27 -19
  58. data/lib/nanoc/version.rb +1 -1
  59. data/spec/nanoc/base/checksummer_spec.rb +19 -11
  60. data/spec/nanoc/base/compiler_spec.rb +18 -14
  61. data/spec/nanoc/base/filter_spec.rb +7 -6
  62. data/spec/nanoc/base/repos/outdatedness_store_spec.rb +3 -32
  63. data/spec/nanoc/base/services/compiler/stages/compile_reps_spec.rb +2 -1
  64. data/spec/nanoc/base/services/compiler/stages/determine_outdatedness_spec.rb +148 -0
  65. data/spec/nanoc/base/services/compiler/stages/preprocess_spec.rb +110 -0
  66. data/spec/nanoc/base/services/executor_spec.rb +6 -6
  67. data/spec/nanoc/base/views/basic_item_rep_collection_view_spec.rb +8 -0
  68. data/spec/nanoc/base/views/basic_item_rep_view_spec.rb +9 -0
  69. data/spec/nanoc/base/views/compilation_item_rep_collection_view_spec.rb +8 -0
  70. data/spec/nanoc/base/views/compilation_item_rep_view_spec.rb +136 -0
  71. data/spec/nanoc/base/views/config_view_spec.rb +5 -5
  72. data/spec/nanoc/base/views/item_collection_with_reps_view_spec.rb +4 -2
  73. data/spec/nanoc/base/views/item_collection_without_reps_view_spec.rb +4 -2
  74. data/spec/nanoc/base/views/item_view_spec.rb +13 -11
  75. data/spec/nanoc/base/views/layout_collection_view_spec.rb +3 -1
  76. data/spec/nanoc/base/views/layout_view_spec.rb +3 -1
  77. data/spec/nanoc/base/views/mutable_item_collection_view_spec.rb +5 -2
  78. data/spec/nanoc/base/views/mutable_item_view_spec.rb +2 -0
  79. data/spec/nanoc/base/views/mutable_layout_collection_view_spec.rb +5 -2
  80. data/spec/nanoc/base/views/mutable_layout_view_spec.rb +2 -0
  81. data/spec/nanoc/base/views/post_compile_item_rep_collection_view_spec.rb +2 -0
  82. data/spec/nanoc/base/views/post_compile_item_rep_view_spec.rb +9 -3
  83. data/spec/nanoc/base/views/{document_view_spec.rb → support/document_view_examples.rb} +5 -5
  84. data/spec/nanoc/base/views/{identifiable_collection_view_spec.rb → support/identifiable_collection_view_examples.rb} +4 -4
  85. data/spec/nanoc/base/views/{item_rep_collection_view_spec.rb → support/item_rep_collection_view_examples.rb} +3 -8
  86. data/spec/nanoc/base/views/{item_rep_view_spec.rb → support/item_rep_view_examples.rb} +10 -111
  87. data/spec/nanoc/base/views/{mutable_document_view_spec.rb → support/mutable_document_view_examples.rb} +7 -6
  88. data/spec/nanoc/base/views/{mutable_identifiable_collection_view_spec.rb → support/mutable_identifiable_collection_view_examples.rb} +1 -1
  89. data/spec/nanoc/cli/commands/compile/abstract_spec.rb +80 -0
  90. data/spec/nanoc/cli/commands/compile_spec.rb +30 -51
  91. data/spec/nanoc/cli/commands/show_data_spec.rb +2 -23
  92. data/spec/nanoc/cli/commands/show_rules_spec.rb +4 -2
  93. data/spec/nanoc/regressions/gh_767_spec.rb +1 -1
  94. data/spec/nanoc/regressions/gh_776_spec.rb +2 -1
  95. data/spec/nanoc/rule_dsl/action_sequence_calculator_spec.rb +25 -12
  96. data/spec/nanoc/rule_dsl/rule_context_spec.rb +16 -6
  97. data/test/base/test_data_source.rb +0 -18
  98. data/test/checking/checks/test_external_links.rb +4 -6
  99. data/test/checking/checks/test_internal_links.rb +6 -9
  100. data/test/cli/commands/test_compile.rb +0 -35
  101. data/test/cli/test_cleaning_stream.rb +1 -1
  102. data/test/data_sources/test_filesystem.rb +16 -0
  103. data/test/filters/test_kramdown.rb +4 -4
  104. data/test/filters/test_sass.rb +1 -1
  105. data/test/filters/test_slim.rb +7 -5
  106. data/test/filters/test_xsl.rb +10 -8
  107. data/test/helpers/test_blogging.rb +5 -5
  108. data/test/helpers/test_capturing.rb +8 -6
  109. data/test/helpers/test_link_to.rb +4 -4
  110. data/test/helpers/test_xml_sitemap.rb +19 -19
  111. metadata +25 -15
  112. data/lib/nanoc/base/views/item_with_reps_view.rb +0 -7
  113. 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
- @site = load_site
13
+ site = load_site
14
14
 
15
- @c = Nanoc::CLI::ANSIStringColorizer
15
+ res = Nanoc::Int::Compiler.new_for(site).run_until_reps_built
16
+ reps = res.fetch(:reps)
16
17
 
17
- compiler = @site.compiler
18
- compiler.build_reps
19
- @reps = compiler.reps
18
+ action_provider = Nanoc::Int::ActionProvider.named(:rule_dsl).for(site)
19
+ rules = action_provider.rules_collection
20
20
 
21
- action_provider = @site.compiler.action_provider
22
- unless action_provider.respond_to?(:rules_collection)
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
- @site.items.sort_by(&:identifier).each { |e| explain_item(e) }
31
- @site.layouts.sort_by(&:identifier).each { |e| explain_layout(e) }
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 "#{@c.c('Item ' + item.identifier, :bold, :yellow)}:"
28
+ def explain_item(item, rules:, reps:)
29
+ puts(fmt_heading("Item #{item.identifier}") + ':')
36
30
 
37
- @reps[item].each do |rep|
38
- rule = @rules.compilation_rule_for(rep)
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 "#{@c.c('Layout ' + layout.identifier, :bold, :yellow)}:"
39
+ def explain_layout(layout, rules:)
40
+ puts(fmt_heading("Layout #{layout.identifier}") + ':')
47
41
 
48
42
  found = false
49
- @rules.layout_filter_mapping.each_key do |pattern|
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-{3,5}\s*$/
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(/^(-{5}|-{3})[ \t]*\r?\n?/, 3)
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::ItemWithRepsView, Nanoc::ItemWithoutRepsView, Nanoc::ItemRepView
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::ViewContext.new(
63
+ Nanoc::ViewContextForCompilation.new(
60
64
  reps: reps,
61
65
  items: site.items,
62
66
  dependency_tracker: dependency_tracker,
63
- compilation_context: site.compiler.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::ViewContext.new(
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
- dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
61
- view_context = @site.compiler.compilation_context.create_view_context(dependency_tracker)
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
- dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
136
- view_context = Nanoc::ViewContext.new(reps: nil, items: nil, dependency_tracker: dependency_tracker, compilation_context: nil, snapshot_repo: nil)
137
- basic_path = routing_rule.apply_to(rep, executor: nil, site: @site, view_context: view_context)
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
@@ -14,6 +14,10 @@ module Nanoc
14
14
  @pre_snapshot = false
15
15
  end
16
16
 
17
+ def inspect
18
+ "<#{self.class}>"
19
+ end
20
+
17
21
  def filter(filter_name, filter_args = {})
18
22
  @action_sequence_builder.add_filter(filter_name, filter_args)
19
23
  end
@@ -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
- # Applies this rule to the given item rep.
48
- #
49
- # @param [Nanoc::Int::ItemRep] rep
50
- # @param [Nanoc::Int::Site] site
51
- # @param [Nanoc::Int::Executor, Nanoc::RuleDSL::RecordingExecutor] executor
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, executor: executor, site: site, view_context: view_context,
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::ViewContext] view_context
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::ItemWithoutRepsView.new(rep.item, view_context),
19
- rep: Nanoc::ItemRepView.new(rep, view_context),
20
- item_rep: Nanoc::ItemRepView.new(rep, view_context),
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),
@@ -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::ItemWithRepsView] A view for the newly created item
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::ItemWithRepsView] A view for the newly created layout
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::ItemWithRepsView] item The item to create a represetation for
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::ItemWithRepsView, nil]
100
+ # @return [Nanoc::CompilationItemView, nil]
99
101
  def item
100
102
  assigns[:item]
101
103
  end
102
104
 
103
- # @return [Nanoc::ItemRepView, nil]
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
- Nanoc::ViewContext.new(
134
- reps: @reps,
135
- items: @items,
136
- dependency_tracker: @dependency_tracker,
137
- compilation_context: site.compiler.compilation_context,
138
- snapshot_repo: site.compiler.compilation_context.snapshot_repo,
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: new_action_provider)
178
+ Nanoc::Int::CompilerLoader.new.load(site, action_provider: @action_provider)
168
179
  end
169
180
 
170
181
  def site
171
- @_site ||= begin
172
- site = Nanoc::Int::Site.new(
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::ItemRepView.new(@item_rep, view_context) : nil,
186
- item: @item ? Nanoc::ItemWithRepsView.new(@item, view_context) : nil,
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,
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.8.9'
5
+ VERSION = '4.8.10'
6
6
  end
@@ -252,11 +252,11 @@ describe Nanoc::Int::Checksummer do
252
252
  end
253
253
  end
254
254
 
255
- context 'Nanoc::ItemWithRepsView' do
256
- let(:obj) { Nanoc::ItemWithRepsView.new(item, nil) }
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::ItemWithRepsView<Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>>') }
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::ItemRepView' do
270
- let(:obj) { Nanoc::ItemRepView.new(rep, :_unused_context) }
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::ItemRepView<Nanoc::Int::ItemRep<item=Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>,name=Symbol<pdf>>>') }
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::ItemWithoutRepsView' do
278
- let(:obj) { Nanoc::ItemWithoutRepsView.new(item, nil) }
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::ItemWithoutRepsView<Nanoc::Int::Item<content=Nanoc::Int::TextualContent<String<asdf>>,attributes=Hash<>,identifier=Nanoc::Identifier<String</foo.md>>>>') }
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::ItemWithoutRepsView<' + expected_item_checksum + '>',
373
+ 'Nanoc::BasicItemView<' + expected_item_checksum + '>',
366
374
  ',rep=',
367
- 'Nanoc::ItemRepView<' + expected_item_rep_checksum + '>',
375
+ 'Nanoc::BasicItemRepView<' + expected_item_rep_checksum + '>',
368
376
  ',items=',
369
377
  'Nanoc::ItemCollectionWithoutRepsView<Array<' + expected_item_checksum + ',>>',
370
378
  ',layouts=',