nanoc-core 4.12.2 → 4.12.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c4a5b22f92ecd2425faeae4cbb597dee48846a8507e5c00673478c4146d99b60
4
- data.tar.gz: b384739256cd987cbbdead7820fcfa3b48a0dff9aacbc632b48bdf9daf77305c
3
+ metadata.gz: 3dc7e6692696f6b2b0bbf15a7c5f0aa607af851182de259323b3f18869117ef0
4
+ data.tar.gz: a6964648a0eb41ffbffbda9fd9b18da1f80dd83a1a86d8564aee05f6bd5be16d
5
5
  SHA512:
6
- metadata.gz: 4c06b89e2b6e699c07cf8a3da87755d15b03e05f368a1823eaa31165822dc258221c08048505a23e64cf412cbafda1425eaf2b6a93fee833351bf1f7ed4caa2c
7
- data.tar.gz: a0108e0a31c98c277a5306d55ec0f666b2e87717a9f0355813c5d66a5410392bbc145a4a8a6b13f8fb1be849a1c1275804c9ac53ae60f0e350d33d6dd8a23516
6
+ metadata.gz: 4ee96bf469d44eb81ee815f6adf1439dadcd7efa34fdb9f71c057888ac4b690d799506d24b3fce04d54530deca15deb3564894cd340f519fde93fdeb80295487
7
+ data.tar.gz: cfa697a3471cb5efb04c8d9e7f919c39b399f958b2f20a8232bd6c3d2d5214fd2a3acf4fb4308a4b094cbf02c4bb87ae050379c6a3b0421092101c2576e69432
@@ -36,7 +36,13 @@ module Nanoc
36
36
  # @return [void]
37
37
  def load
38
38
  # rubocop:disable Security/Eval
39
- eval('def self.use_helper(mod); Nanoc::Core::Context.instance_eval { include mod }; end', TOPLEVEL_BINDING)
39
+ eval(<<~CODE, TOPLEVEL_BINDING)
40
+ unless respond_to?(:use_helper)
41
+ def self.use_helper(mod)
42
+ Nanoc::Core::Context.instance_eval { include mod }
43
+ end
44
+ end
45
+ CODE
40
46
  eval(@data, TOPLEVEL_BINDING, @filename)
41
47
  # rubocop:enable Security/Eval
42
48
  nil
@@ -18,15 +18,20 @@ module Nanoc
18
18
  contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
19
19
  def run(rep, is_outdated:)
20
20
  if can_reuse_content_for_rep?(rep, is_outdated: is_outdated)
21
+ # If cached content can be used for this item rep, do so, and skip
22
+ # recalculation of the item rep compiled content.
21
23
  Nanoc::Core::NotificationCenter.post(:cached_content_used, rep)
22
-
23
24
  @compiled_content_store.set_all(rep, @compiled_content_cache[rep])
24
25
  else
26
+ # Cached content couldn’t be used for this rep. Continue as usual with
27
+ # recalculation of the item rep compiled content.
25
28
  yield
29
+
30
+ # Update compiled content cache, now that the item rep is compiled.
31
+ @compiled_content_cache[rep] = @compiled_content_store.get_all(rep)
26
32
  end
27
33
 
28
34
  rep.compiled = true
29
- @compiled_content_cache[rep] = @compiled_content_store.get_all(rep)
30
35
  end
31
36
 
32
37
  contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool] => C::Bool
@@ -19,20 +19,25 @@ module Nanoc
19
19
  def initialize(items, layouts, config)
20
20
  super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'dependencies'), 5)
21
21
 
22
+ @config = config
22
23
  @items = items
23
24
  @layouts = layouts
24
25
 
25
- @refs2objs = {}
26
- items.each { |o| add_vertex_for(o) }
27
- layouts.each { |o| add_vertex_for(o) }
28
- add_vertex_for(config)
29
- add_vertex_for(items)
30
- add_vertex_for(layouts)
26
+ rebuild_refs2objs
31
27
 
32
28
  @new_objects = []
33
29
  @graph = Nanoc::Core::DirectedGraph.new([nil] + objs2refs(@items) + objs2refs(@layouts))
34
30
  end
35
31
 
32
+ def rebuild_refs2objs
33
+ @refs2objs = {}
34
+ @items.each { |o| add_vertex_for(o) }
35
+ @layouts.each { |o| add_vertex_for(o) }
36
+ add_vertex_for(@config)
37
+ add_vertex_for(@items)
38
+ add_vertex_for(@layouts)
39
+ end
40
+
36
41
  contract C_OBJ_SRC => C::ArrayOf[Nanoc::Core::Dependency]
37
42
  def dependencies_causing_outdatedness_of(object)
38
43
  objects_causing_outdatedness_of(object).map do |other_object|
@@ -53,14 +58,12 @@ module Nanoc
53
58
 
54
59
  def items=(items)
55
60
  @items = items
56
- items.each { |o| @refs2objs[obj2ref(o)] = o }
57
- add_vertex_for(items)
61
+ rebuild_refs2objs
58
62
  end
59
63
 
60
64
  def layouts=(layouts)
61
65
  @layouts = layouts
62
- layouts.each { |o| @refs2objs[obj2ref(o)] = o }
63
- add_vertex_for(layouts)
66
+ rebuild_refs2objs
64
67
  end
65
68
 
66
69
  def new_items
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.12.2'
5
+ VERSION = '4.12.3'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.12.2
4
+ version: 4.12.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-05-28 00:00:00.000000000 Z
11
+ date: 2021-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -300,7 +300,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
300
300
  - !ruby/object:Gem::Version
301
301
  version: '0'
302
302
  requirements: []
303
- rubygems_version: 3.2.18
303
+ rubygems_version: 3.2.28
304
304
  signing_key:
305
305
  specification_version: 4
306
306
  summary: Core of Nanoc