nanoc-core 4.11.18 → 4.11.23

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: bd4fffaf7813aba1bc2544b16ff1cf801f141a293605c4cd3a4f44d26e6baf02
4
- data.tar.gz: a11c2bd8d095dbfcfddc00628cf2a65115184dee3cbedd3ea956d17ce0551f57
3
+ metadata.gz: 54d0d10c4eecdb49a2507a9bcee39269b3a1e444968732d27a4f3bdafe7ff484
4
+ data.tar.gz: 712ae47087f51a2087f03368b6f8206b4a8e4fc3959e09f5d7412e85862a089b
5
5
  SHA512:
6
- metadata.gz: 26a6cf153b5cb6c2fc0c12e1597ab4a77dd6ff52cf95fa90e9b636f684caf819e883677cfbe3d60a179f2f87c548be5a4f436c56f2e981b2691908163844628a
7
- data.tar.gz: 2b2dcbaf7d2b0c41a7d9558af9b33c3e7eafa5b8986ec230fb31c74c916beb4912872f80ffa63f02eea9558c60f5e4723ee08d71ece1731ae8d107b5e847b990
6
+ metadata.gz: 7dfaad676897abbe8eaca4478993c4e5856338cb2cafa2df1fef19d6919be0c8cc3f8e0f8e8edec318d6fd5bcc43215ff525398250943422b59c6c0d0a48ff17
7
+ data.tar.gz: 260b429bde3ed4c72425410c177b598e9f97239addceff6fecbb42e180c22776377a314c5d7be10e26934431086e2d90134a02d8f0ed8bc0ed01fbffa72a3eba
@@ -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
 
@@ -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
@@ -14,6 +14,7 @@ module Nanoc
14
14
  def initialize
15
15
  @counts = {}
16
16
  @root_dir = Dir.mktmpdir('nanoc')
17
+ @mutex = Mutex.new
17
18
  end
18
19
 
19
20
  # @param [String] prefix A string prefix to include in the temporary
@@ -21,8 +22,11 @@ module Nanoc
21
22
  #
22
23
  # @return [String] A new unused filename
23
24
  def create(prefix)
24
- count = @counts.fetch(prefix, 0)
25
- @counts[prefix] = count + 1
25
+ count = nil
26
+ @mutex.synchronize do
27
+ count = @counts.fetch(prefix, 0)
28
+ @counts[prefix] = count + 1
29
+ end
26
30
 
27
31
  dirname = File.join(@root_dir, prefix)
28
32
  filename = File.join(@root_dir, prefix, count.to_s)
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.11.18'
5
+ VERSION = '4.11.23'
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.18
4
+ version: 4.11.23
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-06-17 00:00:00.000000000 Z
11
+ date: 2021-01-16 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.5
318
+ signing_key:
319
319
  specification_version: 4
320
320
  summary: Core of Nanoc
321
321
  test_files: []