nanoc 4.6.3 → 4.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +5 -5
- data/NEWS.md +6 -0
- data/lib/nanoc.rb +1 -0
- data/lib/nanoc/cli/commands/compile.rb +28 -61
- data/lib/nanoc/cli/stream_cleaners/utf8.rb +1 -1
- data/lib/nanoc/spec.rb +3 -3
- data/lib/nanoc/telemetry.rb +17 -0
- data/lib/nanoc/telemetry/counter.rb +13 -0
- data/lib/nanoc/telemetry/labelled_counter.rb +27 -0
- data/lib/nanoc/telemetry/labelled_summary.rb +31 -0
- data/lib/nanoc/telemetry/registry.rb +16 -0
- data/lib/nanoc/telemetry/stopwatch.rb +41 -0
- data/lib/nanoc/telemetry/summary.rb +53 -0
- data/lib/nanoc/version.rb +1 -1
- data/spec/nanoc/cli/commands/compile/timing_recorder_spec.rb +35 -4
- data/spec/nanoc/cli/stream_cleaners/utf8_spec.rb +7 -0
- data/spec/nanoc/helpers/blogging_spec.rb +7 -6
- data/spec/nanoc/helpers/capturing_spec.rb +5 -4
- data/spec/nanoc/helpers/child_parent_spec.rb +12 -43
- data/spec/nanoc/helpers/filtering_spec.rb +5 -2
- data/spec/nanoc/helpers/link_to_spec.rb +66 -23
- data/spec/nanoc/helpers/rendering_spec.rb +3 -7
- data/spec/nanoc/spec_spec.rb +68 -0
- data/spec/nanoc/telemetry/counter_spec.rb +18 -0
- data/spec/nanoc/telemetry/labelled_counter_spec.rb +56 -0
- data/spec/nanoc/telemetry/labelled_summary_spec.rb +63 -0
- data/spec/nanoc/telemetry/stopwatch_spec.rb +59 -0
- data/spec/nanoc/telemetry/summary_spec.rb +66 -0
- data/spec/nanoc/telemetry_spec.rb +26 -0
- metadata +17 -2
@@ -0,0 +1,18 @@
|
|
1
|
+
describe Nanoc::Telemetry::Counter do
|
2
|
+
subject(:counter) { described_class.new }
|
3
|
+
|
4
|
+
it 'starts at 0' do
|
5
|
+
expect(counter.value).to eq(0)
|
6
|
+
end
|
7
|
+
|
8
|
+
describe '#increment' do
|
9
|
+
subject { counter.increment }
|
10
|
+
|
11
|
+
it 'increments' do
|
12
|
+
expect { subject }
|
13
|
+
.to change { counter.value }
|
14
|
+
.from(0)
|
15
|
+
.to(1)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
describe Nanoc::Telemetry::LabelledCounter do
|
2
|
+
subject(:counter) { described_class.new }
|
3
|
+
|
4
|
+
describe 'new counter' do
|
5
|
+
it 'starts at 0' do
|
6
|
+
expect(subject.value(filter: :erb)).to eq(0)
|
7
|
+
expect(subject.value(filter: :haml)).to eq(0)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'has no values' do
|
11
|
+
expect(subject.values).to eq({})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe '#increment' do
|
16
|
+
subject { counter.increment(filter: :erb) }
|
17
|
+
|
18
|
+
it 'increments the matching value' do
|
19
|
+
expect { subject }
|
20
|
+
.to change { counter.value(filter: :erb) }
|
21
|
+
.from(0)
|
22
|
+
.to(1)
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'does not increment any other value' do
|
26
|
+
expect(counter.value(filter: :haml)).to eq(0)
|
27
|
+
expect { subject }
|
28
|
+
.not_to change { counter.value(filter: :haml) }
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'correctly changes #values' do
|
32
|
+
expect { subject }
|
33
|
+
.to change { counter.values }
|
34
|
+
.from({})
|
35
|
+
.to({ filter: :erb } => 1)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
describe '#get' do
|
40
|
+
subject { counter.get(filter: :erb) }
|
41
|
+
|
42
|
+
context 'not incremented' do
|
43
|
+
its(:value) { is_expected.to eq(0) }
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'incremented' do
|
47
|
+
before { counter.increment(filter: :erb) }
|
48
|
+
its(:value) { is_expected.to eq(1) }
|
49
|
+
end
|
50
|
+
|
51
|
+
context 'other incremented' do
|
52
|
+
before { counter.increment(filter: :haml) }
|
53
|
+
its(:value) { is_expected.to eq(0) }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
describe Nanoc::Telemetry::LabelledSummary do
|
2
|
+
subject(:summary) { described_class.new }
|
3
|
+
|
4
|
+
describe '#labels' do
|
5
|
+
subject { summary.labels }
|
6
|
+
|
7
|
+
context 'empty summary' do
|
8
|
+
it { is_expected.to eq([]) }
|
9
|
+
end
|
10
|
+
|
11
|
+
context 'some observations' do
|
12
|
+
before do
|
13
|
+
summary.observe(7.2, filter: :erb)
|
14
|
+
summary.observe(5.3, filter: :erb)
|
15
|
+
summary.observe(3.0, filter: :haml)
|
16
|
+
end
|
17
|
+
|
18
|
+
it { is_expected.to eq([{ filter: :erb }, { filter: :haml }]) }
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
describe '#get' do
|
23
|
+
subject { summary.get(filter: :erb) }
|
24
|
+
|
25
|
+
context 'empty summary' do
|
26
|
+
its(:count) { is_expected.to eq(0) }
|
27
|
+
end
|
28
|
+
|
29
|
+
context 'one observation with that label' do
|
30
|
+
before { summary.observe(0.1, filter: :erb) }
|
31
|
+
its(:count) { is_expected.to eq(1) }
|
32
|
+
end
|
33
|
+
|
34
|
+
context 'one observation with a different label' do
|
35
|
+
before { summary.observe(0.1, filter: :haml) }
|
36
|
+
its(:count) { is_expected.to eq(0) }
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#quantile' do
|
41
|
+
before do
|
42
|
+
subject.observe(2.1, filter: :erb)
|
43
|
+
subject.observe(4.1, filter: :erb)
|
44
|
+
subject.observe(5.3, filter: :haml)
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'has proper quantiles for :erb' do
|
48
|
+
expect(subject.quantile(0.00, filter: :erb)).to be_within(0.000001).of(2.1)
|
49
|
+
expect(subject.quantile(0.25, filter: :erb)).to be_within(0.000001).of(2.6)
|
50
|
+
expect(subject.quantile(0.50, filter: :erb)).to be_within(0.000001).of(3.1)
|
51
|
+
expect(subject.quantile(0.90, filter: :erb)).to be_within(0.000001).of(3.9)
|
52
|
+
expect(subject.quantile(0.99, filter: :erb)).to be_within(0.000001).of(4.08)
|
53
|
+
end
|
54
|
+
|
55
|
+
it 'has proper quantiles for :erb' do
|
56
|
+
expect(subject.quantile(0.00, filter: :haml)).to be_within(0.000001).of(5.3)
|
57
|
+
expect(subject.quantile(0.25, filter: :haml)).to be_within(0.000001).of(5.3)
|
58
|
+
expect(subject.quantile(0.50, filter: :haml)).to be_within(0.000001).of(5.3)
|
59
|
+
expect(subject.quantile(0.90, filter: :haml)).to be_within(0.000001).of(5.3)
|
60
|
+
expect(subject.quantile(0.99, filter: :haml)).to be_within(0.000001).of(5.3)
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
describe Nanoc::Telemetry::Stopwatch do
|
2
|
+
subject(:stopwatch) { described_class.new }
|
3
|
+
|
4
|
+
it 'is zero by default' do
|
5
|
+
expect(stopwatch.duration).to eq(0.0)
|
6
|
+
end
|
7
|
+
|
8
|
+
# TODO: if running, raise error when asking for #duration
|
9
|
+
|
10
|
+
it 'records correct duration after start+stop' do
|
11
|
+
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 0))
|
12
|
+
stopwatch.start
|
13
|
+
|
14
|
+
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 1))
|
15
|
+
stopwatch.stop
|
16
|
+
|
17
|
+
expect(stopwatch.duration).to eq(1.0)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'records correct duration after start+stop+start+stop' do
|
21
|
+
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 0))
|
22
|
+
stopwatch.start
|
23
|
+
|
24
|
+
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 1))
|
25
|
+
stopwatch.stop
|
26
|
+
|
27
|
+
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 3))
|
28
|
+
stopwatch.start
|
29
|
+
|
30
|
+
Timecop.freeze(Time.local(2008, 9, 1, 10, 5, 6))
|
31
|
+
stopwatch.stop
|
32
|
+
|
33
|
+
expect(stopwatch.duration).to eq(1.0 + 3.0)
|
34
|
+
end
|
35
|
+
|
36
|
+
it 'errors when stopping when not started' do
|
37
|
+
expect { stopwatch.stop }.to raise_error(Nanoc::Telemetry::Stopwatch::NotRunningError)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'errors when starting when already started' do
|
41
|
+
stopwatch.start
|
42
|
+
expect { stopwatch.start }.to raise_error(Nanoc::Telemetry::Stopwatch::AlreadyRunningError)
|
43
|
+
end
|
44
|
+
|
45
|
+
it 'reports running status' do
|
46
|
+
expect(stopwatch).not_to be_running
|
47
|
+
expect(stopwatch).to be_stopped
|
48
|
+
|
49
|
+
stopwatch.start
|
50
|
+
|
51
|
+
expect(stopwatch).to be_running
|
52
|
+
expect(stopwatch).not_to be_stopped
|
53
|
+
|
54
|
+
stopwatch.stop
|
55
|
+
|
56
|
+
expect(stopwatch).not_to be_running
|
57
|
+
expect(stopwatch).to be_stopped
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
describe Nanoc::Telemetry::Summary do
|
2
|
+
subject(:summary) { described_class.new }
|
3
|
+
|
4
|
+
context 'no observations' do
|
5
|
+
it 'errors on #min' do
|
6
|
+
expect { subject.min }
|
7
|
+
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'errors on #max' do
|
11
|
+
expect { subject.max }
|
12
|
+
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
13
|
+
end
|
14
|
+
|
15
|
+
it 'errors on #avg' do
|
16
|
+
expect { subject.avg }
|
17
|
+
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
18
|
+
end
|
19
|
+
|
20
|
+
it 'errors on #sum' do
|
21
|
+
expect { subject.sum }
|
22
|
+
.to raise_error(Nanoc::Telemetry::Summary::EmptySummaryError)
|
23
|
+
end
|
24
|
+
|
25
|
+
its(:count) { is_expected.to eq(0) }
|
26
|
+
end
|
27
|
+
|
28
|
+
context 'one observation' do
|
29
|
+
before { subject.observe(2.1) }
|
30
|
+
|
31
|
+
its(:count) { is_expected.to eq(1) }
|
32
|
+
its(:sum) { is_expected.to eq(2.1) }
|
33
|
+
its(:avg) { is_expected.to eq(2.1) }
|
34
|
+
its(:min) { is_expected.to eq(2.1) }
|
35
|
+
its(:max) { is_expected.to eq(2.1) }
|
36
|
+
|
37
|
+
it 'has proper quantiles' do
|
38
|
+
expect(subject.quantile(0.00)).to eq(2.1)
|
39
|
+
expect(subject.quantile(0.25)).to eq(2.1)
|
40
|
+
expect(subject.quantile(0.50)).to eq(2.1)
|
41
|
+
expect(subject.quantile(0.90)).to eq(2.1)
|
42
|
+
expect(subject.quantile(0.99)).to eq(2.1)
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
context 'two observations' do
|
47
|
+
before do
|
48
|
+
subject.observe(2.1)
|
49
|
+
subject.observe(4.1)
|
50
|
+
end
|
51
|
+
|
52
|
+
its(:count) { is_expected.to be_within(0.000001).of(2) }
|
53
|
+
its(:sum) { is_expected.to be_within(0.000001).of(6.2) }
|
54
|
+
its(:avg) { is_expected.to be_within(0.000001).of(3.1) }
|
55
|
+
its(:min) { is_expected.to be_within(0.000001).of(2.1) }
|
56
|
+
its(:max) { is_expected.to be_within(0.000001).of(4.1) }
|
57
|
+
|
58
|
+
it 'has proper quantiles' do
|
59
|
+
expect(subject.quantile(0.00)).to be_within(0.000001).of(2.1)
|
60
|
+
expect(subject.quantile(0.25)).to be_within(0.000001).of(2.6)
|
61
|
+
expect(subject.quantile(0.50)).to be_within(0.000001).of(3.1)
|
62
|
+
expect(subject.quantile(0.90)).to be_within(0.000001).of(3.9)
|
63
|
+
expect(subject.quantile(0.99)).to be_within(0.000001).of(4.08)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
describe Nanoc::Telemetry do
|
2
|
+
subject { described_class.new }
|
3
|
+
|
4
|
+
example do
|
5
|
+
expect(subject.counter(:filters).values).to eq({})
|
6
|
+
expect(subject.counter(:filters).get(identifier: :erb).value).to eq(0)
|
7
|
+
expect(subject.counter(:filters).value(identifier: :erb)).to eq(0)
|
8
|
+
|
9
|
+
subject.counter(:filters).increment(identifier: :erb)
|
10
|
+
expect(subject.counter(:filters).values).to eq({ identifier: :erb } => 1)
|
11
|
+
expect(subject.counter(:filters).get(identifier: :erb).value).to eq(1)
|
12
|
+
expect(subject.counter(:filters).value(identifier: :erb)).to eq(1)
|
13
|
+
end
|
14
|
+
|
15
|
+
example do
|
16
|
+
subject.summary(:filters).observe(0.1, identifier: :erb)
|
17
|
+
expect(subject.summary(:filters).quantile(0.0, identifier: :erb)).to be_within(0.00001).of(0.1)
|
18
|
+
expect(subject.summary(:filters).quantile(0.5, identifier: :erb)).to be_within(0.00001).of(0.1)
|
19
|
+
expect(subject.summary(:filters).quantile(1.0, identifier: :erb)).to be_within(0.00001).of(0.1)
|
20
|
+
|
21
|
+
subject.summary(:filters).observe(1.1, identifier: :erb)
|
22
|
+
expect(subject.summary(:filters).quantile(0.0, identifier: :erb)).to be_within(0.00001).of(0.1)
|
23
|
+
expect(subject.summary(:filters).quantile(0.5, identifier: :erb)).to be_within(0.00001).of(0.6)
|
24
|
+
expect(subject.summary(:filters).quantile(1.0, identifier: :erb)).to be_within(0.00001).of(1.1)
|
25
|
+
end
|
26
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nanoc
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.6.
|
4
|
+
version: 4.6.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Denis Defreyne
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-03-
|
11
|
+
date: 2017-03-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cri
|
@@ -334,6 +334,13 @@ files:
|
|
334
334
|
- lib/nanoc/rule_dsl/rules_collection.rb
|
335
335
|
- lib/nanoc/rule_dsl/rules_loader.rb
|
336
336
|
- lib/nanoc/spec.rb
|
337
|
+
- lib/nanoc/telemetry.rb
|
338
|
+
- lib/nanoc/telemetry/counter.rb
|
339
|
+
- lib/nanoc/telemetry/labelled_counter.rb
|
340
|
+
- lib/nanoc/telemetry/labelled_summary.rb
|
341
|
+
- lib/nanoc/telemetry/registry.rb
|
342
|
+
- lib/nanoc/telemetry/stopwatch.rb
|
343
|
+
- lib/nanoc/telemetry/summary.rb
|
337
344
|
- lib/nanoc/version.rb
|
338
345
|
- nanoc.gemspec
|
339
346
|
- spec/contributors_spec.rb
|
@@ -408,6 +415,7 @@ files:
|
|
408
415
|
- spec/nanoc/cli/commands/show_plugins_spec.rb
|
409
416
|
- spec/nanoc/cli/commands/show_rules_spec.rb
|
410
417
|
- spec/nanoc/cli/commands/view_spec.rb
|
418
|
+
- spec/nanoc/cli/stream_cleaners/utf8_spec.rb
|
411
419
|
- spec/nanoc/data_sources/filesystem_spec.rb
|
412
420
|
- spec/nanoc/deploying/fog_spec.rb
|
413
421
|
- spec/nanoc/deploying/git_spec.rb
|
@@ -481,6 +489,13 @@ files:
|
|
481
489
|
- spec/nanoc/rule_dsl/rule_context_spec.rb
|
482
490
|
- spec/nanoc/rule_dsl/rule_memory_calculator_spec.rb
|
483
491
|
- spec/nanoc/rule_dsl/rules_collection_spec.rb
|
492
|
+
- spec/nanoc/spec_spec.rb
|
493
|
+
- spec/nanoc/telemetry/counter_spec.rb
|
494
|
+
- spec/nanoc/telemetry/labelled_counter_spec.rb
|
495
|
+
- spec/nanoc/telemetry/labelled_summary_spec.rb
|
496
|
+
- spec/nanoc/telemetry/stopwatch_spec.rb
|
497
|
+
- spec/nanoc/telemetry/summary_spec.rb
|
498
|
+
- spec/nanoc/telemetry_spec.rb
|
484
499
|
- spec/regression_filenames_spec.rb
|
485
500
|
- spec/spec_helper.rb
|
486
501
|
- test/base/core_ext/array_spec.rb
|