nanoc 4.6.4 → 4.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +12 -4
- data/NEWS.md +7 -0
- data/README.md +1 -1
- data/lib/nanoc/base/feature.rb +1 -1
- data/lib/nanoc/base/services/compiler.rb +18 -11
- data/lib/nanoc/base/services/compiler/phases.rb +2 -0
- data/lib/nanoc/base/services/compiler/phases/abstract.rb +34 -0
- data/lib/nanoc/base/services/compiler/phases/cache.rb +8 -5
- data/lib/nanoc/base/services/compiler/phases/mark_done.rb +8 -5
- data/lib/nanoc/base/services/compiler/phases/recalculate.rb +6 -2
- data/lib/nanoc/base/services/compiler/phases/resume.rb +9 -7
- data/lib/nanoc/base/services/compiler/phases/write.rb +8 -5
- data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +1 -1
- data/lib/nanoc/cli.rb +8 -0
- data/lib/nanoc/cli/commands/compile.rb +81 -27
- data/lib/nanoc/cli/commands/nanoc.rb +2 -1
- data/lib/nanoc/cli/error_handler.rb +1 -0
- data/lib/nanoc/filters.rb +1 -0
- data/lib/nanoc/filters/erubi.rb +27 -0
- data/lib/nanoc/rule_dsl/rule_context.rb +16 -2
- data/lib/nanoc/telemetry/labelled_counter.rb +9 -9
- data/lib/nanoc/telemetry/labelled_summary.rb +15 -11
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/base/compiler_spec.rb +2 -0
- data/spec/nanoc/base/services/compiler/phases/abstract_spec.rb +49 -0
- data/spec/nanoc/base/services/compiler/phases/cache_spec.rb +13 -9
- data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +101 -5
- data/spec/nanoc/rule_dsl/rule_context_spec.rb +63 -13
- data/spec/nanoc/telemetry/labelled_counter_spec.rb +10 -10
- data/spec/nanoc/telemetry/labelled_summary_spec.rb +36 -23
- data/spec/nanoc/telemetry/stopwatch_spec.rb +2 -0
- data/spec/nanoc/telemetry_spec.rb +14 -14
- data/spec/spec_helper.rb +3 -0
- data/test/base/test_compiler.rb +0 -38
- data/test/checking/checks/test_html.rb +0 -4
- data/test/filters/test_erubi.rb +73 -0
- data/test/fixtures/vcr_cassettes/html_run_ok.yml +27 -98
- data/test/helper.rb +3 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a139ed28840cdd9e8d815959a6ce67a2a3d64629
|
4
|
+
data.tar.gz: 443fad3be7c31740a6b0378e37b358355f4cf451
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 54e42408687a77e4775218127f65e92780702969c3f18e8d4dbd723b7428d6f0a8eec603545ab092f69de699af67af0861ae690b142b5e9314ac4c893ef8830b
|
7
|
+
data.tar.gz: 66dc4eb54985f21f9a6614b366fbcd4b0dc4b8e3dc3cd4fe0e7b6f5c3497432f91e0221e3868cf8c2a2bb60df04dd18d8a0909508e3ef6aad2a15e45ef2cf8f2
|
data/Gemfile
CHANGED
@@ -3,6 +3,7 @@ source 'https://rubygems.org'
|
|
3
3
|
gemspec
|
4
4
|
|
5
5
|
group :devel do
|
6
|
+
gem 'codecov', require: false
|
6
7
|
gem 'contracts', '~> 0.14'
|
7
8
|
gem 'coveralls', require: false
|
8
9
|
gem 'fuubar'
|
@@ -34,6 +35,7 @@ group :plugins do
|
|
34
35
|
gem 'coderay'
|
35
36
|
gem 'coffee-script'
|
36
37
|
gem 'compass'
|
38
|
+
gem 'erubi'
|
37
39
|
gem 'erubis'
|
38
40
|
gem 'fog'
|
39
41
|
gem 'haml'
|
data/Gemfile.lock
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
GIT
|
2
2
|
remote: https://github.com/bbatsov/rubocop.git
|
3
|
-
revision:
|
3
|
+
revision: 7623afc89d97b6149067428e1cb8d69a1786d0b3
|
4
4
|
specs:
|
5
5
|
rubocop (0.47.1)
|
6
6
|
parser (>= 2.3.3.1, < 3.0)
|
@@ -27,7 +27,7 @@ GIT
|
|
27
27
|
PATH
|
28
28
|
remote: .
|
29
29
|
specs:
|
30
|
-
nanoc (4.
|
30
|
+
nanoc (4.7.0)
|
31
31
|
cri (~> 2.3)
|
32
32
|
ddplugin (~> 1.0)
|
33
33
|
hamster (~> 3.0)
|
@@ -50,6 +50,10 @@ GEM
|
|
50
50
|
bluecloth (2.2.0)
|
51
51
|
builder (3.2.3)
|
52
52
|
chunky_png (1.3.8)
|
53
|
+
codecov (0.1.10)
|
54
|
+
json
|
55
|
+
simplecov
|
56
|
+
url
|
53
57
|
coderay (1.1.1)
|
54
58
|
coffee-script (2.4.1)
|
55
59
|
coffee-script-source
|
@@ -84,6 +88,7 @@ GEM
|
|
84
88
|
ddplugin (1.0.1)
|
85
89
|
diff-lcs (1.3)
|
86
90
|
docile (1.1.5)
|
91
|
+
erubi (1.6.0)
|
87
92
|
erubis (2.7.0)
|
88
93
|
excon (0.55.0)
|
89
94
|
execjs (2.7.0)
|
@@ -291,7 +296,7 @@ GEM
|
|
291
296
|
rb-fsevent (0.9.8)
|
292
297
|
rb-inotify (0.9.8)
|
293
298
|
ffi (>= 0.5.0)
|
294
|
-
rbvmomi (1.
|
299
|
+
rbvmomi (1.10.0)
|
295
300
|
builder (~> 3.0)
|
296
301
|
json (>= 1.8)
|
297
302
|
nokogiri (~> 1.5)
|
@@ -342,9 +347,10 @@ GEM
|
|
342
347
|
trollop (2.1.2)
|
343
348
|
typogruby (1.0.18)
|
344
349
|
rubypants
|
345
|
-
uglifier (3.1.
|
350
|
+
uglifier (3.1.7)
|
346
351
|
execjs (>= 0.3.0, < 3)
|
347
352
|
unicode-display_width (1.1.3)
|
353
|
+
url (0.3.2)
|
348
354
|
vcr (3.0.3)
|
349
355
|
w3c_validators (1.3.2)
|
350
356
|
json (>= 1.8)
|
@@ -370,11 +376,13 @@ DEPENDENCIES
|
|
370
376
|
bluecloth
|
371
377
|
builder
|
372
378
|
bundler (>= 1.7.10, < 2.0)
|
379
|
+
codecov
|
373
380
|
coderay
|
374
381
|
coffee-script
|
375
382
|
compass
|
376
383
|
contracts (~> 0.14)
|
377
384
|
coveralls
|
385
|
+
erubi
|
378
386
|
erubis
|
379
387
|
fog
|
380
388
|
fuubar
|
data/NEWS.md
CHANGED
data/README.md
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
[![Gem version](http://img.shields.io/gem/v/nanoc.svg)](http://rubygems.org/gems/nanoc)
|
2
2
|
[![Build status](http://img.shields.io/travis/nanoc/nanoc.svg)](https://travis-ci.org/nanoc/nanoc)
|
3
3
|
[![Code Climate](http://img.shields.io/codeclimate/github/nanoc/nanoc.svg)](https://codeclimate.com/github/nanoc/nanoc)
|
4
|
-
[![Code Coverage](
|
4
|
+
[![Code Coverage](https://img.shields.io/codecov/c/github/nanoc/nanoc.svg)](https://codecov.io/gh/nanoc/nanoc)
|
5
5
|
|
6
6
|
![Nanoc logo](https://avatars1.githubusercontent.com/u/3260163?s=140)
|
7
7
|
|
data/lib/nanoc/base/feature.rb
CHANGED
@@ -121,18 +121,18 @@ module Nanoc::Int
|
|
121
121
|
end
|
122
122
|
|
123
123
|
def run_all
|
124
|
-
preprocess_stage.run
|
125
|
-
build_reps
|
126
|
-
prune_stage.run
|
127
|
-
load_stores
|
128
|
-
determine_outdatedness
|
129
|
-
forget_dependencies_if_needed
|
130
|
-
store
|
131
|
-
compile_reps_stage.run
|
132
|
-
store_output_state
|
133
|
-
@action_provider.postprocess(@site, @reps)
|
124
|
+
time_stage(:preprocess) { preprocess_stage.run }
|
125
|
+
time_stage(:build_reps) { build_reps }
|
126
|
+
time_stage(:prune) { prune_stage.run }
|
127
|
+
time_stage(:load_stores) { load_stores }
|
128
|
+
time_stage(:determine_outdatedness) { determine_outdatedness }
|
129
|
+
time_stage(:forget_dependencies_if_needed) { forget_dependencies_if_needed }
|
130
|
+
time_stage(:store) { store }
|
131
|
+
time_stage(:compile_reps) { compile_reps_stage.run }
|
132
|
+
time_stage(:store_output_state) { store_output_state }
|
133
|
+
time_stage(:postprocess) { @action_provider.postprocess(@site, @reps) }
|
134
134
|
ensure
|
135
|
-
cleanup_stage.run
|
135
|
+
time_stage(:cleanup) { cleanup_stage.run }
|
136
136
|
end
|
137
137
|
|
138
138
|
def load_stores
|
@@ -179,6 +179,13 @@ module Nanoc::Int
|
|
179
179
|
|
180
180
|
private
|
181
181
|
|
182
|
+
def time_stage(name)
|
183
|
+
Nanoc::Int::NotificationCenter.post(:stage_started, name)
|
184
|
+
yield
|
185
|
+
ensure
|
186
|
+
Nanoc::Int::NotificationCenter.post(:stage_ended, name)
|
187
|
+
end
|
188
|
+
|
182
189
|
def preprocess_stage
|
183
190
|
@_preprocess_stage ||= Stages::Preprocess.new(
|
184
191
|
action_provider: action_provider,
|
@@ -0,0 +1,34 @@
|
|
1
|
+
module Nanoc::Int::Compiler::Phases
|
2
|
+
class Abstract
|
3
|
+
include Nanoc::Int::ContractsSupport
|
4
|
+
|
5
|
+
def initialize(wrapped:, name:)
|
6
|
+
@name = name
|
7
|
+
@wrapped = wrapped
|
8
|
+
end
|
9
|
+
|
10
|
+
def call(rep, is_outdated:)
|
11
|
+
notify(:phase_started, rep)
|
12
|
+
run(rep, is_outdated: is_outdated) do
|
13
|
+
notify(:phase_yielded, rep)
|
14
|
+
@wrapped.call(rep, is_outdated: is_outdated)
|
15
|
+
notify(:phase_resumed, rep)
|
16
|
+
end
|
17
|
+
notify(:phase_ended, rep)
|
18
|
+
rescue
|
19
|
+
notify(:phase_aborted, rep)
|
20
|
+
raise
|
21
|
+
end
|
22
|
+
|
23
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
24
|
+
def run(_rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
25
|
+
raise NotImplementedError
|
26
|
+
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def notify(sym, rep)
|
31
|
+
Nanoc::Int::NotificationCenter.post(sym, @name, rep)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -1,23 +1,26 @@
|
|
1
1
|
module Nanoc::Int::Compiler::Phases
|
2
2
|
# Provides functionality for (re)calculating the content of an item rep, with caching or
|
3
3
|
# outdatedness checking. Delegates to s::Recalculate if outdated or no cache available.
|
4
|
-
class Cache
|
4
|
+
class Cache < Abstract
|
5
5
|
include Nanoc::Int::ContractsSupport
|
6
6
|
|
7
|
-
|
7
|
+
NAME = 'cache'.freeze
|
8
|
+
|
9
|
+
def initialize(wrapped:, compiled_content_cache:, snapshot_repo:)
|
10
|
+
super(wrapped: wrapped, name: NAME)
|
11
|
+
|
8
12
|
@compiled_content_cache = compiled_content_cache
|
9
13
|
@snapshot_repo = snapshot_repo
|
10
|
-
@wrapped = wrapped
|
11
14
|
end
|
12
15
|
|
13
|
-
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
16
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
14
17
|
def run(rep, is_outdated:)
|
15
18
|
if can_reuse_content_for_rep?(rep, is_outdated: is_outdated)
|
16
19
|
Nanoc::Int::NotificationCenter.post(:cached_content_used, rep)
|
17
20
|
|
18
21
|
@snapshot_repo.set_all(rep, @compiled_content_cache[rep])
|
19
22
|
else
|
20
|
-
|
23
|
+
yield
|
21
24
|
end
|
22
25
|
|
23
26
|
rep.compiled = true
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module Nanoc::Int::Compiler::Phases
|
2
|
-
class MarkDone
|
2
|
+
class MarkDone < Abstract
|
3
3
|
include Nanoc::Int::ContractsSupport
|
4
4
|
|
5
|
+
NAME = 'mark_done'.freeze
|
6
|
+
|
5
7
|
def initialize(wrapped:, outdatedness_store:)
|
6
|
-
|
8
|
+
super(wrapped: wrapped, name: NAME)
|
9
|
+
|
7
10
|
@outdatedness_store = outdatedness_store
|
8
11
|
end
|
9
12
|
|
10
|
-
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
11
|
-
def run(rep, is_outdated:)
|
12
|
-
|
13
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
14
|
+
def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
15
|
+
yield
|
13
16
|
@outdatedness_store.remove(rep)
|
14
17
|
end
|
15
18
|
end
|
@@ -1,16 +1,20 @@
|
|
1
1
|
module Nanoc::Int::Compiler::Phases
|
2
2
|
# Provides functionality for (re)calculating the content of an item rep, without caching or
|
3
3
|
# outdatedness checking.
|
4
|
-
class Recalculate
|
4
|
+
class Recalculate < Abstract
|
5
5
|
include Nanoc::Int::ContractsSupport
|
6
6
|
|
7
|
+
NAME = 'recalculate'.freeze
|
8
|
+
|
7
9
|
def initialize(action_provider:, dependency_store:, compilation_context:)
|
10
|
+
super(wrapped: nil, name: NAME)
|
11
|
+
|
8
12
|
@action_provider = action_provider
|
9
13
|
@dependency_store = dependency_store
|
10
14
|
@compilation_context = compilation_context
|
11
15
|
end
|
12
16
|
|
13
|
-
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
17
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
14
18
|
def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
15
19
|
dependency_tracker = Nanoc::Int::DependencyTracker.new(@dependency_store)
|
16
20
|
dependency_tracker.enter(rep.item)
|
@@ -1,15 +1,17 @@
|
|
1
1
|
module Nanoc::Int::Compiler::Phases
|
2
2
|
# Provides functionality for suspending and resuming item rep compilation (using fibers).
|
3
|
-
class Resume
|
3
|
+
class Resume < Abstract
|
4
4
|
include Nanoc::Int::ContractsSupport
|
5
5
|
|
6
|
+
NAME = 'resume'.freeze
|
7
|
+
|
6
8
|
def initialize(wrapped:)
|
7
|
-
|
9
|
+
super(wrapped: wrapped, name: NAME)
|
8
10
|
end
|
9
11
|
|
10
|
-
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
12
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
11
13
|
def run(rep, is_outdated:)
|
12
|
-
fiber = fiber_for(rep, is_outdated: is_outdated)
|
14
|
+
fiber = fiber_for(rep, is_outdated: is_outdated) { yield }
|
13
15
|
while fiber.alive?
|
14
16
|
Nanoc::Int::NotificationCenter.post(:compilation_started, rep)
|
15
17
|
res = fiber.resume
|
@@ -30,13 +32,13 @@ module Nanoc::Int::Compiler::Phases
|
|
30
32
|
|
31
33
|
private
|
32
34
|
|
33
|
-
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => Fiber
|
34
|
-
def fiber_for(rep, is_outdated:)
|
35
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => Fiber
|
36
|
+
def fiber_for(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
35
37
|
@fibers ||= {}
|
36
38
|
|
37
39
|
@fibers[rep] ||=
|
38
40
|
Fiber.new do
|
39
|
-
|
41
|
+
yield
|
40
42
|
@fibers.delete(rep)
|
41
43
|
end
|
42
44
|
|
@@ -1,15 +1,18 @@
|
|
1
1
|
module Nanoc::Int::Compiler::Phases
|
2
|
-
class Write
|
2
|
+
class Write < Abstract
|
3
3
|
include Nanoc::Int::ContractsSupport
|
4
4
|
|
5
|
+
NAME = 'write'.freeze
|
6
|
+
|
5
7
|
def initialize(snapshot_repo:, wrapped:)
|
8
|
+
super(wrapped: wrapped, name: NAME)
|
9
|
+
|
6
10
|
@snapshot_repo = snapshot_repo
|
7
|
-
@wrapped = wrapped
|
8
11
|
end
|
9
12
|
|
10
|
-
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Any
|
11
|
-
def run(rep, is_outdated:)
|
12
|
-
|
13
|
+
contract Nanoc::Int::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
|
14
|
+
def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
|
15
|
+
yield
|
13
16
|
|
14
17
|
Nanoc::Int::ItemRepWriter.new.write_all(rep, @snapshot_repo)
|
15
18
|
end
|
data/lib/nanoc/cli.rb
CHANGED
@@ -34,6 +34,14 @@ module Nanoc::CLI
|
|
34
34
|
@debug = boolean
|
35
35
|
end
|
36
36
|
|
37
|
+
def self.verbosity
|
38
|
+
@verbosity || 0
|
39
|
+
end
|
40
|
+
|
41
|
+
def self.verbosity=(val)
|
42
|
+
@verbosity = val
|
43
|
+
end
|
44
|
+
|
37
45
|
# Invokes the Nanoc command-line tool with the given arguments.
|
38
46
|
#
|
39
47
|
# @param [Array<String>] args An array of command-line arguments
|
@@ -158,29 +158,70 @@ module Nanoc::CLI::Commands
|
|
158
158
|
def start
|
159
159
|
@telemetry = Nanoc::Telemetry.new
|
160
160
|
|
161
|
-
|
161
|
+
stage_stopwatch = Nanoc::Telemetry::Stopwatch.new
|
162
|
+
|
163
|
+
Nanoc::Int::NotificationCenter.on(:stage_started) do |_stage_name|
|
164
|
+
stage_stopwatch.start
|
165
|
+
end
|
166
|
+
|
167
|
+
Nanoc::Int::NotificationCenter.on(:stage_ended) do |stage_name|
|
168
|
+
stage_stopwatch.stop
|
169
|
+
@telemetry.summary(:stages).observe(stage_stopwatch.duration, stage_name.to_s)
|
170
|
+
stage_stopwatch = Nanoc::Telemetry::Stopwatch.new
|
171
|
+
end
|
172
|
+
|
173
|
+
filter_stopwatches = {}
|
162
174
|
|
163
175
|
Nanoc::Int::NotificationCenter.on(:filtering_started) do |rep, _filter_name|
|
164
|
-
stopwatch_stack =
|
176
|
+
stopwatch_stack = filter_stopwatches.fetch(rep) { filter_stopwatches[rep] = [] }
|
165
177
|
stopwatch_stack << Nanoc::Telemetry::Stopwatch.new
|
166
178
|
stopwatch_stack.last.start
|
167
179
|
end
|
168
180
|
|
169
181
|
Nanoc::Int::NotificationCenter.on(:filtering_ended) do |rep, filter_name|
|
170
|
-
stopwatch =
|
182
|
+
stopwatch = filter_stopwatches.fetch(rep).pop
|
171
183
|
stopwatch.stop
|
172
184
|
|
173
|
-
@telemetry.summary(:
|
185
|
+
@telemetry.summary(:filters).observe(stopwatch.duration, filter_name.to_s)
|
174
186
|
end
|
175
187
|
|
176
188
|
Nanoc::Int::NotificationCenter.on(:compilation_suspended) do |rep, _exception|
|
177
|
-
|
178
|
-
stopwatch.stop if stopwatch && stopwatch.running?
|
189
|
+
filter_stopwatches.fetch(rep).each(&:stop)
|
179
190
|
end
|
180
191
|
|
181
192
|
Nanoc::Int::NotificationCenter.on(:compilation_started) do |rep|
|
182
|
-
|
183
|
-
|
193
|
+
filter_stopwatches.fetch(rep, []).each(&:start)
|
194
|
+
end
|
195
|
+
|
196
|
+
phase_stopwatches = {}
|
197
|
+
|
198
|
+
Nanoc::Int::NotificationCenter.on(:phase_started) do |phase_name, rep|
|
199
|
+
stopwatches = phase_stopwatches.fetch(rep) { phase_stopwatches[rep] = {} }
|
200
|
+
stopwatches[phase_name] = Nanoc::Telemetry::Stopwatch.new.tap(&:start)
|
201
|
+
end
|
202
|
+
|
203
|
+
Nanoc::Int::NotificationCenter.on(:phase_ended) do |phase_name, rep|
|
204
|
+
stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
|
205
|
+
stopwatch.stop
|
206
|
+
|
207
|
+
@telemetry.summary(:phases).observe(stopwatch.duration, phase_name)
|
208
|
+
end
|
209
|
+
|
210
|
+
Nanoc::Int::NotificationCenter.on(:phase_yielded) do |phase_name, rep|
|
211
|
+
stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
|
212
|
+
stopwatch.stop
|
213
|
+
end
|
214
|
+
|
215
|
+
Nanoc::Int::NotificationCenter.on(:phase_resumed) do |phase_name, rep|
|
216
|
+
stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
|
217
|
+
stopwatch.start if stopwatch.stopped?
|
218
|
+
end
|
219
|
+
|
220
|
+
Nanoc::Int::NotificationCenter.on(:phase_aborted) do |phase_name, rep|
|
221
|
+
stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
|
222
|
+
stopwatch.stop if stopwatch.running?
|
223
|
+
|
224
|
+
@telemetry.summary(:phases).observe(stopwatch.duration, phase_name)
|
184
225
|
end
|
185
226
|
end
|
186
227
|
|
@@ -192,19 +233,15 @@ module Nanoc::CLI::Commands
|
|
192
233
|
|
193
234
|
protected
|
194
235
|
|
195
|
-
def
|
196
|
-
headers = [
|
197
|
-
|
198
|
-
metric_set = @telemetry.summary(:filter_total)
|
199
|
-
rows = metric_set.labels.map do |label|
|
200
|
-
metric = metric_set.get(label)
|
201
|
-
filter_name = label[:filter_name].to_s
|
236
|
+
def table_for_summary(name)
|
237
|
+
headers = [name.to_s, 'count', 'min', 'avg', 'max', 'tot']
|
202
238
|
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
239
|
+
rows = @telemetry.summary(name).map do |filter_name, summary|
|
240
|
+
count = summary.count
|
241
|
+
min = summary.min
|
242
|
+
avg = summary.avg
|
243
|
+
tot = summary.sum
|
244
|
+
max = summary.max
|
208
245
|
|
209
246
|
[filter_name, count.to_s] + [min, avg, max, tot].map { |r| "#{format('%4.2f', r)}s" }
|
210
247
|
end
|
@@ -212,17 +249,34 @@ module Nanoc::CLI::Commands
|
|
212
249
|
[headers] + rows
|
213
250
|
end
|
214
251
|
|
215
|
-
def
|
216
|
-
|
252
|
+
def table_for_summary_durations(name)
|
253
|
+
headers = [name.to_s, 'tot']
|
217
254
|
|
218
|
-
|
219
|
-
|
220
|
-
$stderr.puts 'Warning: profiling information may not be accurate because ' \
|
221
|
-
'some items were not compiled.'
|
255
|
+
rows = @telemetry.summary(:stages).map do |stage_name, summary|
|
256
|
+
[stage_name, "#{format('%4.2f', summary.sum)}s"]
|
222
257
|
end
|
223
258
|
|
259
|
+
[headers] + rows
|
260
|
+
end
|
261
|
+
|
262
|
+
def print_profiling_feedback
|
263
|
+
print_table_for_summary(:filters)
|
264
|
+
print_table_for_summary(:phases) if Nanoc::CLI.verbosity >= 2
|
265
|
+
print_table_for_summary_duration(:stages) if Nanoc::CLI.verbosity >= 2
|
266
|
+
end
|
267
|
+
|
268
|
+
def print_table_for_summary(name)
|
269
|
+
return if @telemetry.summary(name).empty?
|
270
|
+
|
271
|
+
puts
|
272
|
+
print_table(table_for_summary(name))
|
273
|
+
end
|
274
|
+
|
275
|
+
def print_table_for_summary_duration(name)
|
276
|
+
return if @telemetry.summary(name).empty?
|
277
|
+
|
224
278
|
puts
|
225
|
-
print_table
|
279
|
+
print_table(table_for_summary_durations(name))
|
226
280
|
end
|
227
281
|
|
228
282
|
def print_table(table)
|