nanoc 4.11.9 → 4.11.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/NEWS.md +6 -0
  3. data/lib/nanoc/base.rb +0 -1
  4. data/lib/nanoc/base/services/compilation_context.rb +20 -0
  5. data/lib/nanoc/base/services/compiler/phases/write.rb +5 -2
  6. data/lib/nanoc/base/services/compiler/stages.rb +0 -2
  7. data/lib/nanoc/base/services/compiler/stages/build_reps.rb +4 -1
  8. data/lib/nanoc/base/services/compiler/stages/calculate_checksums.rb +1 -1
  9. data/lib/nanoc/base/services/compiler/stages/cleanup.rb +1 -1
  10. data/lib/nanoc/base/services/compiler/stages/compile_reps.rb +3 -3
  11. data/lib/nanoc/base/services/compiler/stages/determine_outdatedness.rb +1 -1
  12. data/lib/nanoc/base/services/compiler/stages/forget_outdated_dependencies.rb +1 -1
  13. data/lib/nanoc/base/services/compiler/stages/load_stores.rb +1 -1
  14. data/lib/nanoc/base/services/compiler/stages/postprocess.rb +1 -1
  15. data/lib/nanoc/base/services/compiler/stages/preprocess.rb +1 -1
  16. data/lib/nanoc/base/services/compiler/stages/prune.rb +1 -1
  17. data/lib/nanoc/base/services/compiler/stages/store_post_compilation_state.rb +1 -1
  18. data/lib/nanoc/base/services/compiler/stages/store_pre_compilation_state.rb +1 -1
  19. data/lib/nanoc/base/services/item_rep_builder.rb +1 -0
  20. data/lib/nanoc/base/services/item_rep_router.rb +1 -0
  21. data/lib/nanoc/base/services/item_rep_writer.rb +2 -2
  22. data/lib/nanoc/base/services/pruner.rb +1 -9
  23. data/lib/nanoc/base/views/view_context_for_compilation.rb +2 -2
  24. data/lib/nanoc/checking/checks/stale.rb +3 -2
  25. data/lib/nanoc/rule_dsl/action_provider.rb +1 -1
  26. data/lib/nanoc/spec.rb +2 -2
  27. data/lib/nanoc/version.rb +1 -1
  28. metadata +4 -6
  29. data/lib/nanoc/base/assertions.rb +0 -47
  30. data/lib/nanoc/base/services/compiler/stage.rb +0 -32
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ff9ad828cf4dbae57144f1794213717d587b220f19b3b6a9bc168b250d3f5508
4
- data.tar.gz: f4fd81a18bb15b30cc53109c4e7c3ddf2d71235d23ebc49ce6639c435b850101
3
+ metadata.gz: f613b6428b6cfd9eb92da14ff7768e830aacae1872df99649a9ca9941026a189
4
+ data.tar.gz: f208c9e15638f9745c558ec12d8a71a0bfb77744c24e735c4f9af2a20f510670
5
5
  SHA512:
6
- metadata.gz: 4ebe934930f925c2a829d1c52106c3fb5e0ca12f6c4a2a96093d60edef05fffe0de80bb9e68195e668921d3d5ec57bcd2f64956062a387933e83e9d49fbd53b6
7
- data.tar.gz: a175cb61715a437e1679b827130fb034d3f9b9fb82062437b807e8ce3d6e9897d23d92a9ef40ae6ef0ae47fb76a9d3800293a41b2b42dea5e9089ee840557ffa
6
+ metadata.gz: 45852ac268085e574f3b266f9ac96ec13848904ad6240a0411c46cefa21e867cc109a0ccdcdda9c9c40212e9b21de2f44338af053b6ed03b00d6a78c92de9c9e
7
+ data.tar.gz: 8e949b83020fb64bdb8fecd4a233d83a5a9d52c65e57d4a4b29909dc5bd7c723ac7e6a379fb240c7d34576031bf7122caf74b6502c4b041178086385531124e5
data/NEWS.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Nanoc news
2
2
 
3
+ ## 4.11.10 (2019-08-31)
4
+
5
+ Fixes:
6
+
7
+ * Fixed problem with sporadic `DDMetrics::Stopwatch::AlreadyRunningError` (#1445)
8
+
3
9
  ## 4.11.9 (2019-08-17)
4
10
 
5
11
  Enhancements:
@@ -9,7 +9,6 @@ end
9
9
  require_relative 'base/error'
10
10
  require_relative 'base/errors'
11
11
  require_relative 'base/changes_stream'
12
- require_relative 'base/assertions'
13
12
 
14
13
  require_relative 'base/feature'
15
14
  require_relative 'base/repos'
@@ -3,10 +3,26 @@
3
3
  module Nanoc
4
4
  module Int
5
5
  class CompilationContext
6
+ include Nanoc::Core::ContractsSupport
7
+
6
8
  attr_reader :site
7
9
  attr_reader :compiled_content_cache
8
10
  attr_reader :compiled_content_store
9
11
 
12
+ C_COMPILED_CONTENT_CACHE =
13
+ C::Or[
14
+ Nanoc::Core::CompiledContentCache,
15
+ Nanoc::Core::TextualCompiledContentCache,
16
+ Nanoc::Core::BinaryCompiledContentCache,
17
+ ]
18
+
19
+ contract C::KeywordArgs[
20
+ action_provider: Nanoc::Core::ActionProvider,
21
+ reps: Nanoc::Core::ItemRepRepo,
22
+ site: Nanoc::Core::Site,
23
+ compiled_content_cache: C_COMPILED_CONTENT_CACHE,
24
+ compiled_content_store: Nanoc::Core::CompiledContentStore,
25
+ ] => C::Any
10
26
  def initialize(action_provider:, reps:, site:, compiled_content_cache:, compiled_content_store:)
11
27
  @action_provider = action_provider
12
28
  @reps = reps
@@ -15,6 +31,8 @@ module Nanoc
15
31
  @compiled_content_store = compiled_content_store
16
32
  end
17
33
 
34
+ # FIXME: Expand contract
35
+ contract Nanoc::Core::Layout => C::Any
18
36
  def filter_name_and_args_for_layout(layout)
19
37
  seq = @action_provider.action_sequence_for(layout)
20
38
  if seq.nil? || seq.size != 1 || !seq[0].is_a?(Nanoc::Core::ProcessingActions::Filter)
@@ -24,6 +42,7 @@ module Nanoc
24
42
  [seq[0].filter_name, seq[0].params]
25
43
  end
26
44
 
45
+ contract Nanoc::Core::DependencyTracker => C::Named['Nanoc::ViewContextForCompilation']
27
46
  def create_view_context(dependency_tracker)
28
47
  Nanoc::ViewContextForCompilation.new(
29
48
  reps: @reps,
@@ -34,6 +53,7 @@ module Nanoc
34
53
  )
35
54
  end
36
55
 
56
+ contract Nanoc::Core::ItemRep, Nanoc::Core::DependencyTracker => Hash
37
57
  def assigns_for(rep, dependency_tracker)
38
58
  last_content = @compiled_content_store.get_current(rep)
39
59
  content_or_filename_assigns =
@@ -72,9 +72,12 @@ module Nanoc
72
72
  def run(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
73
73
  yield
74
74
 
75
- @queue << rep
76
-
75
+ # Caution: Notification must be posted before enqueueing the rep,
76
+ # or we risk a race condition where the :rep_write_ended
77
+ # notification happens before the :rep_write_enqueued one.
77
78
  Nanoc::Core::NotificationCenter.post(:rep_write_enqueued, rep)
79
+
80
+ @queue << rep
78
81
  end
79
82
  end
80
83
  end
@@ -9,8 +9,6 @@ module Nanoc
9
9
  end
10
10
  end
11
11
 
12
- require_relative 'stage'
13
-
14
12
  require_relative 'stages/calculate_checksums'
15
13
  require_relative 'stages/cleanup'
16
14
  require_relative 'stages/compile_reps'
@@ -4,7 +4,10 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class BuildReps < Nanoc::Int::Compiler::Stage
7
+ class BuildReps < Nanoc::Core::CompilationStage
8
+ include Nanoc::Core::ContractsSupport
9
+
10
+ contract C::KeywordArgs[site: Nanoc::Core::Site, action_provider: Nanoc::Core::ActionProvider] => C::Any
8
11
  def initialize(site:, action_provider:)
9
12
  @site = site
10
13
  @action_provider = action_provider
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class CalculateChecksums < Nanoc::Int::Compiler::Stage
7
+ class CalculateChecksums < Nanoc::Core::CompilationStage
8
8
  def initialize(items:, layouts:, code_snippets:, config:)
9
9
  @items = items
10
10
  @layouts = layouts
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class Cleanup < Nanoc::Int::Compiler::Stage
7
+ class Cleanup < Nanoc::Core::CompilationStage
8
8
  def initialize(output_dirs)
9
9
  @output_dirs = output_dirs
10
10
  end
@@ -4,9 +4,9 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class CompileReps < Nanoc::Int::Compiler::Stage
7
+ class CompileReps < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
- include Nanoc::Assertions::Mixin
9
+ include Nanoc::Core::Assertions::Mixin
10
10
 
11
11
  def initialize(reps:, outdatedness_store:, dependency_store:, action_sequences:, compilation_context:, compiled_content_cache:)
12
12
  @reps = reps
@@ -28,7 +28,7 @@ module Nanoc
28
28
  end
29
29
  end
30
30
 
31
- assert Nanoc::Assertions::AllItemRepsHaveCompiledContent.new(
31
+ assert Nanoc::Core::Assertions::AllItemRepsHaveCompiledContent.new(
32
32
  compiled_content_cache: @compiled_content_cache,
33
33
  item_reps: @reps,
34
34
  )
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class DetermineOutdatedness < Nanoc::Int::Compiler::Stage
7
+ class DetermineOutdatedness < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
9
 
10
10
  def initialize(reps:, outdatedness_checker:, outdatedness_store:)
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class ForgetOutdatedDependencies < Nanoc::Int::Compiler::Stage
7
+ class ForgetOutdatedDependencies < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
9
 
10
10
  def initialize(dependency_store:)
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class LoadStores < Nanoc::Int::Compiler::Stage
7
+ class LoadStores < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
9
 
10
10
  def initialize(checksum_store:, compiled_content_cache:, dependency_store:, action_sequence_store:, outdatedness_store:)
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class Postprocess < Nanoc::Int::Compiler::Stage
7
+ class Postprocess < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
9
 
10
10
  def initialize(action_provider:, site:)
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class Preprocess < Nanoc::Int::Compiler::Stage
7
+ class Preprocess < Nanoc::Core::CompilationStage
8
8
  def initialize(action_provider:, site:, dependency_store:, checksum_store:)
9
9
  @action_provider = action_provider
10
10
  @site = site
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class Prune < Nanoc::Int::Compiler::Stage
7
+ class Prune < Nanoc::Core::CompilationStage
8
8
  def initialize(config:, reps:)
9
9
  @config = config
10
10
  @reps = reps
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class StorePostCompilationState < Nanoc::Int::Compiler::Stage
7
+ class StorePostCompilationState < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
9
 
10
10
  def initialize(dependency_store:)
@@ -4,7 +4,7 @@ module Nanoc
4
4
  module Int
5
5
  class Compiler
6
6
  module Stages
7
- class StorePreCompilationState < Nanoc::Int::Compiler::Stage
7
+ class StorePreCompilationState < Nanoc::Core::CompilationStage
8
8
  include Nanoc::Core::ContractsSupport
9
9
 
10
10
  def initialize(reps:, layouts:, checksum_store:, action_sequence_store:, action_sequences:)
@@ -8,6 +8,7 @@ module Nanoc
8
8
 
9
9
  attr_reader :reps
10
10
 
11
+ contract Nanoc::Core::Site, Nanoc::Core::ActionProvider, Nanoc::Core::ItemRepRepo => C::Any
11
12
  def initialize(site, action_provider, reps)
12
13
  @site = site
13
14
  @action_provider = action_provider
@@ -20,6 +20,7 @@ module Nanoc
20
20
  end
21
21
  end
22
22
 
23
+ contract Nanoc::Core::ItemRepRepo, Nanoc::Core::ActionProvider, Nanoc::Core::Site => C::Any
23
24
  def initialize(reps, action_provider, site)
24
25
  @reps = reps
25
26
  @action_provider = action_provider
@@ -5,7 +5,7 @@ module Nanoc
5
5
  # @api private
6
6
  class ItemRepWriter
7
7
  include Nanoc::Core::ContractsSupport
8
- include Nanoc::Assertions::Mixin
8
+ include Nanoc::Core::Assertions::Mixin
9
9
 
10
10
  TMP_TEXT_ITEMS_DIR = 'text_items'
11
11
 
@@ -24,7 +24,7 @@ module Nanoc
24
24
  end
25
25
 
26
26
  def write_single(item_rep, compiled_content_store, snapshot_name, raw_path, written_paths)
27
- assert Nanoc::Assertions::PathIsAbsolute.new(path: raw_path)
27
+ assert Nanoc::Core::Assertions::PathIsAbsolute.new(path: raw_path)
28
28
 
29
29
  # Don’t write twice
30
30
  # TODO: test written_paths behavior
@@ -8,15 +8,7 @@ module Nanoc
8
8
  class Pruner
9
9
  include Nanoc::Core::ContractsSupport
10
10
 
11
- # @param [Nanoc::Core::Configuration] config
12
- #
13
- # @param [Nanoc::Core::ItemRepRepo] reps
14
- #
15
- # @param [Boolean] dry_run true if the files to be deleted
16
- # should only be printed instead of actually deleted, false if the files
17
- # should actually be deleted.
18
- #
19
- # @param [Enumerable<String>] exclude
11
+ contract Nanoc::Core::Configuration, Nanoc::Core::ItemRepRepo, C::KeywordArgs[dry_run: C::Optional[C::Bool], exclude: C::Optional[C::IterOf[String]]] => C::Any
20
12
  def initialize(config, reps, dry_run: false, exclude: [])
21
13
  @config = config
22
14
  @reps = reps
@@ -14,9 +14,9 @@ module Nanoc
14
14
  contract C::KeywordArgs[
15
15
  reps: Nanoc::Core::ItemRepRepo,
16
16
  items: Nanoc::Core::IdentifiableCollection,
17
- dependency_tracker: C::Any,
17
+ dependency_tracker: Nanoc::Core::DependencyTracker,
18
18
  compilation_context: C::Any,
19
- compiled_content_store: C::Any,
19
+ compiled_content_store: Nanoc::Core::CompiledContentStore,
20
20
  ] => C::Any
21
21
  def initialize(reps:, items:, dependency_tracker:, compilation_context:, compiled_content_store:)
22
22
  @reps = reps
@@ -33,8 +33,9 @@ module Nanoc::Checking::Checks
33
33
 
34
34
  def pruner
35
35
  exclude_config = @config.fetch(:prune, {}).fetch(:exclude, [])
36
- # FIXME: reps=nil is icky
37
- @pruner ||= Nanoc::Pruner.new(@config, nil, exclude: exclude_config)
36
+ # FIXME: specifying reps this way is icky
37
+ reps = Nanoc::Core::ItemRepRepo.new
38
+ @pruner ||= Nanoc::Pruner.new(@config._unwrap, reps, exclude: exclude_config)
38
39
  end
39
40
  end
40
41
  end
@@ -65,7 +65,7 @@ module Nanoc::RuleDSL
65
65
  items: site.items,
66
66
  dependency_tracker: dependency_tracker,
67
67
  compilation_context: compiler.compilation_context(reps: reps),
68
- compiled_content_store: nil,
68
+ compiled_content_store: Nanoc::Core::CompiledContentStore.new,
69
69
  )
70
70
  ctx = new_postprocessor_context(site, view_context)
71
71
 
@@ -164,8 +164,8 @@ module Nanoc
164
164
  Nanoc::Int::CompilationContext.new(
165
165
  action_provider: @action_provider,
166
166
  reps: @reps,
167
- site: @site,
168
- compiled_content_cache: :__compiled_content_cache,
167
+ site: site,
168
+ compiled_content_cache: Nanoc::Core::CompiledContentCache.new(config: @config),
169
169
  compiled_content_store: @compiled_content_store,
170
170
  )
171
171
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module Nanoc
4
4
  # The current Nanoc version.
5
- VERSION = '4.11.9'
5
+ VERSION = '4.11.10'
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.11.9
4
+ version: 4.11.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-17 00:00:00.000000000 Z
11
+ date: 2019-08-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable
@@ -58,14 +58,14 @@ dependencies:
58
58
  requirements:
59
59
  - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: 4.11.9
61
+ version: 4.11.10
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: 4.11.9
68
+ version: 4.11.10
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: parallel
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -166,7 +166,6 @@ files:
166
166
  - bin/nanoc
167
167
  - lib/nanoc.rb
168
168
  - lib/nanoc/base.rb
169
- - lib/nanoc/base/assertions.rb
170
169
  - lib/nanoc/base/changes_stream.rb
171
170
  - lib/nanoc/base/error.rb
172
171
  - lib/nanoc/base/errors.rb
@@ -185,7 +184,6 @@ files:
185
184
  - lib/nanoc/base/services/compiler/phases/recalculate.rb
186
185
  - lib/nanoc/base/services/compiler/phases/resume.rb
187
186
  - lib/nanoc/base/services/compiler/phases/write.rb
188
- - lib/nanoc/base/services/compiler/stage.rb
189
187
  - lib/nanoc/base/services/compiler/stages.rb
190
188
  - lib/nanoc/base/services/compiler/stages/build_reps.rb
191
189
  - lib/nanoc/base/services/compiler/stages/calculate_checksums.rb
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Assertions
5
- class AssertionFailure < Nanoc::Int::Errors::InternalInconsistency
6
- end
7
-
8
- module Mixin
9
- def assert(assertion)
10
- return unless Nanoc::Core::ContractsSupport.enabled?
11
-
12
- unless assertion.call
13
- raise AssertionFailure, "assertion failed: #{assertion.class}"
14
- end
15
- end
16
- end
17
-
18
- class Base
19
- def call
20
- raise NotImplementedError
21
- end
22
- end
23
-
24
- class AllItemRepsHaveCompiledContent < Nanoc::Assertions::Base
25
- def initialize(compiled_content_cache:, item_reps:)
26
- @compiled_content_cache = compiled_content_cache
27
- @item_reps = item_reps
28
- end
29
-
30
- def call
31
- @item_reps.all? do |rep|
32
- @compiled_content_cache[rep]
33
- end
34
- end
35
- end
36
-
37
- class PathIsAbsolute < Nanoc::Assertions::Base
38
- def initialize(path:)
39
- @path = path
40
- end
41
-
42
- def call
43
- Pathname.new(@path).absolute?
44
- end
45
- end
46
- end
47
- end
@@ -1,32 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Int
5
- class Compiler
6
- class Stage
7
- def call(*args)
8
- notify(:stage_started)
9
- res = Nanoc::Core::Instrumentor.call(:stage_ran, self.class) do
10
- run(*args)
11
- end
12
- notify(:stage_ended)
13
- res
14
- rescue
15
- notify(:stage_aborted)
16
- raise
17
- end
18
-
19
- def run(*)
20
- raise NotImplementedError
21
- end
22
-
23
- private
24
-
25
- def notify(sym)
26
- name = self.class.to_s.sub(/^.*::/, '')
27
- Nanoc::Core::NotificationCenter.post(sym, name)
28
- end
29
- end
30
- end
31
- end
32
- end