nanoc-core 4.11.20 → 4.12.1

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: ac94fc2464196846d4d6b38fb9a3ee02d0566aaa16f4f192e63f7989af937dc0
4
- data.tar.gz: 0ba05d8ccb6d2cb10a8ec2909bb9bd99dee5203272c24cd02fdc6c6d4041dd17
3
+ metadata.gz: 4967bb5538d055185b3c646d4364f75e01e63a337592b63b1df8896b011b1423
4
+ data.tar.gz: 472af023ca27a5f7a2f09c54ff43c978c83a4d0f86c265e52f75b5e0dc1c7beb
5
5
  SHA512:
6
- metadata.gz: b76254a60ba5cc2d94f0dc6a01498b51fa22c068ba6ee93c6434cee1105a29922f664c08090b155b18a9016b065fb854f60dc38a57f2effa6b1a6a1c1d94aeee
7
- data.tar.gz: 314da571f7e0b49544152e66dc1bc9b30ae49911b0f8aeaf863d23731294ffe33e7b21977a2238f619396119ab6b7a635453e80544ccaf0193e7a94495d34313
6
+ metadata.gz: a8cac018340546cc2950bbf3821df4f54be6e50c94eb91e07baa0aeafdc06f899438eb78d5b7f7cd5691c023230415a705bc7b69bcb70ca4621cd411c09d0d69
7
+ data.tar.gz: 6a56360bd58b3f779e86be59188e453a8f4add7b6626d4ae9f0c3624436fefd7c1ca5fc7836f7f566974c992ae0c67a3acd869eecbd9a31dfc8cf94bd75ee7c3
data/lib/nanoc/core.rb CHANGED
@@ -9,7 +9,6 @@ require 'tmpdir'
9
9
  require 'yaml'
10
10
 
11
11
  # External gems
12
- require 'clonefile'
13
12
  require 'concurrent-ruby'
14
13
  require 'json_schema'
15
14
  require 'ddmemoize'
@@ -17,10 +16,16 @@ require 'ddmetrics'
17
16
  require 'ddplugin'
18
17
  require 'hamster'
19
18
  require 'slow_enumerator_tools'
20
- require 'tomlrb'
21
19
  require 'tty-platform'
22
20
  require 'zeitwerk'
23
21
 
22
+ # External gems (optional)
23
+ begin
24
+ require 'clonefile'
25
+ rescue LoadError
26
+ # ignore
27
+ end
28
+
24
29
  module Nanoc
25
30
  module Core
26
31
  # Similar to `nil` except that it can only be compared against using
@@ -33,7 +38,7 @@ module Nanoc
33
38
  #
34
39
  # @api private
35
40
  def self.version_information
36
- "Nanoc #{Nanoc::VERSION} © 2007–2019 Denis Defreyne.\n" \
41
+ "Nanoc #{Nanoc::VERSION} © 2007–2021 Denis Defreyne.\n" \
37
42
  "Running #{RUBY_ENGINE} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} with RubyGems #{Gem::VERSION}.\n"
38
43
  end
39
44
 
@@ -70,15 +75,3 @@ loader.eager_load
70
75
  require_relative 'core/core_ext/array'
71
76
  require_relative 'core/core_ext/hash'
72
77
  require_relative 'core/core_ext/string'
73
-
74
- # Tracking issue:
75
- # https://github.com/nanoc/features/issues/24
76
- Nanoc::Core::Feature.define('live_cmd', version: '4.11')
77
-
78
- # Tracking issue:
79
- # https://github.com/nanoc/features/issues/40
80
- Nanoc::Core::Feature.define('toml', version: '4.11')
81
-
82
- # Tracking issue:
83
- # https://github.com/nanoc/features/issues/20
84
- Nanoc::Core::Feature.define('binary_compiled_content_cache', version: '4.11')
@@ -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
@@ -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
@@ -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
@@ -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
@@ -79,11 +79,13 @@ module Nanoc
79
79
 
80
80
  def smart_cp(from, to)
81
81
  # Try clonefile
82
- FileUtils.rm_f(to)
83
- begin
84
- res = Clonefile.always(from, to)
85
- return if res
86
- rescue Clonefile::UnsupportedPlatform, Errno::ENOTSUP, Errno::EXDEV, Errno::EINVAL
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
87
89
  end
88
90
 
89
91
  # Try with hardlink
@@ -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.20'
5
+ VERSION = '4.12.1'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,29 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.11.20
4
+ version: 4.12.1
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-12-18 00:00:00.000000000 Z
11
+ date: 2021-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: clonefile
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: 0.5.2
20
- type: :runtime
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - "~>"
25
- - !ruby/object:Gem::Version
26
- version: 0.5.2
27
13
  - !ruby/object:Gem::Dependency
28
14
  name: concurrent-ruby
29
15
  requirement: !ruby/object:Gem::Requirement
@@ -122,20 +108,6 @@ dependencies:
122
108
  - - "~>"
123
109
  - !ruby/object:Gem::Version
124
110
  version: '1.0'
125
- - !ruby/object:Gem::Dependency
126
- name: tomlrb
127
- requirement: !ruby/object:Gem::Requirement
128
- requirements:
129
- - - "~>"
130
- - !ruby/object:Gem::Version
131
- version: '1.2'
132
- type: :runtime
133
- prerelease: false
134
- version_requirements: !ruby/object:Gem::Requirement
135
- requirements:
136
- - - "~>"
137
- - !ruby/object:Gem::Version
138
- version: '1.2'
139
111
  - !ruby/object:Gem::Dependency
140
112
  name: tty-platform
141
113
  requirement: !ruby/object:Gem::Requirement
@@ -313,23 +285,23 @@ homepage: https://nanoc.ws/
313
285
  licenses:
314
286
  - MIT
315
287
  metadata: {}
316
- post_install_message:
288
+ post_install_message:
317
289
  rdoc_options: []
318
290
  require_paths:
319
291
  - lib
320
292
  required_ruby_version: !ruby/object:Gem::Requirement
321
293
  requirements:
322
- - - "~>"
294
+ - - ">="
323
295
  - !ruby/object:Gem::Version
324
- version: '2.4'
296
+ version: '2.5'
325
297
  required_rubygems_version: !ruby/object:Gem::Requirement
326
298
  requirements:
327
299
  - - ">="
328
300
  - !ruby/object:Gem::Version
329
301
  version: '0'
330
302
  requirements: []
331
- rubygems_version: 3.2.2
332
- signing_key:
303
+ rubygems_version: 3.2.15
304
+ signing_key:
333
305
  specification_version: 4
334
306
  summary: Core of Nanoc
335
307
  test_files: []