nanoc-core 4.11.18 → 4.11.23
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/nanoc/core.rb +8 -1
- data/lib/nanoc/core/contracts_support.rb +2 -1
- data/lib/nanoc/core/item_rep_writer.rb +23 -5
- data/lib/nanoc/core/temp_filename_factory.rb +6 -2
- data/lib/nanoc/core/version.rb +1 -1
- metadata +8 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 54d0d10c4eecdb49a2507a9bcee39269b3a1e444968732d27a4f3bdafe7ff484
|
4
|
+
data.tar.gz: 712ae47087f51a2087f03368b6f8206b4a8e4fc3959e09f5d7412e85862a089b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7dfaad676897abbe8eaca4478993c4e5856338cb2cafa2df1fef19d6919be0c8cc3f8e0f8e8edec318d6fd5bcc43215ff525398250943422b59c6c0d0a48ff17
|
7
|
+
data.tar.gz: 260b429bde3ed4c72425410c177b598e9f97239addceff6fecbb42e180c22776377a314c5d7be10e26934431086e2d90134a02d8f0ed8bc0ed01fbffa72a3eba
|
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–
|
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
|
-
|
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
|
-
|
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 =
|
25
|
-
@
|
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)
|
data/lib/nanoc/core/version.rb
CHANGED
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.
|
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:
|
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.
|
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.
|
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: []
|