nanoc-core 4.13.5 → 4.14.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a6e74deb4968f4bad8e83ccbd91797be60fac35b5ad4b08687b24751bd880fb
4
- data.tar.gz: fd3feca15b92a45617b0dc989f56965822081d83af94cb1d168912c29fd84135
3
+ metadata.gz: 5de89d113517fc4b36e407d4e143a8cf715a976403a88ebccd7b835657d0fe7c
4
+ data.tar.gz: fa356053ac5f68c8000fe8f33d5c04441e866921905f9b360a0f55c16897e3ac
5
5
  SHA512:
6
- metadata.gz: c97de8904374f0620b01848e71e3de9fd753d507aa1ccf1804e94e9eafdcbe2459f318a6646e41a3b18ca6146c78b84271785de65534ca8e729fead59294afcf
7
- data.tar.gz: d43e488b4139003a08cfe726e4a8c3ef2a588d63b031be816a924623a68f3b37b083ad5e28f5bffeb2bc23bd713d6f4194fe74d72fd534268ccf57b541dc723e
6
+ metadata.gz: c6ee804845d8df4865282f5844d9d04005efd6b72235a8d1c145308d9df521f1340852934564b34163623da8809abbde7c003dfc04cea8865dd30139898db2ed
7
+ data.tar.gz: aff44bee226c1edbf815cb9f459a2ab6a59729f0ffd520a771e101f1b92aa11a3adcbf447547a61a147aee7d032ed0849326d65f59c7e6f36a77886791b45ee9
@@ -77,29 +77,27 @@ module Nanoc
77
77
  @action_sequences = action_sequences
78
78
 
79
79
  # Memoize
80
- @_outdatedness_status_for = {}
80
+ @_apply_rules = {}
81
81
  end
82
82
 
83
83
  contract C_OBJ_MAYBE_REP => C::Maybe[Nanoc::Core::OutdatednessStatus]
84
84
  def outdatedness_status_for(obj)
85
- # TODO: remove memoization (no longer needed)
86
- @_outdatedness_status_for[obj] ||=
87
- case obj
88
- when Nanoc::Core::ItemRep
89
- apply_rules(RULES_FOR_ITEM_REP, obj)
90
- when Nanoc::Core::Item
91
- apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
92
- when Nanoc::Core::Layout
93
- apply_rules(RULES_FOR_LAYOUT, obj)
94
- when Nanoc::Core::Configuration
95
- apply_rules(RULES_FOR_CONFIG, obj)
96
- when Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection
97
- # Collections are never outdated. Objects inside them might be,
98
- # however.
99
- apply_rules([], obj)
100
- else
101
- raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
102
- end
85
+ case obj
86
+ when Nanoc::Core::ItemRep
87
+ apply_rules(RULES_FOR_ITEM_REP, obj)
88
+ when Nanoc::Core::Item
89
+ apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
90
+ when Nanoc::Core::Layout
91
+ apply_rules(RULES_FOR_LAYOUT, obj)
92
+ when Nanoc::Core::Configuration
93
+ apply_rules(RULES_FOR_CONFIG, obj)
94
+ when Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection
95
+ # Collections are never outdated. Objects inside them might be,
96
+ # however.
97
+ apply_rules([], obj)
98
+ else
99
+ raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
100
+ end
103
101
  end
104
102
 
105
103
  def action_sequence_for(rep)
@@ -110,18 +108,19 @@ module Nanoc
110
108
 
111
109
  contract C::ArrayOf[Class], C_OBJ_MAYBE_REP, Nanoc::Core::OutdatednessStatus => C::Maybe[Nanoc::Core::OutdatednessStatus]
112
110
  def apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new)
113
- rules.inject(status) do |acc, rule|
114
- if acc.useful_to_apply?(rule)
115
- reason = rule.instance.call(obj, self)
116
- if reason
117
- acc.update(reason)
111
+ @_apply_rules[obj] ||=
112
+ rules.inject(status) do |acc, rule|
113
+ if acc.useful_to_apply?(rule)
114
+ reason = rule.instance.call(obj, self)
115
+ if reason
116
+ acc.update(reason)
117
+ else
118
+ acc
119
+ end
118
120
  else
119
121
  acc
120
122
  end
121
- else
122
- acc
123
123
  end
124
- end
125
124
  end
126
125
 
127
126
  contract C::ArrayOf[Class], C::ArrayOf[C_OBJ_MAYBE_REP] => C::Maybe[Nanoc::Core::OutdatednessStatus]
@@ -27,7 +27,7 @@ module Nanoc
27
27
  res = @item_rep.raw_path(snapshot:)
28
28
 
29
29
  unless @item_rep.compiled?
30
- Fiber.yield(Nanoc::Core::Errors::UnmetDependency.new(@item_rep, snapshot))
30
+ raise Nanoc::Core::Errors::UnmetDependency.new(@item_rep, snapshot)
31
31
  end
32
32
 
33
33
  # Wait for file to exist
@@ -12,6 +12,9 @@ module Nanoc
12
12
  Nanoc::Core::NotificationCenter.post(:compilation_started, rep)
13
13
  yield
14
14
  Nanoc::Core::NotificationCenter.post(:compilation_ended, rep)
15
+ rescue Nanoc::Core::Errors::UnmetDependency
16
+ Nanoc::Core::NotificationCenter.post(:compilation_suspended, rep)
17
+ raise
15
18
  end
16
19
  end
17
20
  end
@@ -23,10 +23,16 @@ module Nanoc
23
23
 
24
24
  executor = Nanoc::Core::Executor.new(rep, @compilation_context, dependency_tracker)
25
25
 
26
- @compilation_context.compiled_content_store.set_current(rep, rep.item.content)
26
+ # Set initial content, if not already present
27
+ compiled_content_store = @compilation_context.compiled_content_store
28
+ unless compiled_content_store.get_current(rep)
29
+ compiled_content_store.set_current(rep, rep.item.content)
30
+ end
31
+
32
+ actions = pending_action_sequence_for(rep:)
33
+ until actions.empty?
34
+ action = actions.first
27
35
 
28
- actions = @action_sequences[rep]
29
- actions.each do |action|
30
36
  case action
31
37
  when Nanoc::Core::ProcessingActions::Filter
32
38
  executor.filter(action.filter_name, action.params)
@@ -39,10 +45,17 @@ module Nanoc
39
45
  else
40
46
  raise Nanoc::Core::Errors::InternalInconsistency, "unknown action #{action.inspect}"
41
47
  end
48
+
49
+ actions.shift
42
50
  end
43
51
  ensure
44
52
  dependency_tracker.exit
45
53
  end
54
+
55
+ def pending_action_sequence_for(rep:)
56
+ @_pending_action_sequences ||= {}
57
+ @_pending_action_sequences[rep] ||= @action_sequences[rep].to_a
58
+ end
46
59
  end
47
60
  end
48
61
  end
@@ -87,13 +87,9 @@ module Nanoc
87
87
  wrapped: recalculate_phase,
88
88
  )
89
89
 
90
- resume_phase = Nanoc::Core::CompilationPhases::Resume.new(
91
- wrapped: cache_phase,
92
- )
93
-
94
90
  write_phase = Nanoc::Core::CompilationPhases::Write.new(
95
91
  compiled_content_store: @compilation_context.compiled_content_store,
96
- wrapped: resume_phase,
92
+ wrapped: cache_phase,
97
93
  )
98
94
 
99
95
  mark_done_phase = Nanoc::Core::CompilationPhases::MarkDone.new(
@@ -57,9 +57,8 @@ module Nanoc
57
57
  content = get(rep, snapshot_name)
58
58
  return content if content
59
59
 
60
- # Content is unavailable; notify and try again
61
- Fiber.yield(Nanoc::Core::Errors::UnmetDependency.new(rep, snapshot_name))
62
- get(rep, snapshot_name)
60
+ # Content is unavailable
61
+ raise Nanoc::Core::Errors::UnmetDependency.new(rep, snapshot_name)
63
62
  end
64
63
 
65
64
  contract C::KeywordArgs[rep: Nanoc::Core::ItemRep, snapshot: C::Optional[C::Maybe[Symbol]]] => String
@@ -29,7 +29,11 @@ module Nanoc
29
29
 
30
30
  # @return [String]
31
31
  def self.config_filename_for_cwd
32
- filenames = %w[nanoc.yaml config.yaml]
32
+ filenames = [
33
+ 'nanoc.yaml',
34
+ 'nanoc.toml',
35
+ 'config.yaml',
36
+ ]
33
37
  candidate = filenames.find { |f| File.file?(f) }
34
38
  candidate && File.expand_path(candidate)
35
39
  end
@@ -54,7 +58,8 @@ module Nanoc
54
58
  end
55
59
 
56
60
  def load_file(filename)
57
- YamlLoader.load_file(filename)
61
+ loader = StructuredDataLoader.for_extension(File.extname(filename))
62
+ loader.load_file(filename)
58
63
  end
59
64
 
60
65
  # @api private
@@ -78,8 +78,8 @@ module Nanoc
78
78
  end
79
79
  end
80
80
 
81
- def contract(*args)
82
- Contract(*args)
81
+ def contract(*)
82
+ Contract(*)
83
83
  end
84
84
  end
85
85
 
@@ -14,24 +14,24 @@ module Nanoc
14
14
  C::Or[
15
15
  C::SetOf[C::Or[String, Regexp]],
16
16
  C::ArrayOf[C::Or[String, Regexp]],
17
- C::Bool
17
+ C::Bool,
18
18
  ]
19
19
 
20
20
  C_ATTR =
21
21
  C::Or[
22
22
  C::SetOf[
23
23
  C::Or[
24
- Symbol, # any value
25
- [Symbol, C::Any] # pair (specific value)
24
+ Symbol, # any value
25
+ [Symbol, C::Any], # pair (specific value)
26
26
  ],
27
27
  ],
28
28
  C::ArrayOf[
29
29
  C::Or[
30
- Symbol, # any value
31
- [Symbol, C::Any] # pair (specific value)
30
+ Symbol, # any value
31
+ [Symbol, C::Any], # pair (specific value)
32
32
  ],
33
33
  ],
34
- C::Bool
34
+ C::Bool,
35
35
  ]
36
36
 
37
37
  C_ARGS =
@@ -39,7 +39,7 @@ module Nanoc
39
39
  raw_content: C::Optional[C_RAW_CONTENT],
40
40
  attributes: C::Optional[C_ATTR],
41
41
  compiled_content: C::Optional[C::Bool],
42
- path: C::Optional[C::Bool]
42
+ path: C::Optional[C::Bool],
43
43
  ]
44
44
 
45
45
  contract C_ARGS => C::Any
@@ -9,14 +9,14 @@ module Nanoc
9
9
  C_RAW_CONTENT =
10
10
  C::Or[
11
11
  C::ArrayOf[C::Or[String, Regexp]],
12
- C::Bool
12
+ C::Bool,
13
13
  ]
14
14
 
15
15
  C_ATTR =
16
16
  C::Or[
17
17
  C::ArrayOf[Symbol],
18
18
  C::HashOf[Symbol => C::Any],
19
- C::Bool
19
+ C::Bool,
20
20
  ]
21
21
 
22
22
  C_KEYWORD_PROPS =
@@ -24,7 +24,7 @@ module Nanoc
24
24
  raw_content: C::Optional[C_RAW_CONTENT],
25
25
  attributes: C::Optional[C_ATTR],
26
26
  compiled_content: C::Optional[C::Bool],
27
- path: C::Optional[C::Bool]
27
+ path: C::Optional[C::Bool],
28
28
  ]
29
29
 
30
30
  C_OBJ_SRC = Nanoc::Core::Item
@@ -34,7 +34,7 @@ module Nanoc
34
34
  Nanoc::Core::Item,
35
35
  Nanoc::Core::Layout,
36
36
  Nanoc::Core::Configuration,
37
- Nanoc::Core::IdentifiableCollection
37
+ Nanoc::Core::IdentifiableCollection,
38
38
  ]
39
39
 
40
40
  attr_reader :items
@@ -11,20 +11,20 @@ module Nanoc
11
11
  Nanoc::Core::Item,
12
12
  Nanoc::Core::Layout,
13
13
  Nanoc::Core::Configuration,
14
- Nanoc::Core::IdentifiableCollection
14
+ Nanoc::Core::IdentifiableCollection,
15
15
  ]
16
16
 
17
17
  C_RAW_CONTENT =
18
18
  C::Or[
19
19
  C::ArrayOf[C::Or[String, Regexp]],
20
- C::Bool
20
+ C::Bool,
21
21
  ]
22
22
 
23
23
  C_ATTR =
24
24
  C::Or[
25
25
  C::ArrayOf[Symbol],
26
26
  C::HashOf[Symbol => C::Any],
27
- C::Bool
27
+ C::Bool,
28
28
  ]
29
29
 
30
30
  C_ARGS =
@@ -32,7 +32,7 @@ module Nanoc
32
32
  raw_content: C::Optional[C_RAW_CONTENT],
33
33
  attributes: C::Optional[C_ATTR],
34
34
  compiled_content: C::Optional[C::Bool],
35
- path: C::Optional[C::Bool]
35
+ path: C::Optional[C::Bool],
36
36
  ]
37
37
 
38
38
  attr_reader :dependency_store
@@ -33,6 +33,8 @@ module Nanoc
33
33
  # graph.predecessors_of('e').sort
34
34
  # # => %w( c d )
35
35
  class DirectedGraph
36
+ EMPTY_SET = Set.new.freeze
37
+
36
38
  # @group Creating a graph
37
39
 
38
40
  # Creates a new directed graph with the given vertices.
@@ -40,7 +42,8 @@ module Nanoc
40
42
  @vertices = {}
41
43
  @next_vertex_idx = 0
42
44
  vertices.each do |v|
43
- @vertices[v] = @next_vertex_idx.tap { @next_vertex_idx += 1 }
45
+ @vertices[v] = @next_vertex_idx
46
+ @next_vertex_idx += 1
44
47
  end
45
48
 
46
49
  @to_graph = {}
@@ -93,7 +96,8 @@ module Nanoc
93
96
  def add_vertex(vertex)
94
97
  return if @vertices.key?(vertex)
95
98
 
96
- @vertices[vertex] = @next_vertex_idx.tap { @next_vertex_idx += 1 }
99
+ @vertices[vertex] = @next_vertex_idx
100
+ @next_vertex_idx += 1
97
101
  end
98
102
 
99
103
  # Deletes all edges going to the given vertex.
@@ -121,7 +125,7 @@ module Nanoc
121
125
  #
122
126
  # @return [Array] Direct predecessors of the given vertex
123
127
  def direct_predecessors_of(to)
124
- @to_graph.fetch(to, Set.new)
128
+ @to_graph.fetch(to, EMPTY_SET)
125
129
  end
126
130
 
127
131
  # Returns the predecessors of the given vertex, i.e. the vertices x for
@@ -91,4 +91,4 @@ module Nanoc
91
91
  end
92
92
  end
93
93
 
94
- Nanoc::Core::Feature.define('where', version: '4.13')
94
+ Nanoc::Core::Feature.define('where', version: '4.14')
@@ -249,11 +249,6 @@ module Nanoc
249
249
  end
250
250
  end
251
251
 
252
- # @api private
253
- def on_main_fiber(&block)
254
- Fiber.yield(block)
255
- end
256
-
257
252
  contract C::ArrayOf[C::Named['Nanoc::Core::BasicItemView']] => C::Any
258
253
  # Creates a dependency from the item that is currently being filtered onto
259
254
  # the given collection of items. In other words, require the given items
@@ -23,7 +23,7 @@ module Nanoc
23
23
  @enabled = false
24
24
  end
25
25
 
26
- def self.call(key, *args)
26
+ def self.call(key, *)
27
27
  return yield unless @enabled
28
28
 
29
29
  begin
@@ -32,7 +32,7 @@ module Nanoc
32
32
  yield
33
33
  ensure
34
34
  stopwatch.stop
35
- Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *args)
35
+ Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *)
36
36
  end
37
37
  end
38
38
  end
@@ -10,46 +10,9 @@ module Nanoc
10
10
  # table of subscribers is not stored in the observable object itself, but in
11
11
  # the notification center.
12
12
  class NotificationCenter
13
- DONE = Object.new
14
- SYNC = Object.new
15
-
16
13
  def initialize
17
- @thread = nil
18
-
19
14
  # name => observers dictionary
20
15
  @notifications = Hash.new { |hash, name| hash[name] = [] }
21
-
22
- @queue = Queue.new
23
-
24
- @sync_queue = Queue.new
25
- on(SYNC, self) { @sync_queue << true }
26
- end
27
-
28
- def start
29
- @thread ||= Thread.new do # rubocop:disable Naming/MemoizedInstanceVariableName
30
- Thread.current.abort_on_exception = true
31
-
32
- loop do
33
- elem = @queue.pop
34
- break if DONE.equal?(elem)
35
-
36
- name = elem[0]
37
- args = elem[1]
38
-
39
- @notifications[name].each do |observer|
40
- observer[:block].call(*args)
41
- end
42
- end
43
- end
44
- end
45
-
46
- def stop
47
- @queue << DONE
48
- @thread.join
49
- end
50
-
51
- def force_stop
52
- @queue << DONE
53
16
  end
54
17
 
55
18
  def on(name, id = nil, &block)
@@ -61,26 +24,24 @@ module Nanoc
61
24
  end
62
25
 
63
26
  def post(name, *args)
64
- @queue << [name, args]
65
- self
66
- end
27
+ @notifications[name].each do |observer|
28
+ observer[:block].call(*args)
29
+ end
67
30
 
68
- def sync
69
- post(SYNC)
70
- @sync_queue.pop
31
+ self
71
32
  end
72
33
 
73
34
  class << self
74
35
  def instance
75
- @_instance ||= new.tap(&:start)
36
+ @_instance ||= new
76
37
  end
77
38
 
78
39
  def on(name, id = nil, &)
79
40
  instance.on(name, id, &)
80
41
  end
81
42
 
82
- def post(name, *args)
83
- instance.post(name, *args)
43
+ def post(name, *)
44
+ instance.post(name, *)
84
45
  end
85
46
 
86
47
  def remove(name, id)
@@ -88,18 +49,8 @@ module Nanoc
88
49
  end
89
50
 
90
51
  def reset
91
- instance.stop
92
52
  @_instance = nil
93
53
  end
94
-
95
- def force_reset
96
- instance.force_stop
97
- @_instance = nil
98
- end
99
-
100
- def sync
101
- instance.sync
102
- end
103
54
  end
104
55
  end
105
56
  end
@@ -28,7 +28,7 @@ module Nanoc
28
28
  dependency_store: Nanoc::Core::DependencyStore,
29
29
  action_sequence_store: Nanoc::Core::ActionSequenceStore,
30
30
  action_sequences: C_ACTION_SEQUENCES,
31
- reps: Nanoc::Core::ItemRepRepo
31
+ reps: Nanoc::Core::ItemRepRepo,
32
32
  ] => C::Any
33
33
  def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
34
34
  @site = site
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ # @api private
6
+ module StructuredDataLoader
7
+ class UnknownLanguageError < StandardError
8
+ def initialize(lang)
9
+ super("cannot find loader for language: #{lang.inspect}")
10
+ end
11
+ end
12
+
13
+ def self.for_language(language)
14
+ case language
15
+ when :yaml
16
+ YamlLoader
17
+ when :toml
18
+ TomlLoader
19
+ else
20
+ raise UnknownLanguageError.enw(language)
21
+ end
22
+ end
23
+
24
+ def self.for_extension(ext)
25
+ case ext
26
+ when '.yaml'
27
+ YamlLoader
28
+ when '.toml'
29
+ TomlLoader
30
+ else
31
+ raise UnknownLanguageError.enw(language)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ # @api private
6
+ module TomlLoader
7
+ def self.load(string)
8
+ require 'perfect_toml'
9
+ PerfectTOML.parse(string)
10
+ end
11
+
12
+ def self.load_file(filename)
13
+ require 'perfect_toml'
14
+ load(File.read(filename))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.13.5'
5
+ VERSION = '4.14.1'
6
6
  end
7
7
  end
@@ -10,7 +10,7 @@ module Nanoc
10
10
  contract C::Maybe[C::Or[
11
11
  Nanoc::Core::ViewContextForCompilation,
12
12
  Nanoc::Core::ViewContextForPreCompilation,
13
- Nanoc::Core::ViewContextForShell
13
+ Nanoc::Core::ViewContextForShell,
14
14
  ]] => C::Any
15
15
  def initialize(context)
16
16
  @context = context
@@ -11,8 +11,8 @@ module Nanoc
11
11
 
12
12
  private_constant :OPTIONS
13
13
 
14
- def self.load(yaml_string)
15
- YAML.safe_load(yaml_string, **OPTIONS)
14
+ def self.load(string)
15
+ YAML.safe_load(string, **OPTIONS)
16
16
  end
17
17
 
18
18
  def self.load_file(filename)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.13.5
4
+ version: 4.14.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
@@ -185,7 +185,6 @@ files:
185
185
  - lib/nanoc/core/compilation_phases/mark_done.rb
186
186
  - lib/nanoc/core/compilation_phases/notify.rb
187
187
  - lib/nanoc/core/compilation_phases/recalculate.rb
188
- - lib/nanoc/core/compilation_phases/resume.rb
189
188
  - lib/nanoc/core/compilation_phases/write.rb
190
189
  - lib/nanoc/core/compilation_stage.rb
191
190
  - lib/nanoc/core/compilation_stages/build_reps.rb
@@ -286,9 +285,11 @@ files:
286
285
  - lib/nanoc/core/snapshot_def.rb
287
286
  - lib/nanoc/core/store.rb
288
287
  - lib/nanoc/core/string_pattern.rb
288
+ - lib/nanoc/core/structured_data_loader.rb
289
289
  - lib/nanoc/core/temp_filename_factory.rb
290
290
  - lib/nanoc/core/textual_compiled_content_cache.rb
291
291
  - lib/nanoc/core/textual_content.rb
292
+ - lib/nanoc/core/toml_loader.rb
292
293
  - lib/nanoc/core/trivial_error.rb
293
294
  - lib/nanoc/core/utils.rb
294
295
  - lib/nanoc/core/version.rb
@@ -302,7 +303,7 @@ licenses:
302
303
  - MIT
303
304
  metadata:
304
305
  rubygems_mfa_required: 'true'
305
- source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.13.5/nanoc-core
306
+ source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.14.1/nanoc-core
306
307
  rdoc_options: []
307
308
  require_paths:
308
309
  - lib
@@ -310,14 +311,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
310
311
  requirements:
311
312
  - - ">="
312
313
  - !ruby/object:Gem::Version
313
- version: '3.1'
314
+ version: '3.2'
314
315
  required_rubygems_version: !ruby/object:Gem::Requirement
315
316
  requirements:
316
317
  - - ">="
317
318
  - !ruby/object:Gem::Version
318
319
  version: '0'
319
320
  requirements: []
320
- rubygems_version: 3.6.7
321
+ rubygems_version: 3.7.2
321
322
  specification_version: 4
322
323
  summary: Core of Nanoc
323
324
  test_files: []
@@ -1,52 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Nanoc
4
- module Core
5
- module CompilationPhases
6
- # Provides functionality for suspending and resuming item rep compilation (using fibers).
7
- class Resume < Abstract
8
- include Nanoc::Core::ContractsSupport
9
-
10
- DONE = Object.new
11
-
12
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
13
- def run(rep, is_outdated:, &block)
14
- fiber = fiber_for(rep, is_outdated:, &block)
15
- while fiber.alive?
16
- res = fiber.resume
17
-
18
- case res
19
- when Nanoc::Core::Errors::UnmetDependency
20
- Nanoc::Core::NotificationCenter.post(:compilation_suspended, rep, res.rep, res.snapshot_name)
21
- raise(res)
22
- when Proc
23
- fiber.resume(res.call)
24
- when DONE
25
- # ignore
26
- else
27
- raise Nanoc::Core::Errors::InternalInconsistency.new(
28
- "Fiber yielded object of unexpected type #{res.class}",
29
- )
30
- end
31
- end
32
- end
33
-
34
- private
35
-
36
- contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => Fiber
37
- def fiber_for(rep, is_outdated:) # rubocop:disable Lint/UnusedMethodArgument
38
- @fibers ||= {}
39
-
40
- @fibers[rep] ||=
41
- Fiber.new do
42
- yield
43
- @fibers.delete(rep)
44
- DONE
45
- end
46
-
47
- @fibers[rep]
48
- end
49
- end
50
- end
51
- end
52
- end