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
@@ -1,9 +1,14 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
module Nanoc
|
4
|
-
class PostCompileItemRepView < ::Nanoc::
|
4
|
+
class PostCompileItemRepView < ::Nanoc::BasicItemRepView
|
5
|
+
def item_view_class
|
6
|
+
Nanoc::PostCompileItemView
|
7
|
+
end
|
8
|
+
|
5
9
|
def compiled_content(snapshot: nil)
|
6
|
-
|
10
|
+
compilation_context = @context.compilation_context
|
11
|
+
snapshot_contents = compilation_context.compiled_content_cache[unwrap]
|
7
12
|
|
8
13
|
snapshot_name = snapshot || (snapshot_contents[:pre] ? :pre : :last)
|
9
14
|
|
@@ -2,13 +2,22 @@
|
|
2
2
|
|
3
3
|
module Nanoc
|
4
4
|
# @api private
|
5
|
-
class
|
5
|
+
class ViewContextForCompilation
|
6
|
+
include Nanoc::Int::ContractsSupport
|
7
|
+
|
6
8
|
attr_reader :reps
|
7
9
|
attr_reader :items
|
8
10
|
attr_reader :dependency_tracker
|
9
11
|
attr_reader :compilation_context
|
10
12
|
attr_reader :snapshot_repo
|
11
13
|
|
14
|
+
contract C::KeywordArgs[
|
15
|
+
reps: Nanoc::Int::ItemRepRepo,
|
16
|
+
items: Nanoc::Int::IdentifiableCollection,
|
17
|
+
dependency_tracker: C::Any,
|
18
|
+
compilation_context: C::Any,
|
19
|
+
snapshot_repo: C::Any,
|
20
|
+
] => C::Any
|
12
21
|
def initialize(reps:, items:, dependency_tracker:, compilation_context:, snapshot_repo:)
|
13
22
|
@reps = reps
|
14
23
|
@items = items
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
# @api private
|
5
|
+
class ViewContextForPreCompilation
|
6
|
+
include Nanoc::Int::ContractsSupport
|
7
|
+
|
8
|
+
attr_reader :items
|
9
|
+
attr_reader :dependency_tracker
|
10
|
+
|
11
|
+
contract C::KeywordArgs[items: Nanoc::Int::IdentifiableCollection] => C::Any
|
12
|
+
def initialize(items:)
|
13
|
+
@items = items
|
14
|
+
|
15
|
+
@dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc
|
4
|
+
# @api private
|
5
|
+
class ViewContextForShell
|
6
|
+
include Nanoc::Int::ContractsSupport
|
7
|
+
|
8
|
+
attr_reader :items
|
9
|
+
attr_reader :reps
|
10
|
+
attr_reader :dependency_tracker
|
11
|
+
|
12
|
+
contract C::KeywordArgs[
|
13
|
+
items: Nanoc::Int::IdentifiableCollection,
|
14
|
+
reps: Nanoc::Int::ItemRepRepo,
|
15
|
+
] => C::Any
|
16
|
+
def initialize(items:, reps:)
|
17
|
+
@items = items
|
18
|
+
@reps = reps
|
19
|
+
|
20
|
+
@dependency_tracker = Nanoc::Int::DependencyTracker::Null.new
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
data/lib/nanoc/checking/check.rb
CHANGED
@@ -22,7 +22,11 @@ module Nanoc::Checking
|
|
22
22
|
output_filenames = Dir[output_dir + '/**/*'].select { |f| File.file?(f) }
|
23
23
|
|
24
24
|
# FIXME: ugly
|
25
|
-
|
25
|
+
compiler = Nanoc::Int::Compiler.new_for(site)
|
26
|
+
res = compiler.run_until_reps_built
|
27
|
+
reps = res.fetch(:reps)
|
28
|
+
compilation_context = compiler.compilation_context(reps: reps)
|
29
|
+
view_context = compilation_context.create_view_context(Nanoc::Int::DependencyTracker::Null.new)
|
26
30
|
|
27
31
|
context = {
|
28
32
|
items: Nanoc::PostCompileItemCollectionView.new(site.items, view_context),
|
data/lib/nanoc/cli.rb
CHANGED
@@ -26,6 +26,7 @@ require_relative 'cli/commands/compile_listeners/debug_printer'
|
|
26
26
|
require_relative 'cli/commands/compile_listeners/diff_generator'
|
27
27
|
require_relative 'cli/commands/compile_listeners/file_action_printer'
|
28
28
|
require_relative 'cli/commands/compile_listeners/timing_recorder'
|
29
|
+
require_relative 'cli/commands/compile_listeners/aggregate'
|
29
30
|
|
30
31
|
# @api private
|
31
32
|
module Nanoc::CLI
|
@@ -50,20 +50,14 @@ module Nanoc::CLI
|
|
50
50
|
# Asserts that the current working directory contains a site and loads the site into memory.
|
51
51
|
#
|
52
52
|
# @return [void]
|
53
|
-
def load_site
|
53
|
+
def load_site
|
54
54
|
self.class.enter_site_dir
|
55
55
|
|
56
56
|
$stderr.print 'Loading site… '
|
57
57
|
$stderr.flush
|
58
|
-
|
59
58
|
site = Nanoc::Int::SiteLoader.new.new_from_cwd
|
60
59
|
|
61
|
-
if preprocess
|
62
|
-
site.compiler.action_provider.preprocess(site)
|
63
|
-
end
|
64
|
-
|
65
60
|
$stderr.puts 'done'
|
66
|
-
|
67
61
|
site
|
68
62
|
end
|
69
63
|
|
@@ -14,9 +14,9 @@ module Nanoc::CLI::Commands
|
|
14
14
|
class Check < ::Nanoc::CLI::CommandRunner
|
15
15
|
def run
|
16
16
|
validate_options_and_arguments
|
17
|
-
|
17
|
+
site = load_site
|
18
18
|
|
19
|
-
runner = Nanoc::Checking::Runner.new(
|
19
|
+
runner = Nanoc::Checking::Runner.new(site)
|
20
20
|
|
21
21
|
if options[:list]
|
22
22
|
runner.list_checks
|
@@ -11,65 +11,26 @@ module Nanoc::CLI::Commands
|
|
11
11
|
class Compile < ::Nanoc::CLI::CommandRunner
|
12
12
|
attr_accessor :listener_classes
|
13
13
|
|
14
|
-
def initialize(options, arguments, command)
|
15
|
-
super
|
16
|
-
@listener_classes = default_listener_classes
|
17
|
-
end
|
18
|
-
|
19
14
|
def run
|
20
15
|
time_before = Time.now
|
21
16
|
|
22
17
|
@site = load_site
|
23
18
|
|
24
19
|
puts 'Compiling site…'
|
25
|
-
|
26
|
-
|
20
|
+
compiler = Nanoc::Int::Compiler.new_for(@site)
|
21
|
+
listener = Nanoc::CLI::Commands::CompileListeners::Aggregate.new(
|
22
|
+
command_runner: self,
|
23
|
+
site: @site,
|
24
|
+
compiler: compiler,
|
25
|
+
)
|
26
|
+
listener.run_while do
|
27
|
+
compiler.run_until_end
|
27
28
|
end
|
28
29
|
|
29
30
|
time_after = Time.now
|
30
31
|
puts
|
31
32
|
puts "Site compiled in #{format('%.2f', time_after - time_before)}s."
|
32
33
|
end
|
33
|
-
|
34
|
-
protected
|
35
|
-
|
36
|
-
def default_listener_classes
|
37
|
-
[
|
38
|
-
Nanoc::CLI::Commands::CompileListeners::DiffGenerator,
|
39
|
-
Nanoc::CLI::Commands::CompileListeners::DebugPrinter,
|
40
|
-
Nanoc::CLI::Commands::CompileListeners::TimingRecorder,
|
41
|
-
Nanoc::CLI::Commands::CompileListeners::FileActionPrinter,
|
42
|
-
]
|
43
|
-
end
|
44
|
-
|
45
|
-
def setup_listeners
|
46
|
-
@listeners =
|
47
|
-
@listener_classes
|
48
|
-
.select { |klass| klass.enable_for?(self, @site) }
|
49
|
-
.map { |klass| klass.new(reps: reps) }
|
50
|
-
|
51
|
-
@listeners.each(&:start_safely)
|
52
|
-
end
|
53
|
-
|
54
|
-
def listeners
|
55
|
-
@listeners
|
56
|
-
end
|
57
|
-
|
58
|
-
def run_listeners_while
|
59
|
-
setup_listeners
|
60
|
-
yield
|
61
|
-
ensure
|
62
|
-
teardown_listeners
|
63
|
-
end
|
64
|
-
|
65
|
-
def teardown_listeners
|
66
|
-
return unless @listeners
|
67
|
-
@listeners.reverse_each(&:stop_safely)
|
68
|
-
end
|
69
|
-
|
70
|
-
def reps
|
71
|
-
@site.compiler.reps
|
72
|
-
end
|
73
34
|
end
|
74
35
|
end
|
75
36
|
|
@@ -8,12 +8,21 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
8
8
|
true
|
9
9
|
end
|
10
10
|
|
11
|
+
# @abstract
|
11
12
|
def start
|
12
13
|
raise NotImplementedError, "Subclasses of #{self.class} must implement #start"
|
13
14
|
end
|
14
15
|
|
16
|
+
# @abstract
|
15
17
|
def stop; end
|
16
18
|
|
19
|
+
def run_while
|
20
|
+
start
|
21
|
+
yield
|
22
|
+
ensure
|
23
|
+
stop
|
24
|
+
end
|
25
|
+
|
17
26
|
def start_safely
|
18
27
|
start
|
19
28
|
@_started = true
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc::CLI::Commands::CompileListeners
|
4
|
+
class Aggregate < Abstract
|
5
|
+
def initialize(command_runner:, site:, compiler:)
|
6
|
+
@site = site
|
7
|
+
@compiler = compiler
|
8
|
+
@command_runner = command_runner
|
9
|
+
|
10
|
+
@listener_classes = self.class.default_listener_classes
|
11
|
+
end
|
12
|
+
|
13
|
+
def start
|
14
|
+
setup_listeners
|
15
|
+
end
|
16
|
+
|
17
|
+
def stop
|
18
|
+
teardown_listeners
|
19
|
+
end
|
20
|
+
|
21
|
+
def self.default_listener_classes
|
22
|
+
[
|
23
|
+
Nanoc::CLI::Commands::CompileListeners::DiffGenerator,
|
24
|
+
Nanoc::CLI::Commands::CompileListeners::DebugPrinter,
|
25
|
+
Nanoc::CLI::Commands::CompileListeners::TimingRecorder,
|
26
|
+
Nanoc::CLI::Commands::CompileListeners::FileActionPrinter,
|
27
|
+
]
|
28
|
+
end
|
29
|
+
|
30
|
+
protected
|
31
|
+
|
32
|
+
def setup_listeners
|
33
|
+
res = @compiler.run_until_reps_built
|
34
|
+
reps = res.fetch(:reps)
|
35
|
+
|
36
|
+
@listeners =
|
37
|
+
@listener_classes
|
38
|
+
.select { |klass| klass.enable_for?(@command_runner, @site) }
|
39
|
+
.map { |klass| klass.new(reps: reps) }
|
40
|
+
|
41
|
+
@listeners.each(&:start_safely)
|
42
|
+
end
|
43
|
+
|
44
|
+
def teardown_listeners
|
45
|
+
return unless @listeners
|
46
|
+
@listeners.reverse_each(&:stop_safely)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -15,7 +15,8 @@ option :n, :'dry-run', 'show what would be deployed'
|
|
15
15
|
module Nanoc::CLI::Commands
|
16
16
|
class Deploy < ::Nanoc::CLI::CommandRunner
|
17
17
|
def run
|
18
|
-
@site = load_site
|
18
|
+
@site = load_site
|
19
|
+
Nanoc::Int::Compiler.new_for(@site).run_until_preprocessed
|
19
20
|
|
20
21
|
if options[:'list-deployers']
|
21
22
|
list_deployers
|
@@ -17,13 +17,14 @@ flag :n, :'dry-run', 'print files to be deleted instead of actually deleting the
|
|
17
17
|
module Nanoc::CLI::Commands
|
18
18
|
class Prune < ::Nanoc::CLI::CommandRunner
|
19
19
|
def run
|
20
|
-
@site = load_site
|
21
|
-
@site.
|
20
|
+
@site = load_site
|
21
|
+
res = Nanoc::Int::Compiler.new_for(@site).run_until_reps_built
|
22
|
+
reps = res.fetch(:reps)
|
22
23
|
|
23
24
|
if options.key?(:yes)
|
24
|
-
Nanoc::Pruner.new(@site.config,
|
25
|
+
Nanoc::Pruner.new(@site.config, reps, exclude: prune_config_exclude).run
|
25
26
|
elsif options.key?(:'dry-run')
|
26
|
-
Nanoc::Pruner.new(@site.config,
|
27
|
+
Nanoc::Pruner.new(@site.config, reps, exclude: prune_config_exclude, dry_run: true).run
|
27
28
|
else
|
28
29
|
$stderr.puts 'WARNING: Since the prune command is a destructive command, it requires an additional --yes flag in order to work.'
|
29
30
|
$stderr.puts
|
@@ -13,7 +13,8 @@ module Nanoc::CLI::Commands
|
|
13
13
|
def run
|
14
14
|
require 'pry'
|
15
15
|
|
16
|
-
@site = load_site
|
16
|
+
@site = load_site
|
17
|
+
Nanoc::Int::Compiler.new_for(@site).run_until_preprocessed if options[:preprocess]
|
17
18
|
|
18
19
|
Nanoc::Int::Context.new(env).pry
|
19
20
|
end
|
@@ -31,12 +32,9 @@ module Nanoc::CLI::Commands
|
|
31
32
|
end
|
32
33
|
|
33
34
|
def self.view_context_for(site)
|
34
|
-
Nanoc::
|
35
|
-
reps: reps_for(site),
|
35
|
+
Nanoc::ViewContextForShell.new(
|
36
36
|
items: site.items,
|
37
|
-
|
38
|
-
compilation_context: nil,
|
39
|
-
snapshot_repo: nil,
|
37
|
+
reps: reps_for(site),
|
40
38
|
)
|
41
39
|
end
|
42
40
|
|
@@ -11,25 +11,20 @@ EOS
|
|
11
11
|
module Nanoc::CLI::Commands
|
12
12
|
class ShowData < ::Nanoc::CLI::CommandRunner
|
13
13
|
def run
|
14
|
-
|
14
|
+
site = load_site
|
15
|
+
res = Nanoc::Int::Compiler.new_for(site).run_until_precompiled
|
15
16
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
compiler = @site.compiler
|
22
|
-
compiler.load_stores
|
23
|
-
dependency_store = compiler.dependency_store
|
24
|
-
|
25
|
-
# Build reps
|
26
|
-
compiler.build_reps
|
17
|
+
items = site.items
|
18
|
+
layouts = site.layouts
|
19
|
+
reps = res.fetch(:reps)
|
20
|
+
dependency_store = res.fetch(:dependency_store)
|
21
|
+
outdatedness_checker = res.fetch(:outdatedness_checker)
|
27
22
|
|
28
23
|
# Print data
|
29
24
|
print_item_dependencies(items, dependency_store)
|
30
|
-
print_item_rep_paths(items)
|
31
|
-
print_item_rep_outdatedness(items,
|
32
|
-
print_layouts(layouts,
|
25
|
+
print_item_rep_paths(items, reps)
|
26
|
+
print_item_rep_outdatedness(items, outdatedness_checker, reps)
|
27
|
+
print_layouts(layouts, outdatedness_checker)
|
33
28
|
end
|
34
29
|
|
35
30
|
protected
|
@@ -42,10 +37,10 @@ module Nanoc::CLI::Commands
|
|
42
37
|
end
|
43
38
|
end
|
44
39
|
|
45
|
-
def sorted_reps_with_prev(items)
|
40
|
+
def sorted_reps_with_prev(items, reps)
|
46
41
|
prev = nil
|
47
42
|
items.sort_by(&:identifier).each do |item|
|
48
|
-
|
43
|
+
reps[item].sort_by { |r| r.name.to_s }.each do |rep|
|
49
44
|
yield(rep, prev)
|
50
45
|
prev = rep
|
51
46
|
end
|
@@ -131,10 +126,10 @@ module Nanoc::CLI::Commands
|
|
131
126
|
end
|
132
127
|
end
|
133
128
|
|
134
|
-
def print_item_rep_paths(items)
|
129
|
+
def print_item_rep_paths(items, reps)
|
135
130
|
print_header('Item representation paths')
|
136
131
|
|
137
|
-
sorted_reps_with_prev(items) do |rep, prev|
|
132
|
+
sorted_reps_with_prev(items, reps) do |rep, prev|
|
138
133
|
puts if prev
|
139
134
|
puts "item #{rep.item.identifier}, rep #{rep.name}:"
|
140
135
|
if rep.raw_paths.empty?
|
@@ -149,29 +144,27 @@ module Nanoc::CLI::Commands
|
|
149
144
|
end
|
150
145
|
end
|
151
146
|
|
152
|
-
def print_item_rep_outdatedness(items,
|
147
|
+
def print_item_rep_outdatedness(items, outdatedness_checker, reps)
|
153
148
|
print_header('Item representation outdatedness')
|
154
149
|
|
155
|
-
sorted_reps_with_prev(items) do |rep, prev|
|
150
|
+
sorted_reps_with_prev(items, reps) do |rep, prev|
|
156
151
|
puts if prev
|
157
152
|
puts "item #{rep.item.identifier}, rep #{rep.name}:"
|
158
|
-
print_outdatedness_reasons_for(rep,
|
153
|
+
print_outdatedness_reasons_for(rep, outdatedness_checker)
|
159
154
|
end
|
160
155
|
end
|
161
156
|
|
162
|
-
def print_layouts(layouts,
|
157
|
+
def print_layouts(layouts, outdatedness_checker)
|
163
158
|
print_header('Layouts')
|
164
159
|
|
165
160
|
sorted_with_prev(layouts) do |layout, prev|
|
166
161
|
puts if prev
|
167
162
|
puts "layout #{layout.identifier}:"
|
168
|
-
print_outdatedness_reasons_for(layout,
|
163
|
+
print_outdatedness_reasons_for(layout, outdatedness_checker)
|
169
164
|
end
|
170
165
|
end
|
171
166
|
|
172
|
-
def print_outdatedness_reasons_for(obj,
|
173
|
-
compiler.calculate_checksums
|
174
|
-
outdatedness_checker = compiler.create_outdatedness_checker
|
167
|
+
def print_outdatedness_reasons_for(obj, outdatedness_checker)
|
175
168
|
reasons = outdatedness_checker.outdatedness_reasons_for(obj)
|
176
169
|
if reasons.any?
|
177
170
|
puts ' is outdated:'
|