nanoc-core 4.11.23 → 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: 54d0d10c4eecdb49a2507a9bcee39269b3a1e444968732d27a4f3bdafe7ff484
4
- data.tar.gz: 712ae47087f51a2087f03368b6f8206b4a8e4fc3959e09f5d7412e85862a089b
3
+ metadata.gz: 3dc7e6692696f6b2b0bbf15a7c5f0aa607af851182de259323b3f18869117ef0
4
+ data.tar.gz: a6964648a0eb41ffbffbda9fd9b18da1f80dd83a1a86d8564aee05f6bd5be16d
5
5
  SHA512:
6
- metadata.gz: 7dfaad676897abbe8eaca4478993c4e5856338cb2cafa2df1fef19d6919be0c8cc3f8e0f8e8edec318d6fd5bcc43215ff525398250943422b59c6c0d0a48ff17
7
- data.tar.gz: 260b429bde3ed4c72425410c177b598e9f97239addceff6fecbb42e180c22776377a314c5d7be10e26934431086e2d90134a02d8f0ed8bc0ed01fbffa72a3eba
6
+ metadata.gz: 4ee96bf469d44eb81ee815f6adf1439dadcd7efa34fdb9f71c057888ac4b690d799506d24b3fce04d54530deca15deb3564894cd340f519fde93fdeb80295487
7
+ data.tar.gz: cfa697a3471cb5efb04c8d9e7f919c39b399f958b2f20a8232bd6c3d2d5214fd2a3acf4fb4308a4b094cbf02c4bb87ae050379c6a3b0421092101c2576e69432
@@ -11,7 +11,7 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'binary_content'), 1)
14
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'binary_content'), 2)
15
15
 
16
16
  @cache = {}
17
17
  end
@@ -49,6 +49,11 @@ module Nanoc
49
49
  rep_cache = @cache[rep.item.identifier][rep.name]
50
50
 
51
51
  content.each do |snapshot, binary_content|
52
+ # Check
53
+ if Nanoc::Core::ContractsSupport.enabled? && !File.file?(binary_content.filename)
54
+ raise Nanoc::Core::Errors::InternalInconsistency, "Binary content at #{binary_content.filename.inspect} does not exist, but is expected to."
55
+ end
56
+
52
57
  filename = build_filename(rep, snapshot)
53
58
  rep_cache[snapshot] = filename
54
59
 
@@ -57,12 +62,8 @@ module Nanoc
57
62
  next if binary_content.filename == filename
58
63
 
59
64
  # Copy
60
- #
61
- # NOTE: hardlinking is not an option in this case, because hardlinking
62
- # would make it possible for the content to be (inadvertently)
63
- # changed outside of Nanoc.
64
65
  FileUtils.mkdir_p(File.dirname(filename))
65
- FileUtils.cp(binary_content.filename, filename)
66
+ smart_cp(binary_content.filename, filename)
66
67
  end
67
68
  end
68
69
 
@@ -123,6 +124,26 @@ module Nanoc
123
124
  string_to_path_component(snapshot_name.to_s),
124
125
  )
125
126
  end
127
+
128
+ # NOTE: Similar to ItemRepWriter#smart_cp (but without hardlinking)
129
+ def smart_cp(from, to)
130
+ # NOTE: hardlinking is not an option in this case, because hardlinking
131
+ # would make it possible for the content to be (inadvertently)
132
+ # changed outside of Nanoc.
133
+
134
+ # Try clonefile
135
+ if defined?(Clonefile)
136
+ FileUtils.rm_f(to)
137
+ begin
138
+ res = Clonefile.always(from, to)
139
+ return if res
140
+ rescue Clonefile::UnsupportedPlatform, Errno::ENOTSUP, Errno::EXDEV, Errno::EINVAL
141
+ end
142
+ end
143
+
144
+ # Fall back to old-school copy
145
+ FileUtils.cp(from, to)
146
+ end
126
147
  end
127
148
  end
128
149
  end
@@ -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
@@ -34,7 +34,7 @@ module Nanoc
34
34
  if res
35
35
  start = Time.now
36
36
  sleep 0.05 until File.file?(res) || Time.now - start > FILE_APPEAR_TIMEOUT
37
- raise Nanoc::Core::Errors::InternalInconsistency, "File did not apear in time: #{res}" unless File.file?(res)
37
+ raise Nanoc::Core::Errors::InternalInconsistency, "File raw_path did not appear in time (#{FILE_APPEAR_TIMEOUT}s): #{res}" unless File.file?(res)
38
38
  end
39
39
 
40
40
  res
@@ -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
@@ -36,12 +36,7 @@ module Nanoc
36
36
  end
37
37
 
38
38
  def compiled_content_cache_class
39
- feature_name = Nanoc::Core::Feature::BINARY_COMPILED_CONTENT_CACHE
40
- if Nanoc::Core::Feature.enabled?(feature_name)
41
- Nanoc::Core::CompiledContentCache
42
- else
43
- Nanoc::Core::TextualCompiledContentCache
44
- end
39
+ Nanoc::Core::CompiledContentCache
45
40
  end
46
41
  end
47
42
  end
@@ -29,12 +29,7 @@ module Nanoc
29
29
 
30
30
  # @return [String]
31
31
  def self.config_filename_for_cwd
32
- filenames =
33
- if Nanoc::Core::Feature.enabled?(Nanoc::Core::Feature::TOML)
34
- %w[nanoc.yaml config.yaml nanoc.toml]
35
- else
36
- %w[nanoc.yaml config.yaml]
37
- end
32
+ filenames = %w[nanoc.yaml config.yaml]
38
33
  candidate = filenames.find { |f| File.file?(f) }
39
34
  candidate && File.expand_path(candidate)
40
35
  end
@@ -59,14 +54,7 @@ module Nanoc
59
54
  end
60
55
 
61
56
  def load_file(filename)
62
- case File.extname(filename)
63
- when '.yaml'
64
- YAML.load_file(filename)
65
- when '.toml'
66
- Tomlrb.load_file(filename)
67
- else
68
- raise Nanoc::Core::Errors::InternalInconsistency, 'Unhandled config file extension'
69
- end
57
+ YAML.load_file(filename)
70
58
  end
71
59
 
72
60
  # @api private
@@ -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
@@ -11,7 +11,7 @@ module Nanoc
11
11
 
12
12
  contract C::KeywordArgs[config: Nanoc::Core::Configuration] => C::Any
13
13
  def initialize(config:)
14
- super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'compiled_content'), 2)
14
+ super(Nanoc::Core::Store.tmp_path_for(config: config, store_name: 'compiled_content'), 3)
15
15
 
16
16
  @cache = {}
17
17
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.11.23'
5
+ VERSION = '4.12.3'
6
6
  end
7
7
  end
data/lib/nanoc/core.rb CHANGED
@@ -16,7 +16,6 @@ require 'ddmetrics'
16
16
  require 'ddplugin'
17
17
  require 'hamster'
18
18
  require 'slow_enumerator_tools'
19
- require 'tomlrb'
20
19
  require 'tty-platform'
21
20
  require 'zeitwerk'
22
21
 
@@ -76,15 +75,3 @@ loader.eager_load
76
75
  require_relative 'core/core_ext/array'
77
76
  require_relative 'core/core_ext/hash'
78
77
  require_relative 'core/core_ext/string'
79
-
80
- # Tracking issue:
81
- # https://github.com/nanoc/features/issues/24
82
- Nanoc::Core::Feature.define('live_cmd', version: '4.11')
83
-
84
- # Tracking issue:
85
- # https://github.com/nanoc/features/issues/40
86
- Nanoc::Core::Feature.define('toml', version: '4.11')
87
-
88
- # Tracking issue:
89
- # https://github.com/nanoc/features/issues/20
90
- Nanoc::Core::Feature.define('binary_compiled_content_cache', version: '4.11')
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.11.23
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-01-16 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
@@ -108,20 +108,6 @@ dependencies:
108
108
  - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '1.0'
111
- - !ruby/object:Gem::Dependency
112
- name: tomlrb
113
- requirement: !ruby/object:Gem::Requirement
114
- requirements:
115
- - - "~>"
116
- - !ruby/object:Gem::Version
117
- version: '1.2'
118
- type: :runtime
119
- prerelease: false
120
- version_requirements: !ruby/object:Gem::Requirement
121
- requirements:
122
- - - "~>"
123
- - !ruby/object:Gem::Version
124
- version: '1.2'
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: tty-platform
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -307,14 +293,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
307
293
  requirements:
308
294
  - - ">="
309
295
  - !ruby/object:Gem::Version
310
- version: '2.5'
296
+ version: '2.6'
311
297
  required_rubygems_version: !ruby/object:Gem::Requirement
312
298
  requirements:
313
299
  - - ">="
314
300
  - !ruby/object:Gem::Version
315
301
  version: '0'
316
302
  requirements: []
317
- rubygems_version: 3.2.5
303
+ rubygems_version: 3.2.28
318
304
  signing_key:
319
305
  specification_version: 4
320
306
  summary: Core of Nanoc