nanoc 4.8.19 → 4.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/LICENSE +1 -1
- data/NEWS.md +21 -0
- data/lib/nanoc.rb +5 -4
- data/lib/nanoc/base/entities/directed_graph.rb +4 -4
- data/lib/nanoc/base/entities/identifier.rb +5 -0
- data/lib/nanoc/base/feature.rb +1 -2
- data/lib/nanoc/base/repos/dependency_store.rb +4 -4
- data/lib/nanoc/base/services/compiler/phases/abstract.rb +8 -0
- data/lib/nanoc/base/services/compiler/phases/write.rb +58 -1
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +39 -29
- data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +2 -2
- data/lib/nanoc/base/services/instrumentor.rb +1 -1
- data/lib/nanoc/base/services/item_rep_writer.rb +2 -2
- data/lib/nanoc/base/views/compilation_item_rep_view.rb +7 -0
- data/lib/nanoc/checking.rb +4 -1
- data/lib/nanoc/checking/check.rb +7 -0
- data/lib/nanoc/checking/checks/external_links.rb +21 -12
- data/lib/nanoc/checking/dsl.rb +5 -7
- data/lib/nanoc/checking/loader.rb +50 -0
- data/lib/nanoc/checking/runner.rb +18 -40
- data/lib/nanoc/cli.rb +1 -1
- data/lib/nanoc/cli/ansi_string_colorizer.rb +4 -4
- data/lib/nanoc/cli/cleaning_stream.rb +12 -12
- data/lib/nanoc/cli/commands/check.rb +5 -15
- data/lib/nanoc/cli/commands/compile_listeners/diff_generator.rb +7 -7
- data/lib/nanoc/cli/commands/compile_listeners/file_action_printer.rb +12 -2
- data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +27 -19
- data/lib/nanoc/cli/commands/deploy.rb +1 -1
- data/lib/nanoc/cli/commands/show-rules.rb +2 -2
- data/lib/nanoc/cli/error_handler.rb +1 -4
- data/lib/nanoc/cli/stream_cleaners/abstract.rb +2 -2
- data/lib/nanoc/cli/stream_cleaners/ansi_colors.rb +2 -2
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +2 -2
- data/lib/nanoc/data_sources/filesystem/parser.rb +1 -1
- data/lib/nanoc/deploying/deployers/fog.rb +3 -3
- data/lib/nanoc/extra.rb +1 -2
- data/lib/nanoc/filters/colorize_syntax.rb +2 -2
- data/lib/nanoc/filters/relativize_paths.rb +2 -2
- data/lib/nanoc/helpers/blogging.rb +11 -11
- data/lib/nanoc/rule_dsl/compilation_rule_context.rb +1 -1
- data/lib/nanoc/version.rb +1 -1
- metadata +27 -13
- data/lib/nanoc/extra/parallel_collection.rb +0 -57
data/lib/nanoc/checking/dsl.rb
CHANGED
@@ -3,17 +3,15 @@
|
|
3
3
|
module Nanoc::Checking
|
4
4
|
# @api private
|
5
5
|
class DSL
|
6
|
-
|
7
|
-
|
8
|
-
def self.from_file(filename)
|
9
|
-
dsl = new
|
6
|
+
def self.from_file(filename, enabled_checks:)
|
7
|
+
dsl = new(enabled_checks: enabled_checks)
|
10
8
|
absolute_filename = File.expand_path(filename)
|
11
9
|
dsl.instance_eval(File.read(filename), absolute_filename)
|
12
10
|
dsl
|
13
11
|
end
|
14
12
|
|
15
|
-
def initialize
|
16
|
-
@
|
13
|
+
def initialize(enabled_checks:)
|
14
|
+
@enabled_checks = enabled_checks
|
17
15
|
end
|
18
16
|
|
19
17
|
def check(identifier, &block)
|
@@ -23,7 +21,7 @@ module Nanoc::Checking
|
|
23
21
|
end
|
24
22
|
|
25
23
|
def deploy_check(*identifiers)
|
26
|
-
identifiers.each { |i| @
|
24
|
+
identifiers.each { |i| @enabled_checks << i }
|
27
25
|
end
|
28
26
|
end
|
29
27
|
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Nanoc::Checking
|
4
|
+
# @api private
|
5
|
+
class Loader
|
6
|
+
CHECKS_FILENAMES = ['Checks', 'Checks.rb', 'checks', 'checks.rb'].freeze
|
7
|
+
|
8
|
+
def initialize(config:)
|
9
|
+
@config = config
|
10
|
+
end
|
11
|
+
|
12
|
+
def run
|
13
|
+
dsl
|
14
|
+
end
|
15
|
+
|
16
|
+
def enabled_checks
|
17
|
+
(enabled_checks_from_dsl + enabled_checks_from_config).uniq
|
18
|
+
end
|
19
|
+
|
20
|
+
private
|
21
|
+
|
22
|
+
def dsl_present?
|
23
|
+
checks_filename && File.file?(checks_filename)
|
24
|
+
end
|
25
|
+
|
26
|
+
def enabled_checks_from_dsl
|
27
|
+
dsl
|
28
|
+
@enabled_checks_from_dsl
|
29
|
+
end
|
30
|
+
|
31
|
+
def enabled_checks_from_config
|
32
|
+
@config.fetch(:checking, {}).fetch(:enabled_checks, []).map(&:to_sym)
|
33
|
+
end
|
34
|
+
|
35
|
+
def dsl
|
36
|
+
@enabled_checks_from_dsl ||= []
|
37
|
+
|
38
|
+
@dsl ||=
|
39
|
+
if dsl_present?
|
40
|
+
Nanoc::Checking::DSL.from_file(checks_filename, enabled_checks: @enabled_checks_from_dsl)
|
41
|
+
else
|
42
|
+
Nanoc::Checking::DSL.new(enabled_checks: @enabled_checks_from_dsl)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
def checks_filename
|
47
|
+
@_checks_filename ||= CHECKS_FILENAMES.find { |f| File.file?(f) }
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
@@ -5,29 +5,20 @@ module Nanoc::Checking
|
|
5
5
|
#
|
6
6
|
# @api private
|
7
7
|
class Runner
|
8
|
-
CHECKS_FILENAMES = ['Checks', 'Checks.rb', 'checks', 'checks.rb'].freeze
|
9
|
-
|
10
8
|
# @param [Nanoc::Int::Site] site The Nanoc site this runner is for
|
11
9
|
def initialize(site)
|
12
10
|
@site = site
|
13
11
|
end
|
14
12
|
|
15
|
-
|
16
|
-
|
17
|
-
@_checks_filename ||= CHECKS_FILENAMES.find { |f| File.file?(f) }
|
18
|
-
end
|
19
|
-
|
20
|
-
# @return [Boolean] true if a Checks file exists, false otherwise
|
21
|
-
def dsl_present?
|
22
|
-
checks_filename && File.file?(checks_filename)
|
13
|
+
def any_enabled_checks?
|
14
|
+
enabled_checks.any?
|
23
15
|
end
|
24
|
-
alias has_dsl? dsl_present?
|
25
16
|
|
26
17
|
# Lists all available checks on stdout.
|
27
18
|
#
|
28
19
|
# @return [void]
|
29
20
|
def list_checks
|
30
|
-
|
21
|
+
load_all
|
31
22
|
|
32
23
|
puts 'Available checks:'
|
33
24
|
puts
|
@@ -38,8 +29,7 @@ module Nanoc::Checking
|
|
38
29
|
#
|
39
30
|
# @return [Boolean] true if successful, false otherwise
|
40
31
|
def run_all
|
41
|
-
|
42
|
-
|
32
|
+
load_all
|
43
33
|
run_check_classes(all_check_classes)
|
44
34
|
end
|
45
35
|
|
@@ -47,10 +37,9 @@ module Nanoc::Checking
|
|
47
37
|
#
|
48
38
|
# @return [Boolean] true if successful, false otherwise
|
49
39
|
def run_for_deploy
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
run_check_classes(check_classes_named(dsl.deploy_checks))
|
40
|
+
# TODO: rename to #run_enabled
|
41
|
+
load_all
|
42
|
+
run_check_classes(check_classes_named(enabled_checks))
|
54
43
|
end
|
55
44
|
|
56
45
|
# Runs the checks with the given names.
|
@@ -59,33 +48,22 @@ module Nanoc::Checking
|
|
59
48
|
#
|
60
49
|
# @return [Boolean] true if successful, false otherwise
|
61
50
|
def run_specific(check_class_names)
|
62
|
-
|
63
|
-
|
51
|
+
load_all
|
64
52
|
run_check_classes(check_classes_named(check_class_names))
|
65
53
|
end
|
66
54
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
if dsl_present?
|
72
|
-
Nanoc::Checking::DSL.from_file(checks_filename)
|
73
|
-
else
|
74
|
-
nil
|
75
|
-
end
|
76
|
-
@dsl_loaded = true
|
77
|
-
end
|
55
|
+
private
|
56
|
+
|
57
|
+
def loader
|
58
|
+
@loader ||= Nanoc::Checking::Loader.new(config: @site.config)
|
78
59
|
end
|
79
60
|
|
80
|
-
def
|
81
|
-
|
82
|
-
if dsl.nil?
|
83
|
-
raise Nanoc::Int::Errors::GenericTrivial, "No checks defined (no #{CHECKS_FILENAMES.first} file present)"
|
84
|
-
end
|
61
|
+
def load_all
|
62
|
+
loader.run
|
85
63
|
end
|
86
64
|
|
87
|
-
def
|
88
|
-
|
65
|
+
def enabled_checks
|
66
|
+
loader.enabled_checks
|
89
67
|
end
|
90
68
|
|
91
69
|
def run_check_classes(classes)
|
@@ -132,8 +110,8 @@ module Nanoc::Checking
|
|
132
110
|
issues
|
133
111
|
end
|
134
112
|
|
135
|
-
def subject_to_s(
|
136
|
-
|
113
|
+
def subject_to_s(str)
|
114
|
+
str || '(global)'
|
137
115
|
end
|
138
116
|
|
139
117
|
def print_issues(issues)
|
data/lib/nanoc/cli.rb
CHANGED
@@ -15,14 +15,14 @@ module Nanoc::CLI
|
|
15
15
|
blue: "\e[34m",
|
16
16
|
}.freeze
|
17
17
|
|
18
|
-
# @param [String]
|
18
|
+
# @param [String] str The string to colorize
|
19
19
|
#
|
20
|
-
# @param [Array]
|
20
|
+
# @param [Array] attrs An array of attributes from `MAPPING` to colorize the
|
21
21
|
# string with
|
22
22
|
#
|
23
23
|
# @return [String] A string colorized using the given attributes
|
24
|
-
def self.c(
|
25
|
-
|
24
|
+
def self.c(str, *attrs)
|
25
|
+
attrs.map { |a| MAPPING[a] }.join('') + str + "\e[0m"
|
26
26
|
end
|
27
27
|
end
|
28
28
|
end
|
@@ -40,16 +40,16 @@ module Nanoc::CLI
|
|
40
40
|
# @group IO proxy methods
|
41
41
|
|
42
42
|
# @see IO#write
|
43
|
-
def write(
|
43
|
+
def write(str)
|
44
44
|
_nanoc_swallow_broken_pipe_errors_while do
|
45
|
-
@stream.write(_nanoc_clean(
|
45
|
+
@stream.write(_nanoc_clean(str))
|
46
46
|
end
|
47
47
|
end
|
48
48
|
|
49
49
|
# @see IO#<<
|
50
|
-
def <<(
|
50
|
+
def <<(str)
|
51
51
|
_nanoc_swallow_broken_pipe_errors_while do
|
52
|
-
@stream.<<(_nanoc_clean(
|
52
|
+
@stream.<<(_nanoc_clean(str))
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
@@ -76,16 +76,16 @@ module Nanoc::CLI
|
|
76
76
|
end
|
77
77
|
|
78
78
|
# @see IO#print
|
79
|
-
def print(
|
79
|
+
def print(str)
|
80
80
|
_nanoc_swallow_broken_pipe_errors_while do
|
81
|
-
@stream.print(_nanoc_clean(
|
81
|
+
@stream.print(_nanoc_clean(str))
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
85
|
# @see IO#puts
|
86
|
-
def puts(*
|
86
|
+
def puts(*str)
|
87
87
|
_nanoc_swallow_broken_pipe_errors_while do
|
88
|
-
@stream.puts(*
|
88
|
+
@stream.puts(*str.map { |ss| _nanoc_clean(ss) })
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
@@ -95,8 +95,8 @@ module Nanoc::CLI
|
|
95
95
|
end
|
96
96
|
|
97
97
|
# @see IO#reopen
|
98
|
-
def reopen(*
|
99
|
-
@stream.reopen(*
|
98
|
+
def reopen(*args)
|
99
|
+
@stream.reopen(*args)
|
100
100
|
end
|
101
101
|
|
102
102
|
# @see IO#close
|
@@ -148,8 +148,8 @@ module Nanoc::CLI
|
|
148
148
|
|
149
149
|
protected
|
150
150
|
|
151
|
-
def _nanoc_clean(
|
152
|
-
@stream_cleaners.reduce(
|
151
|
+
def _nanoc_clean(str)
|
152
|
+
@stream_cleaners.reduce(str.to_s.scrub) { |acc, elem| elem.clean(acc) }
|
153
153
|
end
|
154
154
|
|
155
155
|
def _nanoc_swallow_broken_pipe_errors_while
|
@@ -3,17 +3,16 @@
|
|
3
3
|
usage 'check [options] [names]'
|
4
4
|
summary 'run issue checks'
|
5
5
|
description "
|
6
|
-
Run issue checks on the current site. If the `--all` option is passed, all available issue checks will be run.
|
6
|
+
Run issue checks on the current site. If the `--all` option is passed, all available issue checks will be run. By default, the issue checks marked for deployment will be run.
|
7
7
|
"
|
8
8
|
|
9
9
|
flag :a, :all, 'run all checks'
|
10
10
|
flag :L, :list, 'list all checks'
|
11
|
-
flag :d, :deploy, '
|
11
|
+
flag :d, :deploy, '(deprecated)'
|
12
12
|
|
13
13
|
module Nanoc::CLI::Commands
|
14
14
|
class Check < ::Nanoc::CLI::CommandRunner
|
15
15
|
def run
|
16
|
-
validate_options_and_arguments
|
17
16
|
site = load_site
|
18
17
|
|
19
18
|
runner = Nanoc::Checking::Runner.new(site)
|
@@ -28,25 +27,16 @@ module Nanoc::CLI::Commands
|
|
28
27
|
runner.run_all
|
29
28
|
elsif options[:deploy]
|
30
29
|
runner.run_for_deploy
|
31
|
-
|
30
|
+
elsif arguments.any?
|
32
31
|
runner.run_specific(arguments)
|
32
|
+
else
|
33
|
+
runner.run_for_deploy
|
33
34
|
end
|
34
35
|
|
35
36
|
unless success
|
36
37
|
raise Nanoc::Int::Errors::GenericTrivial, 'One or more checks failed'
|
37
38
|
end
|
38
39
|
end
|
39
|
-
|
40
|
-
protected
|
41
|
-
|
42
|
-
def validate_options_and_arguments
|
43
|
-
if arguments.empty? && !options[:all] && !options[:deploy] && !options[:list]
|
44
|
-
raise(
|
45
|
-
Nanoc::Int::Errors::GenericTrivial,
|
46
|
-
'nothing to do (pass either --all, --deploy or --list or a list of checks)',
|
47
|
-
)
|
48
|
-
end
|
49
|
-
end
|
50
40
|
end
|
51
41
|
end
|
52
42
|
|
@@ -11,10 +11,10 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
11
11
|
def start
|
12
12
|
setup_diffs
|
13
13
|
old_contents = {}
|
14
|
-
Nanoc::Int::NotificationCenter.on(:
|
14
|
+
Nanoc::Int::NotificationCenter.on(:rep_write_started, self) do |rep, path|
|
15
15
|
old_contents[rep] = File.file?(path) ? File.read(path) : nil
|
16
16
|
end
|
17
|
-
Nanoc::Int::NotificationCenter.on(:
|
17
|
+
Nanoc::Int::NotificationCenter.on(:rep_write_ended, self) do |rep, binary, path, _is_created, _is_modified|
|
18
18
|
unless binary
|
19
19
|
new_contents = File.file?(path) ? File.read(path) : nil
|
20
20
|
if old_contents[rep] && new_contents
|
@@ -29,8 +29,8 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
29
29
|
def stop
|
30
30
|
super
|
31
31
|
|
32
|
-
Nanoc::Int::NotificationCenter.remove(:
|
33
|
-
Nanoc::Int::NotificationCenter.remove(:
|
32
|
+
Nanoc::Int::NotificationCenter.remove(:rep_write_started, self)
|
33
|
+
Nanoc::Int::NotificationCenter.remove(:rep_write_ended, self)
|
34
34
|
|
35
35
|
teardown_diffs
|
36
36
|
end
|
@@ -63,14 +63,14 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
63
63
|
end
|
64
64
|
end
|
65
65
|
|
66
|
-
def diff_strings(
|
66
|
+
def diff_strings(str_a, str_b)
|
67
67
|
# Create files
|
68
68
|
Tempfile.open('old') do |old_file|
|
69
69
|
Tempfile.open('new') do |new_file|
|
70
70
|
# Write files
|
71
|
-
old_file.write(
|
71
|
+
old_file.write(str_a)
|
72
72
|
old_file.flush
|
73
|
-
new_file.write(
|
73
|
+
new_file.write(str_b)
|
74
74
|
new_file.flush
|
75
75
|
|
76
76
|
# Diff
|
@@ -25,7 +25,15 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
25
25
|
cached_reps << rep
|
26
26
|
end
|
27
27
|
|
28
|
-
Nanoc::Int::NotificationCenter.on(:
|
28
|
+
Nanoc::Int::NotificationCenter.on(:rep_write_enqueued, self) do |rep|
|
29
|
+
@acc_durations[rep] += Time.now - @start_times[rep]
|
30
|
+
end
|
31
|
+
|
32
|
+
Nanoc::Int::NotificationCenter.on(:rep_write_started, self) do |rep, _raw_path|
|
33
|
+
@start_times[rep] = Time.now
|
34
|
+
end
|
35
|
+
|
36
|
+
Nanoc::Int::NotificationCenter.on(:rep_write_ended, self) do |rep, _binary, path, is_created, is_modified|
|
29
37
|
@acc_durations[rep] += Time.now - @start_times[rep]
|
30
38
|
duration = @acc_durations[rep]
|
31
39
|
|
@@ -50,7 +58,9 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
50
58
|
|
51
59
|
Nanoc::Int::NotificationCenter.remove(:compilation_started, self)
|
52
60
|
Nanoc::Int::NotificationCenter.remove(:compilation_suspended, self)
|
53
|
-
Nanoc::Int::NotificationCenter.remove(:
|
61
|
+
Nanoc::Int::NotificationCenter.remove(:rep_write_enqueued, self)
|
62
|
+
Nanoc::Int::NotificationCenter.remove(:rep_write_started, self)
|
63
|
+
Nanoc::Int::NotificationCenter.remove(:rep_write_ended, self)
|
54
64
|
|
55
65
|
@reps.reject(&:compiled?).each do |rep|
|
56
66
|
raw_paths = rep.raw_paths.values.flatten.uniq
|
@@ -16,28 +16,28 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
16
16
|
def initialize(reps:)
|
17
17
|
@reps = reps
|
18
18
|
|
19
|
-
@stages_summary =
|
20
|
-
@phases_summary =
|
21
|
-
@outdatedness_rules_summary =
|
22
|
-
@filters_summary =
|
23
|
-
@load_stores_summary =
|
19
|
+
@stages_summary = DDMetrics::Summary.new
|
20
|
+
@phases_summary = DDMetrics::Summary.new
|
21
|
+
@outdatedness_rules_summary = DDMetrics::Summary.new
|
22
|
+
@filters_summary = DDMetrics::Summary.new
|
23
|
+
@load_stores_summary = DDMetrics::Summary.new
|
24
24
|
end
|
25
25
|
|
26
26
|
# @see Listener#start
|
27
27
|
def start
|
28
28
|
on(:stage_ran) do |duration, klass|
|
29
|
-
@stages_summary.observe(duration, klass.to_s.sub(/.*::/, ''))
|
29
|
+
@stages_summary.observe(duration, name: klass.to_s.sub(/.*::/, ''))
|
30
30
|
end
|
31
31
|
|
32
32
|
on(:outdatedness_rule_ran) do |duration, klass|
|
33
|
-
@outdatedness_rules_summary.observe(duration, klass.to_s.sub(/.*::/, ''))
|
33
|
+
@outdatedness_rules_summary.observe(duration, name: klass.to_s.sub(/.*::/, ''))
|
34
34
|
end
|
35
35
|
|
36
36
|
filter_stopwatches = {}
|
37
37
|
|
38
38
|
on(:filtering_started) do |rep, _filter_name|
|
39
39
|
stopwatch_stack = filter_stopwatches.fetch(rep) { filter_stopwatches[rep] = [] }
|
40
|
-
stopwatch_stack <<
|
40
|
+
stopwatch_stack << DDMetrics::Stopwatch.new
|
41
41
|
stopwatch_stack.last.start
|
42
42
|
end
|
43
43
|
|
@@ -45,11 +45,11 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
45
45
|
stopwatch = filter_stopwatches.fetch(rep).pop
|
46
46
|
stopwatch.stop
|
47
47
|
|
48
|
-
@filters_summary.observe(stopwatch.duration, filter_name.to_s)
|
48
|
+
@filters_summary.observe(stopwatch.duration, name: filter_name.to_s)
|
49
49
|
end
|
50
50
|
|
51
51
|
on(:store_loaded) do |duration, klass|
|
52
|
-
@load_stores_summary.observe(duration, klass.to_s)
|
52
|
+
@load_stores_summary.observe(duration, name: klass.to_s)
|
53
53
|
end
|
54
54
|
|
55
55
|
on(:compilation_suspended) do |rep, _exception|
|
@@ -64,14 +64,14 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
64
64
|
|
65
65
|
on(:phase_started) do |phase_name, rep|
|
66
66
|
stopwatches = phase_stopwatches.fetch(rep) { phase_stopwatches[rep] = {} }
|
67
|
-
stopwatches[phase_name] =
|
67
|
+
stopwatches[phase_name] = DDMetrics::Stopwatch.new.tap(&:start)
|
68
68
|
end
|
69
69
|
|
70
70
|
on(:phase_ended) do |phase_name, rep|
|
71
71
|
stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
|
72
72
|
stopwatch.stop
|
73
73
|
|
74
|
-
@phases_summary.observe(stopwatch.duration, phase_name)
|
74
|
+
@phases_summary.observe(stopwatch.duration, name: phase_name)
|
75
75
|
end
|
76
76
|
|
77
77
|
on(:phase_yielded) do |phase_name, rep|
|
@@ -88,7 +88,7 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
88
88
|
stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
|
89
89
|
stopwatch.stop if stopwatch.running?
|
90
90
|
|
91
|
-
@phases_summary.observe(stopwatch.duration, phase_name)
|
91
|
+
@phases_summary.observe(stopwatch.duration, name: phase_name)
|
92
92
|
end
|
93
93
|
end
|
94
94
|
|
@@ -103,7 +103,9 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
103
103
|
def table_for_summary(name, summary)
|
104
104
|
headers = [name.to_s, 'count', 'min', '.50', '.90', '.95', 'max', 'tot']
|
105
105
|
|
106
|
-
rows = summary.map do |
|
106
|
+
rows = summary.map do |label, stats|
|
107
|
+
name = label.fetch(:name)
|
108
|
+
|
107
109
|
count = stats.count
|
108
110
|
min = stats.min
|
109
111
|
p50 = stats.quantile(0.50)
|
@@ -112,7 +114,7 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
112
114
|
tot = stats.sum
|
113
115
|
max = stats.max
|
114
116
|
|
115
|
-
[
|
117
|
+
[name, count.to_s] + [min, p50, p90, p95, max, tot].map { |r| "#{format('%4.2f', r)}s" }
|
116
118
|
end
|
117
119
|
|
118
120
|
[headers] + rows
|
@@ -121,8 +123,9 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
121
123
|
def table_for_summary_durations(name, summary)
|
122
124
|
headers = [name.to_s, 'tot']
|
123
125
|
|
124
|
-
rows = summary.map do |
|
125
|
-
|
126
|
+
rows = summary.map do |label, stats|
|
127
|
+
name = label.fetch(:name)
|
128
|
+
[name, "#{format('%4.2f', stats.sum)}s"]
|
126
129
|
end
|
127
130
|
|
128
131
|
[headers] + rows
|
@@ -134,7 +137,7 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
134
137
|
print_table_for_summary_duration(:stages, @stages_summary) if Nanoc::CLI.verbosity >= 2
|
135
138
|
print_table_for_summary(:outdatedness_rules, @outdatedness_rules_summary) if Nanoc::CLI.verbosity >= 2
|
136
139
|
print_table_for_summary_duration(:load_stores, @load_stores_summary) if Nanoc::CLI.verbosity >= 2
|
137
|
-
|
140
|
+
print_ddmemoize_metrics if Nanoc::CLI.verbosity >= 2
|
138
141
|
end
|
139
142
|
|
140
143
|
def print_table_for_summary(name, summary)
|
@@ -151,8 +154,13 @@ module Nanoc::CLI::Commands::CompileListeners
|
|
151
154
|
print_table(table_for_summary_durations(name, summary))
|
152
155
|
end
|
153
156
|
|
157
|
+
def print_ddmemoize_metrics
|
158
|
+
puts
|
159
|
+
DDMemoize.print_metrics
|
160
|
+
end
|
161
|
+
|
154
162
|
def print_table(rows)
|
155
|
-
puts
|
163
|
+
puts DDMetrics::Table.new(rows).to_s
|
156
164
|
end
|
157
165
|
end
|
158
166
|
end
|