nanoc-core 4.11.19 → 4.12.0

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: a5609a4d82cab318b327443ab017ec28ace7a23f0766176df6e289c7c757138e
4
- data.tar.gz: 4646c4338db2b0fe0a46b0b604205796c154d51c7f5f77c5b59d2031fd806877
3
+ metadata.gz: 3785b5628c2b36382f5c6eed88988943304f6d4e8555a4a72c769b11e8f9a21e
4
+ data.tar.gz: cb562257783d0a0d351822b25c19f9172e134a9910b2fd475ec27a2aa6a13321
5
5
  SHA512:
6
- metadata.gz: d387e1b5fbd4ed31ac03f6eb0510238f4e8e92a615b1c38351fa2e7c1f785e7f2d9ac013c51c48a1f0f6e32a02c8b49d20f9a48e324ed07bc45c054246cdda62
7
- data.tar.gz: 6789e6da893cb64eb032c110f244de514c56143df96c8865b2a2903ffcbbbb2a242c60ee46eca40fb3bb1e77e11c1febdc7ebbe675d428ce9e41e419f5683f0d
6
+ metadata.gz: 5386cce963813faa6c3ac38936b8b2ffce7e3fc94297b5f663a4b8b76df9590e62ee891013abfe665f5f2c06bd14cc754b3c56cbf473b38a079a97eab0e11900
7
+ data.tar.gz: a038f93b08e01ecad024545e97fde14627c1522ed546d6f2cfebdb06f348ad3fdc4fbb2743d8dbe0a658333ba996a91d2f559bbfd8dbd7e5045d35f07b3302ba
data/lib/nanoc/core.rb CHANGED
@@ -20,6 +20,13 @@ require 'tomlrb'
20
20
  require 'tty-platform'
21
21
  require 'zeitwerk'
22
22
 
23
+ # External gems (optional)
24
+ begin
25
+ require 'clonefile'
26
+ rescue LoadError
27
+ # ignore
28
+ end
29
+
23
30
  module Nanoc
24
31
  module Core
25
32
  # Similar to `nil` except that it can only be compared against using
@@ -32,7 +39,7 @@ module Nanoc
32
39
  #
33
40
  # @api private
34
41
  def self.version_information
35
- "Nanoc #{Nanoc::VERSION} © 2007–2019 Denis Defreyne.\n" \
42
+ "Nanoc #{Nanoc::VERSION} © 2007–2021 Denis Defreyne.\n" \
36
43
  "Running #{RUBY_ENGINE} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} with RubyGems #{Gem::VERSION}.\n"
37
44
  end
38
45
 
@@ -70,14 +77,6 @@ require_relative 'core/core_ext/array'
70
77
  require_relative 'core/core_ext/hash'
71
78
  require_relative 'core/core_ext/string'
72
79
 
73
- # Tracking issue:
74
- # https://github.com/nanoc/features/issues/24
75
- Nanoc::Core::Feature.define('live_cmd', version: '4.11')
76
-
77
80
  # Tracking issue:
78
81
  # https://github.com/nanoc/features/issues/40
79
- Nanoc::Core::Feature.define('toml', version: '4.11')
80
-
81
- # Tracking issue:
82
- # https://github.com/nanoc/features/issues/20
83
- Nanoc::Core::Feature.define('binary_compiled_content_cache', version: '4.11')
82
+ Nanoc::Core::Feature.define('toml', version: '4.12')
@@ -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,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
@@ -96,7 +96,8 @@ module Nanoc
96
96
  false
97
97
  end
98
98
 
99
- @_contracts_support__should_enable = contracts_loadable && !ENV.key?('DISABLE_CONTRACTS')
99
+ # FIXME: Do something better with contracts on Ruby 3.x
100
+ @_contracts_support__should_enable = contracts_loadable && !RUBY_VERSION.start_with?('3') && !ENV.key?('DISABLE_CONTRACTS')
100
101
 
101
102
  if @_contracts_support__should_enable
102
103
  # FIXME: ugly
@@ -62,11 +62,7 @@ module Nanoc
62
62
 
63
63
  # Write
64
64
  if is_modified
65
- begin
66
- FileUtils.ln(temp_path, raw_path, force: true)
67
- rescue Errno::EXDEV, Errno::EACCES
68
- FileUtils.cp(temp_path, raw_path)
69
- end
65
+ smart_cp(temp_path, raw_path)
70
66
  end
71
67
 
72
68
  item_rep.modified = is_modified
@@ -80,6 +76,28 @@ module Nanoc
80
76
  def temp_filename
81
77
  Nanoc::Core::TempFilenameFactory.instance.create(TMP_TEXT_ITEMS_DIR)
82
78
  end
79
+
80
+ def smart_cp(from, to)
81
+ # Try clonefile
82
+ if defined?(Clonefile)
83
+ FileUtils.rm_f(to)
84
+ begin
85
+ res = Clonefile.always(from, to)
86
+ return if res
87
+ rescue Clonefile::UnsupportedPlatform, Errno::ENOTSUP, Errno::EXDEV, Errno::EINVAL
88
+ end
89
+ end
90
+
91
+ # Try with hardlink
92
+ begin
93
+ FileUtils.ln(from, to, force: true)
94
+ return
95
+ rescue Errno::EXDEV, Errno::EACCES
96
+ end
97
+
98
+ # Fall back to old-school copy
99
+ FileUtils.cp(from, to)
100
+ end
83
101
  end
84
102
  end
85
103
  end
@@ -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.19'
5
+ VERSION = '4.12.0'
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.11.19
4
+ version: 4.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-10-16 00:00:00.000000000 Z
11
+ date: 2021-02-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -299,23 +299,23 @@ homepage: https://nanoc.ws/
299
299
  licenses:
300
300
  - MIT
301
301
  metadata: {}
302
- post_install_message:
302
+ post_install_message:
303
303
  rdoc_options: []
304
304
  require_paths:
305
305
  - lib
306
306
  required_ruby_version: !ruby/object:Gem::Requirement
307
307
  requirements:
308
- - - "~>"
308
+ - - ">="
309
309
  - !ruby/object:Gem::Version
310
- version: '2.4'
310
+ version: '2.5'
311
311
  required_rubygems_version: !ruby/object:Gem::Requirement
312
312
  requirements:
313
313
  - - ">="
314
314
  - !ruby/object:Gem::Version
315
315
  version: '0'
316
316
  requirements: []
317
- rubygems_version: 3.1.4
318
- signing_key:
317
+ rubygems_version: 3.2.11
318
+ signing_key:
319
319
  specification_version: 4
320
320
  summary: Core of Nanoc
321
321
  test_files: []