nanoc 4.8.17 → 4.8.18

Sign up to get free protection for your applications and to get access to all the features.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +11 -0
  3. data/lib/nanoc.rb +3 -2
  4. data/lib/nanoc/base/entities/action_sequence.rb +1 -1
  5. data/lib/nanoc/base/entities/configuration.rb +1 -1
  6. data/lib/nanoc/base/entities/identifiable_collection.rb +1 -1
  7. data/lib/nanoc/base/services.rb +1 -0
  8. data/lib/nanoc/base/services/compiler.rb +12 -19
  9. data/lib/nanoc/base/services/compiler/stage.rb +13 -0
  10. data/lib/nanoc/base/services/compiler/stages.rb +2 -0
  11. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +1 -1
  12. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +1 -1
  13. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +1 -1
  14. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +1 -1
  15. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +1 -1
  16. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +1 -1
  17. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +13 -6
  18. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +1 -1
  19. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +1 -1
  20. data/lib/nanoc/base/services/compiler/stages/prune.rb +1 -1
  21. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +1 -1
  22. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +1 -1
  23. data/lib/nanoc/base/services/instrumentor.rb +15 -0
  24. data/lib/nanoc/base/services/outdatedness_checker.rb +2 -2
  25. data/lib/nanoc/base/services/outdatedness_rule.rb +3 -4
  26. data/lib/nanoc/base/services/outdatedness_rules/code_snippets_modified.rb +1 -1
  27. data/lib/nanoc/base/views/identifiable_collection_view.rb +8 -1
  28. data/lib/nanoc/cli/command_runner.rb +0 -1
  29. data/lib/nanoc/cli/commands/compile_listeners/timing_recorder.rb +45 -54
  30. data/lib/nanoc/cli/error_handler.rb +8 -0
  31. data/lib/nanoc/filters/colorize_syntax.rb +1 -1
  32. data/lib/nanoc/helpers/breadcrumbs.rb +30 -1
  33. data/lib/nanoc/rule_dsl/action_sequence_calculator.rb +1 -1
  34. data/lib/nanoc/spec.rb +13 -0
  35. data/lib/nanoc/version.rb +1 -1
  36. metadata +9 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 2b0135cd287173e9725acef9bb921109f8158d9e6453bd8e7ae194e23cdd25ef
4
- data.tar.gz: 115b6b3baf84924b26cacac37925023f0aacbb9530721bd093386a74102fbd10
3
+ metadata.gz: 42c6429f3ab75c70a0616b03c8658442b860f3238e626e3b7a41e21b93558bc6
4
+ data.tar.gz: 329c3e49d8813363facc58726517a330821866d2ef6dac20279aa61800c0c617
5
5
  SHA512:
6
- metadata.gz: c8aa8b0d5005dfbaa7664d08baaeee74bc7e5fb15cd2873d18bb0d4847c4c76203539852a258c4ad7c5187cb6503db1396e0a43752926f51fe89ea66b04dce12
7
- data.tar.gz: 19fd6556430be0ffda0d733f0e8546a0ac646e7deb8da0e62df17c9caae4e99c166f4cc6bf8aadfc39376d5a1df44f53c542f104fefbf404686b840b4d18ced0
6
+ metadata.gz: 3caf2cc5572e4ccc9615ab06487391f6d691e4dbe9bb08d600f20f2f20284c827a7ce1fd6325e7ed5cd785d16d19b6e77380a2134fa505dd27f11c91defb780b
7
+ data.tar.gz: 71c7a650d30c2d29ba5a38b8fc2eee74596102506dbc44956a733f914d1c7b58b87bdd0ac5603788eae03758b3ef8ebae6c65c3102b3743e68e17354846b0f0d
data/NEWS.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.8.18 (2017-12-28)
4
+
5
+ Enhancements:
6
+
7
+ * Added `.tex` to the default list of text extensions (#1280) [Rien Maertens]
8
+
9
+ Fixes:
10
+
11
+ * Made `#breadcrumbs_trail` smarter about picking the right parent when there is ambiguity (#1278, #1279)
12
+ * Made `#find_all` be callable with block instead of an argument (like `Enumerable#find_all`) (#1284, #1285)
13
+
3
14
  ## 4.8.17 (2017-12-16)
4
15
 
5
16
  Enhancements:
data/lib/nanoc.rb CHANGED
@@ -9,6 +9,8 @@ require 'slow_enumerator_tools'
9
9
  require 'ddmemoize'
10
10
  require 'ddtelemetry'
11
11
 
12
+ DDMemoize.enable_telemetry
13
+
12
14
  module Nanoc
13
15
  # @return [String] A string containing information about this Nanoc version
14
16
  # and its environment (Ruby engine and version, Rubygems version if any).
@@ -25,8 +27,6 @@ module Nanoc
25
27
  def self.on_windows?
26
28
  RUBY_PLATFORM =~ /windows|bccwin|cygwin|djgpp|mingw|mswin|wince/i
27
29
  end
28
-
29
- MEMOIZATION_TELEMETRY = DDTelemetry.new
30
30
  end
31
31
 
32
32
  # Load general requirements
@@ -44,6 +44,7 @@ require 'pathname'
44
44
  require 'pstore'
45
45
  require 'set'
46
46
  require 'singleton'
47
+ require 'stringio'
47
48
  require 'tempfile'
48
49
  require 'time'
49
50
  require 'timeout'
@@ -4,7 +4,7 @@ module Nanoc::Int
4
4
  class ActionSequence
5
5
  include Nanoc::Int::ContractsSupport
6
6
  include Enumerable
7
- DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)
7
+ DDMemoize.activate(self)
8
8
 
9
9
  attr_reader :item_rep
10
10
  attr_reader :actions
@@ -24,7 +24,7 @@ module Nanoc::Int
24
24
  # that lacks some options, the default value will be taken from
25
25
  # `DEFAULT_CONFIG`.
26
26
  DEFAULT_CONFIG = {
27
- text_extensions: %w[adoc asciidoc atom css erb haml htm html js less markdown md php rb sass scss txt xhtml xml coffee hb handlebars mustache ms slim rdoc].sort,
27
+ text_extensions: %w[adoc asciidoc atom css erb haml htm html js less markdown md php rb sass scss tex txt xhtml xml coffee hb handlebars mustache ms slim rdoc].sort,
28
28
  lib_dirs: %w[lib],
29
29
  commands_dirs: %w[commands],
30
30
  output_dir: 'output',
@@ -3,7 +3,7 @@
3
3
  module Nanoc::Int
4
4
  # @api private
5
5
  class IdentifiableCollection
6
- DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)
6
+ DDMemoize.activate(self)
7
7
 
8
8
  include Nanoc::Int::ContractsSupport
9
9
  include Enumerable
@@ -9,6 +9,7 @@ require_relative 'services/compiler_loader'
9
9
  require_relative 'services/dependency_tracker'
10
10
  require_relative 'services/executor'
11
11
  require_relative 'services/filter'
12
+ require_relative 'services/instrumentor'
12
13
  require_relative 'services/item_rep_builder'
13
14
  require_relative 'services/item_rep_router'
14
15
  require_relative 'services/item_rep_selector'
@@ -27,7 +27,7 @@ module Nanoc::Int
27
27
 
28
28
  def run_until_preprocessed
29
29
  @_res_preprocessed ||= begin
30
- run_stage(preprocess_stage)
30
+ preprocess_stage.call
31
31
  {}
32
32
  end
33
33
  end
@@ -36,7 +36,7 @@ module Nanoc::Int
36
36
  @_res_reps_built ||= begin
37
37
  prev = run_until_preprocessed
38
38
 
39
- res = run_stage(build_reps_stage)
39
+ res = build_reps_stage.call
40
40
 
41
41
  prev.merge(
42
42
  reps: res.fetch(:reps),
@@ -51,14 +51,14 @@ module Nanoc::Int
51
51
  action_sequences = prev.fetch(:action_sequences)
52
52
  reps = prev.fetch(:reps)
53
53
 
54
- run_stage(load_stores_stage)
55
- checksums = run_stage(calculate_checksums_stage)
54
+ load_stores_stage.call
55
+ checksums = calculate_checksums_stage.call
56
56
  outdatedness_checker = create_outdatedness_checker(
57
57
  checksums: checksums,
58
58
  action_sequences: action_sequences,
59
59
  reps: reps,
60
60
  )
61
- outdated_items = run_stage(determine_outdatedness_stage(outdatedness_checker, reps))
61
+ outdated_items = determine_outdatedness_stage(outdatedness_checker, reps).call
62
62
 
63
63
  prev.merge(
64
64
  checksums: checksums,
@@ -76,14 +76,14 @@ module Nanoc::Int
76
76
  checksums = res.fetch(:checksums)
77
77
  outdated_items = res.fetch(:outdated_items)
78
78
 
79
- run_stage(forget_outdated_dependencies_stage, outdated_items)
80
- run_stage(store_pre_compilation_state_stage(action_sequences, reps), checksums)
81
- run_stage(prune_stage(reps))
82
- run_stage(compile_reps_stage(action_sequences, reps))
83
- run_stage(store_post_compilation_state_stage)
84
- run_stage(postprocess_stage, self)
79
+ forget_outdated_dependencies_stage.call(outdated_items)
80
+ store_pre_compilation_state_stage(action_sequences, reps).call(checksums)
81
+ prune_stage(reps).call
82
+ compile_reps_stage(action_sequences, reps).call
83
+ store_post_compilation_state_stage.call
84
+ postprocess_stage.call(self)
85
85
  ensure
86
- run_stage(cleanup_stage)
86
+ cleanup_stage.call
87
87
  end
88
88
 
89
89
  def compilation_context(reps:)
@@ -98,13 +98,6 @@ module Nanoc::Int
98
98
 
99
99
  private
100
100
 
101
- def run_stage(stage, *args)
102
- Nanoc::Int::NotificationCenter.post(:stage_started, stage.class)
103
- stage.run(*args)
104
- ensure
105
- Nanoc::Int::NotificationCenter.post(:stage_ended, stage.class)
106
- end
107
-
108
101
  def create_outdatedness_checker(checksums:, action_sequences:, reps:)
109
102
  Nanoc::Int::OutdatednessChecker.new(
110
103
  site: @site,
@@ -0,0 +1,13 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Nanoc::Int::Compiler::Stage
4
+ def call(*args)
5
+ Nanoc::Int::Instrumentor.call(:stage_ran, self.class) do
6
+ run(*args)
7
+ end
8
+ end
9
+
10
+ def run(*)
11
+ raise NotImplementedError
12
+ end
13
+ end
@@ -3,6 +3,8 @@
3
3
  module Nanoc::Int::Compiler::Stages
4
4
  end
5
5
 
6
+ require_relative 'stage'
7
+
6
8
  require_relative 'stages/calculate_checksums'
7
9
  require_relative 'stages/cleanup'
8
10
  require_relative 'stages/compile_reps'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class BuildReps
4
+ class BuildReps < Nanoc::Int::Compiler::Stage
5
5
  def initialize(site:, action_provider:)
6
6
  @site = site
7
7
  @action_provider = action_provider
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class CalculateChecksums
4
+ class CalculateChecksums < Nanoc::Int::Compiler::Stage
5
5
  def initialize(items:, layouts:, code_snippets:, config:)
6
6
  @items = items
7
7
  @layouts = layouts
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class Cleanup
4
+ class Cleanup < Nanoc::Int::Compiler::Stage
5
5
  def initialize(output_dirs)
6
6
  @output_dirs = output_dirs
7
7
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class CompileReps
4
+ class CompileReps < Nanoc::Int::Compiler::Stage
5
5
  def initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:)
6
6
  @reps = reps
7
7
  @outdatedness_store = outdatedness_store
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class DetermineOutdatedness
4
+ class DetermineOutdatedness < Nanoc::Int::Compiler::Stage
5
5
  include Nanoc::Int::ContractsSupport
6
6
 
7
7
  def initialize(reps:, outdatedness_checker:, outdatedness_store:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class ForgetOutdatedDependencies
4
+ class ForgetOutdatedDependencies < Nanoc::Int::Compiler::Stage
5
5
  include Nanoc::Int::ContractsSupport
6
6
 
7
7
  def initialize(dependency_store:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class LoadStores
4
+ class LoadStores < Nanoc::Int::Compiler::Stage
5
5
  include Nanoc::Int::ContractsSupport
6
6
 
7
7
  def initialize(checksum_store:, compiled_content_cache:, dependency_store:, action_sequence_store:, outdatedness_store:)
@@ -14,11 +14,18 @@ module Nanoc::Int::Compiler::Stages
14
14
 
15
15
  contract C::None => C::Any
16
16
  def run
17
- @checksum_store.load
18
- @compiled_content_cache.load
19
- @dependency_store.load
20
- @action_sequence_store.load
21
- @outdatedness_store.load
17
+ load_store(@checksum_store)
18
+ load_store(@compiled_content_cache)
19
+ load_store(@dependency_store)
20
+ load_store(@action_sequence_store)
21
+ load_store(@outdatedness_store)
22
+ end
23
+
24
+ contract Nanoc::Int::Store => C::Any
25
+ def load_store(store)
26
+ Nanoc::Int::Instrumentor.call(:store_loaded, store.class) do
27
+ store.load
28
+ end
22
29
  end
23
30
  end
24
31
  end
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class Postprocess
4
+ class Postprocess < Nanoc::Int::Compiler::Stage
5
5
  include Nanoc::Int::ContractsSupport
6
6
 
7
7
  def initialize(action_provider:, site:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class Preprocess
4
+ class Preprocess < Nanoc::Int::Compiler::Stage
5
5
  def initialize(action_provider:, site:, dependency_store:, checksum_store:)
6
6
  @action_provider = action_provider
7
7
  @site = site
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class Prune
4
+ class Prune < Nanoc::Int::Compiler::Stage
5
5
  def initialize(config:, reps:)
6
6
  @config = config
7
7
  @reps = reps
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class StorePostCompilationState
4
+ class StorePostCompilationState < Nanoc::Int::Compiler::Stage
5
5
  include Nanoc::Int::ContractsSupport
6
6
 
7
7
  def initialize(dependency_store:)
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Nanoc::Int::Compiler::Stages
4
- class StorePreCompilationState
4
+ class StorePreCompilationState < Nanoc::Int::Compiler::Stage
5
5
  include Nanoc::Int::ContractsSupport
6
6
 
7
7
  def initialize(reps:, layouts:, checksum_store:, action_sequence_store:, action_sequences:)
@@ -0,0 +1,15 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc::Int
4
+ # @api private
5
+ class Instrumentor
6
+ def self.call(key, *args)
7
+ stopwatch = DDTelemetry::Stopwatch.new
8
+ stopwatch.start
9
+ yield
10
+ ensure
11
+ stopwatch.stop
12
+ Nanoc::Int::NotificationCenter.post(key, stopwatch.duration, *args)
13
+ end
14
+ end
15
+ end
@@ -6,7 +6,7 @@ module Nanoc::Int
6
6
  # @api private
7
7
  class OutdatednessChecker
8
8
  class Basic
9
- DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)
9
+ DDMemoize.activate(self)
10
10
 
11
11
  include Nanoc::Int::ContractsSupport
12
12
 
@@ -97,7 +97,7 @@ module Nanoc::Int
97
97
  end
98
98
  end
99
99
 
100
- DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)
100
+ DDMemoize.activate(self)
101
101
 
102
102
  include Nanoc::Int::ContractsSupport
103
103
 
@@ -7,10 +7,9 @@ module Nanoc::Int
7
7
  include Singleton
8
8
 
9
9
  def call(obj, outdatedness_checker)
10
- Nanoc::Int::NotificationCenter.post(:outdatedness_rule_started, self.class, obj)
11
- apply(obj, outdatedness_checker)
12
- ensure
13
- Nanoc::Int::NotificationCenter.post(:outdatedness_rule_ended, self.class, obj)
10
+ Nanoc::Int::Instrumentor.call(:outdatedness_rule_ran, self.class) do
11
+ apply(obj, outdatedness_checker)
12
+ end
14
13
  end
15
14
 
16
15
  def apply(_obj, _outdatedness_checker)
@@ -2,7 +2,7 @@
2
2
 
3
3
  module Nanoc::Int::OutdatednessRules
4
4
  class CodeSnippetsModified < Nanoc::Int::OutdatednessRule
5
- DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)
5
+ DDMemoize.activate(self)
6
6
 
7
7
  include Nanoc::Int::ContractsSupport
8
8
 
@@ -4,6 +4,8 @@ module Nanoc
4
4
  class IdentifiableCollectionView < ::Nanoc::View
5
5
  include Enumerable
6
6
 
7
+ NOTHING = Object.new
8
+
7
9
  # @api private
8
10
  def initialize(objects, context)
9
11
  super(context)
@@ -46,7 +48,12 @@ module Nanoc
46
48
  # @param [String, Regex] arg
47
49
  #
48
50
  # @return [Enumerable]
49
- def find_all(arg)
51
+ def find_all(arg = NOTHING, &block)
52
+ if NOTHING.equal?(arg)
53
+ @context.dependency_tracker.bounce(unwrap, raw_content: true)
54
+ return @objects.select(&block).map { |i| view_class.new(i, @context) }
55
+ end
56
+
50
57
  prop_attribute =
51
58
  case arg
52
59
  when String, Nanoc::Identifier
@@ -20,7 +20,6 @@ module Nanoc::CLI
20
20
  def in_site_dir?
21
21
  Nanoc::Int::SiteLoader.cwd_is_nanoc_site?
22
22
  end
23
- alias is_in_site_dir? in_site_dir?
24
23
 
25
24
  def self.find_site_dir
26
25
  start_here = Dir.pwd
@@ -2,7 +2,10 @@
2
2
 
3
3
  module Nanoc::CLI::Commands::CompileListeners
4
4
  class TimingRecorder < Abstract
5
- attr_reader :telemetry
5
+ attr_reader :stages_summary
6
+ attr_reader :phases_summary
7
+ attr_reader :outdatedness_rules_summary
8
+ attr_reader :filters_summary
6
9
 
7
10
  # @see Listener#enable_for?
8
11
  def self.enable_for?(_command_runner, _site)
@@ -12,39 +15,22 @@ module Nanoc::CLI::Commands::CompileListeners
12
15
  # @param [Enumerable<Nanoc::Int::ItemRep>] reps
13
16
  def initialize(reps:)
14
17
  @reps = reps
15
- @telemetry = DDTelemetry.new
18
+
19
+ @stages_summary = DDTelemetry::Summary.new
20
+ @phases_summary = DDTelemetry::Summary.new
21
+ @outdatedness_rules_summary = DDTelemetry::Summary.new
22
+ @filters_summary = DDTelemetry::Summary.new
23
+ @load_stores_summary = DDTelemetry::Summary.new
16
24
  end
17
25
 
18
26
  # @see Listener#start
19
27
  def start
20
- stage_stopwatch = DDTelemetry::Stopwatch.new
21
-
22
- on(:stage_started) do |_klass|
23
- stage_stopwatch.start
24
- end
25
-
26
- on(:stage_ended) do |klass|
27
- stage_stopwatch.stop
28
- name = klass.to_s.sub(/.*::/, '')
29
- @telemetry.summary(:stages).observe(stage_stopwatch.duration, name)
30
- stage_stopwatch = DDTelemetry::Stopwatch.new
28
+ on(:stage_ran) do |duration, klass|
29
+ @stages_summary.observe(duration, klass.to_s.sub(/.*::/, ''))
31
30
  end
32
31
 
33
- outdatedness_rule_stopwatches = {}
34
-
35
- on(:outdatedness_rule_started) do |klass, obj|
36
- stopwatches = outdatedness_rule_stopwatches.fetch(klass) { outdatedness_rule_stopwatches[klass] = {} }
37
- stopwatch = stopwatches.fetch(obj) { stopwatches[obj] = DDTelemetry::Stopwatch.new }
38
- stopwatch.start
39
- end
40
-
41
- on(:outdatedness_rule_ended) do |klass, obj|
42
- stopwatches = outdatedness_rule_stopwatches.fetch(klass)
43
- stopwatch = stopwatches.fetch(obj)
44
- stopwatch.stop
45
-
46
- name = klass.to_s.sub(/.*::/, '')
47
- @telemetry.summary(:outdatedness_rules).observe(stopwatch.duration, name)
32
+ on(:outdatedness_rule_ran) do |duration, klass|
33
+ @outdatedness_rules_summary.observe(duration, klass.to_s.sub(/.*::/, ''))
48
34
  end
49
35
 
50
36
  filter_stopwatches = {}
@@ -59,7 +45,11 @@ module Nanoc::CLI::Commands::CompileListeners
59
45
  stopwatch = filter_stopwatches.fetch(rep).pop
60
46
  stopwatch.stop
61
47
 
62
- @telemetry.summary(:filters).observe(stopwatch.duration, filter_name.to_s)
48
+ @filters_summary.observe(stopwatch.duration, filter_name.to_s)
49
+ end
50
+
51
+ on(:store_loaded) do |duration, klass|
52
+ @load_stores_summary.observe(duration, klass.to_s)
63
53
  end
64
54
 
65
55
  on(:compilation_suspended) do |rep, _exception|
@@ -81,7 +71,7 @@ module Nanoc::CLI::Commands::CompileListeners
81
71
  stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
82
72
  stopwatch.stop
83
73
 
84
- @telemetry.summary(:phases).observe(stopwatch.duration, phase_name)
74
+ @phases_summary.observe(stopwatch.duration, phase_name)
85
75
  end
86
76
 
87
77
  on(:phase_yielded) do |phase_name, rep|
@@ -98,7 +88,7 @@ module Nanoc::CLI::Commands::CompileListeners
98
88
  stopwatch = phase_stopwatches.fetch(rep).fetch(phase_name)
99
89
  stopwatch.stop if stopwatch.running?
100
90
 
101
- @telemetry.summary(:phases).observe(stopwatch.duration, phase_name)
91
+ @phases_summary.observe(stopwatch.duration, phase_name)
102
92
  end
103
93
  end
104
94
 
@@ -110,17 +100,17 @@ module Nanoc::CLI::Commands::CompileListeners
110
100
 
111
101
  protected
112
102
 
113
- def table_for_summary(name)
103
+ def table_for_summary(name, summary)
114
104
  headers = [name.to_s, 'count', 'min', '.50', '.90', '.95', 'max', 'tot']
115
105
 
116
- rows = @telemetry.summary(name).map do |filter_name, summary|
117
- count = summary.count
118
- min = summary.min
119
- p50 = summary.quantile(0.50)
120
- p90 = summary.quantile(0.90)
121
- p95 = summary.quantile(0.95)
122
- tot = summary.sum
123
- max = summary.max
106
+ rows = summary.map do |filter_name, stats|
107
+ count = stats.count
108
+ min = stats.min
109
+ p50 = stats.quantile(0.50)
110
+ p90 = stats.quantile(0.90)
111
+ p95 = stats.quantile(0.95)
112
+ tot = stats.sum
113
+ max = stats.max
124
114
 
125
115
  [filter_name, count.to_s] + [min, p50, p90, p95, max, tot].map { |r| "#{format('%4.2f', r)}s" }
126
116
  end
@@ -128,36 +118,37 @@ module Nanoc::CLI::Commands::CompileListeners
128
118
  [headers] + rows
129
119
  end
130
120
 
131
- def table_for_summary_durations(name)
121
+ def table_for_summary_durations(name, summary)
132
122
  headers = [name.to_s, 'tot']
133
123
 
134
- rows = @telemetry.summary(:stages).map do |stage_name, summary|
135
- [stage_name, "#{format('%4.2f', summary.sum)}s"]
124
+ rows = summary.map do |stage_name, stats|
125
+ [stage_name, "#{format('%4.2f', stats.sum)}s"]
136
126
  end
137
127
 
138
128
  [headers] + rows
139
129
  end
140
130
 
141
131
  def print_profiling_feedback
142
- print_table_for_summary(:filters)
143
- print_table_for_summary(:phases) if Nanoc::CLI.verbosity >= 2
144
- print_table_for_summary_duration(:stages) if Nanoc::CLI.verbosity >= 2
145
- print_table_for_summary(:outdatedness_rules) if Nanoc::CLI.verbosity >= 2
146
- DDMemoize.print_telemetry(Nanoc::MEMOIZATION_TELEMETRY) if Nanoc::CLI.verbosity >= 2
132
+ print_table_for_summary(:filters, @filters_summary)
133
+ print_table_for_summary(:phases, @phases_summary) if Nanoc::CLI.verbosity >= 2
134
+ print_table_for_summary_duration(:stages, @stages_summary) if Nanoc::CLI.verbosity >= 2
135
+ print_table_for_summary(:outdatedness_rules, @outdatedness_rules_summary) if Nanoc::CLI.verbosity >= 2
136
+ print_table_for_summary_duration(:load_stores, @load_stores_summary) if Nanoc::CLI.verbosity >= 2
137
+ DDMemoize.print_telemetry if Nanoc::CLI.verbosity >= 2
147
138
  end
148
139
 
149
- def print_table_for_summary(name)
150
- return if @telemetry.summary(name).empty?
140
+ def print_table_for_summary(name, summary)
141
+ return unless summary.any?
151
142
 
152
143
  puts
153
- print_table(table_for_summary(name))
144
+ print_table(table_for_summary(name, summary))
154
145
  end
155
146
 
156
- def print_table_for_summary_duration(name)
157
- return if @telemetry.summary(name).empty?
147
+ def print_table_for_summary_duration(name, summary)
148
+ return unless summary.any?
158
149
 
159
150
  puts
160
- print_table(table_for_summary_durations(name))
151
+ print_table(table_for_summary_durations(name, summary))
161
152
  end
162
153
 
163
154
  def print_table(rows)
@@ -184,9 +184,11 @@ module Nanoc::CLI
184
184
  # `#require` fails, the gem name is looked up in this hash.
185
185
  GEM_NAMES = {
186
186
  'adsf' => 'adsf',
187
+ 'asciidoctor' => 'asciidoctor',
187
188
  'bluecloth' => 'bluecloth',
188
189
  'builder' => 'builder',
189
190
  'coderay' => 'coderay',
191
+ 'coffee-script' => 'coffee-script',
190
192
  'cri' => 'cri',
191
193
  'erubi' => 'erubi',
192
194
  'erubis' => 'erubis',
@@ -201,9 +203,11 @@ module Nanoc::CLI
201
203
  'markaby' => 'markaby',
202
204
  'maruku' => 'maruku',
203
205
  'mime/types' => 'mime-types',
206
+ 'mustache' => 'mustache',
204
207
  'nanoc/live' => 'nanoc-live',
205
208
  'nokogiri' => 'nokogiri',
206
209
  'nokogumbo' => 'nokogumbo',
210
+ 'pandoc-ruby' => 'pandoc-ruby',
207
211
  'pry' => 'pry',
208
212
  'rack' => 'rack',
209
213
  'rack/cache' => 'rack-cache',
@@ -213,7 +217,11 @@ module Nanoc::CLI
213
217
  'redcloth' => 'RedCloth',
214
218
  'rubypants' => 'rubypants',
215
219
  'sass' => 'sass',
220
+ 'slim' => 'slim',
221
+ 'typogruby' => 'typogruby',
222
+ 'uglifier' => 'uglifier',
216
223
  'w3c_validators' => 'w3c_validators',
224
+ 'yuicompressor' => 'yuicompressor',
217
225
  }.freeze
218
226
 
219
227
  # Attempts to find a resolution for the given error, or nil if no
@@ -5,7 +5,7 @@ module Nanoc::Filters
5
5
  class ColorizeSyntax < Nanoc::Filter
6
6
  identifier :colorize_syntax
7
7
 
8
- requires 'nokogiri', 'stringio', 'open3'
8
+ requires 'nokogiri'
9
9
 
10
10
  DEFAULT_COLORIZER = :coderay
11
11
 
@@ -3,6 +3,34 @@
3
3
  module Nanoc::Helpers
4
4
  # @see http://nanoc.ws/doc/reference/helpers/#breadcrumbs
5
5
  module Breadcrumbs
6
+ # @api private
7
+ module Int
8
+ # e.g. unfold(10.class, &:superclass)
9
+ # => [Integer, Numeric, Object, BasicObject]
10
+ def self.unfold(obj, &blk)
11
+ acc = [obj]
12
+
13
+ res = yield(obj)
14
+ if res
15
+ acc + unfold(res, &blk)
16
+ else
17
+ acc
18
+ end
19
+ end
20
+
21
+ # e.g. patterns_for_prefix('/foo/1.0')
22
+ # => ['/foo/1.0.*', '/foo/1.*']
23
+ def self.patterns_for_prefix(prefix)
24
+ prefixes =
25
+ unfold(prefix) do |old_prefix|
26
+ new_prefix = Nanoc::Identifier.new(old_prefix).without_ext
27
+ new_prefix == old_prefix ? nil : new_prefix
28
+ end
29
+
30
+ prefixes.map { |pr| pr + '.*' }
31
+ end
32
+ end
33
+
6
34
  # @return [Array]
7
35
  def breadcrumbs_trail
8
36
  # e.g. ['', '/foo', '/foo/bar']
@@ -18,7 +46,8 @@ module Nanoc::Helpers
18
46
  if pr == ''
19
47
  @items['/index.*']
20
48
  else
21
- @items[Nanoc::Identifier.new(pr).without_ext + '.*']
49
+ prefix_patterns = Int.patterns_for_prefix(pr)
50
+ prefix_patterns.lazy.map { |pat| @items[pat] }.find(&:itself)
22
51
  end
23
52
  end
24
53
  end
@@ -6,7 +6,7 @@ module Nanoc::RuleDSL
6
6
  #
7
7
  # @api private
8
8
  class ActionSequenceCalculator
9
- DDMemoize.activate(self, telemetry: Nanoc::MEMOIZATION_TELEMETRY)
9
+ DDMemoize.activate(self)
10
10
 
11
11
  class UnsupportedObjectTypeException < ::Nanoc::Error
12
12
  def initialize(obj)
data/lib/nanoc/spec.rb CHANGED
@@ -11,6 +11,19 @@ module Nanoc
11
11
  ensure
12
12
  Dir.chdir(here)
13
13
  end
14
+
15
+ def on_windows?
16
+ Nanoc.on_windows?
17
+ end
18
+
19
+ def command?(cmd)
20
+ which, null = on_windows? ? %w[where NUL] : ['which', '/dev/null']
21
+ system("#{which} #{cmd} > #{null} 2>&1")
22
+ end
23
+
24
+ def skip_unless_have_command(cmd)
25
+ skip "Could not find external command \"#{cmd}\"" unless command?(cmd)
26
+ end
14
27
  end
15
28
 
16
29
  class HelperContext
data/lib/nanoc/version.rb CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.8.17'
5
+ VERSION = '4.8.18'
6
6
  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.8.17
4
+ version: 4.8.18
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-12-16 00:00:00.000000000 Z
11
+ date: 2017-12-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - '='
46
46
  - !ruby/object:Gem::Version
47
- version: 1.0.0a2
47
+ version: 1.0.0a3
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - '='
53
53
  - !ruby/object:Gem::Version
54
- version: 1.0.0a2
54
+ version: 1.0.0a3
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: ddplugin
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,14 +72,14 @@ dependencies:
72
72
  requirements:
73
73
  - - '='
74
74
  - !ruby/object:Gem::Version
75
- version: 1.0.0a1
75
+ version: 1.0.0a2
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - '='
81
81
  - !ruby/object:Gem::Version
82
- version: 1.0.0a1
82
+ version: 1.0.0a2
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: hamster
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -204,6 +204,7 @@ files:
204
204
  - lib/nanoc/base/services/compiler/phases/recalculate.rb
205
205
  - lib/nanoc/base/services/compiler/phases/resume.rb
206
206
  - lib/nanoc/base/services/compiler/phases/write.rb
207
+ - lib/nanoc/base/services/compiler/stage.rb
207
208
  - lib/nanoc/base/services/compiler/stages.rb
208
209
  - lib/nanoc/base/services/compiler/stages/build_reps.rb
209
210
  - lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
@@ -221,6 +222,7 @@ files:
221
222
  - lib/nanoc/base/services/dependency_tracker.rb
222
223
  - lib/nanoc/base/services/executor.rb
223
224
  - lib/nanoc/base/services/filter.rb
225
+ - lib/nanoc/base/services/instrumentor.rb
224
226
  - lib/nanoc/base/services/item_rep_builder.rb
225
227
  - lib/nanoc/base/services/item_rep_router.rb
226
228
  - lib/nanoc/base/services/item_rep_selector.rb
@@ -402,7 +404,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
402
404
  version: '0'
403
405
  requirements: []
404
406
  rubyforge_project:
405
- rubygems_version: 2.7.3
407
+ rubygems_version: 2.7.4
406
408
  signing_key:
407
409
  specification_version: 4
408
410
  summary: A static-site generator with a focus on flexibility.