nanoc-core 4.13.5 → 4.14.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: 9a6e74deb4968f4bad8e83ccbd91797be60fac35b5ad4b08687b24751bd880fb
4
- data.tar.gz: fd3feca15b92a45617b0dc989f56965822081d83af94cb1d168912c29fd84135
3
+ metadata.gz: 789cc6b4702b215a8124a7fd9e223bbd5ae0ab388100d2825cc0aab1a2871706
4
+ data.tar.gz: 41badc8b04d48a56d08b12394a16677973326c82ff94b61e987c332e27ddcfb5
5
5
  SHA512:
6
- metadata.gz: c97de8904374f0620b01848e71e3de9fd753d507aa1ccf1804e94e9eafdcbe2459f318a6646e41a3b18ca6146c78b84271785de65534ca8e729fead59294afcf
7
- data.tar.gz: d43e488b4139003a08cfe726e4a8c3ef2a588d63b031be816a924623a68f3b37b083ad5e28f5bffeb2bc23bd713d6f4194fe74d72fd534268ccf57b541dc723e
6
+ metadata.gz: 7f65db903bb45e40731a74aff7ed48a9189ed8327e77bc10323a72084e180845fedb2af85b8c4e9f93b1a9b1beb8a9c3b84af562ef89108de994153af7846f79
7
+ data.tar.gz: 68ba69732bf619f3b30a73b4029d08cfe38e2e4451da63517aca1fc6040cf8d2451438c023844b5dc626c3c6da3ab4009bcd8c35bffc2b72599f6fad866a5a6f
@@ -77,29 +77,27 @@ module Nanoc
77
77
  @action_sequences = action_sequences
78
78
 
79
79
  # Memoize
80
- @_outdatedness_status_for = {}
80
+ @_apply_rules = {}
81
81
  end
82
82
 
83
83
  contract C_OBJ_MAYBE_REP => C::Maybe[Nanoc::Core::OutdatednessStatus]
84
84
  def outdatedness_status_for(obj)
85
- # TODO: remove memoization (no longer needed)
86
- @_outdatedness_status_for[obj] ||=
87
- case obj
88
- when Nanoc::Core::ItemRep
89
- apply_rules(RULES_FOR_ITEM_REP, obj)
90
- when Nanoc::Core::Item
91
- apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
92
- when Nanoc::Core::Layout
93
- apply_rules(RULES_FOR_LAYOUT, obj)
94
- when Nanoc::Core::Configuration
95
- apply_rules(RULES_FOR_CONFIG, obj)
96
- when Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection
97
- # Collections are never outdated. Objects inside them might be,
98
- # however.
99
- apply_rules([], obj)
100
- else
101
- raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
102
- end
85
+ case obj
86
+ when Nanoc::Core::ItemRep
87
+ apply_rules(RULES_FOR_ITEM_REP, obj)
88
+ when Nanoc::Core::Item
89
+ apply_rules_multi(RULES_FOR_ITEM_REP, @reps[obj])
90
+ when Nanoc::Core::Layout
91
+ apply_rules(RULES_FOR_LAYOUT, obj)
92
+ when Nanoc::Core::Configuration
93
+ apply_rules(RULES_FOR_CONFIG, obj)
94
+ when Nanoc::Core::ItemCollection, Nanoc::Core::LayoutCollection
95
+ # Collections are never outdated. Objects inside them might be,
96
+ # however.
97
+ apply_rules([], obj)
98
+ else
99
+ raise Nanoc::Core::Errors::InternalInconsistency, "do not know how to check outdatedness of #{obj.inspect}"
100
+ end
103
101
  end
104
102
 
105
103
  def action_sequence_for(rep)
@@ -110,18 +108,19 @@ module Nanoc
110
108
 
111
109
  contract C::ArrayOf[Class], C_OBJ_MAYBE_REP, Nanoc::Core::OutdatednessStatus => C::Maybe[Nanoc::Core::OutdatednessStatus]
112
110
  def apply_rules(rules, obj, status = Nanoc::Core::OutdatednessStatus.new)
113
- rules.inject(status) do |acc, rule|
114
- if acc.useful_to_apply?(rule)
115
- reason = rule.instance.call(obj, self)
116
- if reason
117
- acc.update(reason)
111
+ @_apply_rules[obj] ||=
112
+ rules.inject(status) do |acc, rule|
113
+ if acc.useful_to_apply?(rule)
114
+ reason = rule.instance.call(obj, self)
115
+ if reason
116
+ acc.update(reason)
117
+ else
118
+ acc
119
+ end
118
120
  else
119
121
  acc
120
122
  end
121
- else
122
- acc
123
123
  end
124
- end
125
124
  end
126
125
 
127
126
  contract C::ArrayOf[Class], C::ArrayOf[C_OBJ_MAYBE_REP] => C::Maybe[Nanoc::Core::OutdatednessStatus]
@@ -10,8 +10,8 @@ module Nanoc
10
10
  DONE = Object.new
11
11
 
12
12
  contract Nanoc::Core::ItemRep, C::KeywordArgs[is_outdated: C::Bool], C::Func[C::None => C::Any] => C::Any
13
- def run(rep, is_outdated:, &block)
14
- fiber = fiber_for(rep, is_outdated:, &block)
13
+ def run(rep, is_outdated:, &)
14
+ fiber = fiber_for(rep, is_outdated:, &)
15
15
  while fiber.alive?
16
16
  res = fiber.resume
17
17
 
@@ -29,7 +29,11 @@ module Nanoc
29
29
 
30
30
  # @return [String]
31
31
  def self.config_filename_for_cwd
32
- filenames = %w[nanoc.yaml config.yaml]
32
+ filenames = [
33
+ 'nanoc.yaml',
34
+ 'nanoc.toml',
35
+ 'config.yaml',
36
+ ]
33
37
  candidate = filenames.find { |f| File.file?(f) }
34
38
  candidate && File.expand_path(candidate)
35
39
  end
@@ -54,7 +58,8 @@ module Nanoc
54
58
  end
55
59
 
56
60
  def load_file(filename)
57
- YamlLoader.load_file(filename)
61
+ loader = StructuredDataLoader.for_extension(File.extname(filename))
62
+ loader.load_file(filename)
58
63
  end
59
64
 
60
65
  # @api private
@@ -78,8 +78,8 @@ module Nanoc
78
78
  end
79
79
  end
80
80
 
81
- def contract(*args)
82
- Contract(*args)
81
+ def contract(*)
82
+ Contract(*)
83
83
  end
84
84
  end
85
85
 
@@ -14,24 +14,24 @@ module Nanoc
14
14
  C::Or[
15
15
  C::SetOf[C::Or[String, Regexp]],
16
16
  C::ArrayOf[C::Or[String, Regexp]],
17
- C::Bool
17
+ C::Bool,
18
18
  ]
19
19
 
20
20
  C_ATTR =
21
21
  C::Or[
22
22
  C::SetOf[
23
23
  C::Or[
24
- Symbol, # any value
25
- [Symbol, C::Any] # pair (specific value)
24
+ Symbol, # any value
25
+ [Symbol, C::Any], # pair (specific value)
26
26
  ],
27
27
  ],
28
28
  C::ArrayOf[
29
29
  C::Or[
30
- Symbol, # any value
31
- [Symbol, C::Any] # pair (specific value)
30
+ Symbol, # any value
31
+ [Symbol, C::Any], # pair (specific value)
32
32
  ],
33
33
  ],
34
- C::Bool
34
+ C::Bool,
35
35
  ]
36
36
 
37
37
  C_ARGS =
@@ -39,7 +39,7 @@ module Nanoc
39
39
  raw_content: C::Optional[C_RAW_CONTENT],
40
40
  attributes: C::Optional[C_ATTR],
41
41
  compiled_content: C::Optional[C::Bool],
42
- path: C::Optional[C::Bool]
42
+ path: C::Optional[C::Bool],
43
43
  ]
44
44
 
45
45
  contract C_ARGS => C::Any
@@ -9,14 +9,14 @@ module Nanoc
9
9
  C_RAW_CONTENT =
10
10
  C::Or[
11
11
  C::ArrayOf[C::Or[String, Regexp]],
12
- C::Bool
12
+ C::Bool,
13
13
  ]
14
14
 
15
15
  C_ATTR =
16
16
  C::Or[
17
17
  C::ArrayOf[Symbol],
18
18
  C::HashOf[Symbol => C::Any],
19
- C::Bool
19
+ C::Bool,
20
20
  ]
21
21
 
22
22
  C_KEYWORD_PROPS =
@@ -24,7 +24,7 @@ module Nanoc
24
24
  raw_content: C::Optional[C_RAW_CONTENT],
25
25
  attributes: C::Optional[C_ATTR],
26
26
  compiled_content: C::Optional[C::Bool],
27
- path: C::Optional[C::Bool]
27
+ path: C::Optional[C::Bool],
28
28
  ]
29
29
 
30
30
  C_OBJ_SRC = Nanoc::Core::Item
@@ -34,7 +34,7 @@ module Nanoc
34
34
  Nanoc::Core::Item,
35
35
  Nanoc::Core::Layout,
36
36
  Nanoc::Core::Configuration,
37
- Nanoc::Core::IdentifiableCollection
37
+ Nanoc::Core::IdentifiableCollection,
38
38
  ]
39
39
 
40
40
  attr_reader :items
@@ -11,20 +11,20 @@ module Nanoc
11
11
  Nanoc::Core::Item,
12
12
  Nanoc::Core::Layout,
13
13
  Nanoc::Core::Configuration,
14
- Nanoc::Core::IdentifiableCollection
14
+ Nanoc::Core::IdentifiableCollection,
15
15
  ]
16
16
 
17
17
  C_RAW_CONTENT =
18
18
  C::Or[
19
19
  C::ArrayOf[C::Or[String, Regexp]],
20
- C::Bool
20
+ C::Bool,
21
21
  ]
22
22
 
23
23
  C_ATTR =
24
24
  C::Or[
25
25
  C::ArrayOf[Symbol],
26
26
  C::HashOf[Symbol => C::Any],
27
- C::Bool
27
+ C::Bool,
28
28
  ]
29
29
 
30
30
  C_ARGS =
@@ -32,7 +32,7 @@ module Nanoc
32
32
  raw_content: C::Optional[C_RAW_CONTENT],
33
33
  attributes: C::Optional[C_ATTR],
34
34
  compiled_content: C::Optional[C::Bool],
35
- path: C::Optional[C::Bool]
35
+ path: C::Optional[C::Bool],
36
36
  ]
37
37
 
38
38
  attr_reader :dependency_store
@@ -91,4 +91,4 @@ module Nanoc
91
91
  end
92
92
  end
93
93
 
94
- Nanoc::Core::Feature.define('where', version: '4.13')
94
+ Nanoc::Core::Feature.define('where', version: '4.14')
@@ -23,7 +23,7 @@ module Nanoc
23
23
  @enabled = false
24
24
  end
25
25
 
26
- def self.call(key, *args)
26
+ def self.call(key, *)
27
27
  return yield unless @enabled
28
28
 
29
29
  begin
@@ -32,7 +32,7 @@ module Nanoc
32
32
  yield
33
33
  ensure
34
34
  stopwatch.stop
35
- Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *args)
35
+ Nanoc::Core::NotificationCenter.post(key, stopwatch.duration, *)
36
36
  end
37
37
  end
38
38
  end
@@ -79,8 +79,8 @@ module Nanoc
79
79
  instance.on(name, id, &)
80
80
  end
81
81
 
82
- def post(name, *args)
83
- instance.post(name, *args)
82
+ def post(name, *)
83
+ instance.post(name, *)
84
84
  end
85
85
 
86
86
  def remove(name, id)
@@ -28,7 +28,7 @@ module Nanoc
28
28
  dependency_store: Nanoc::Core::DependencyStore,
29
29
  action_sequence_store: Nanoc::Core::ActionSequenceStore,
30
30
  action_sequences: C_ACTION_SEQUENCES,
31
- reps: Nanoc::Core::ItemRepRepo
31
+ reps: Nanoc::Core::ItemRepRepo,
32
32
  ] => C::Any
33
33
  def initialize(site:, checksum_store:, checksums:, dependency_store:, action_sequence_store:, action_sequences:, reps:)
34
34
  @site = site
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ # @api private
6
+ module StructuredDataLoader
7
+ class UnknownLanguageError < StandardError
8
+ def initialize(lang)
9
+ super("cannot find loader for language: #{lang.inspect}")
10
+ end
11
+ end
12
+
13
+ def self.for_language(language)
14
+ case language
15
+ when :yaml
16
+ YamlLoader
17
+ when :toml
18
+ TomlLoader
19
+ else
20
+ raise UnknownLanguageError.enw(language)
21
+ end
22
+ end
23
+
24
+ def self.for_extension(ext)
25
+ case ext
26
+ when '.yaml'
27
+ YamlLoader
28
+ when '.toml'
29
+ TomlLoader
30
+ else
31
+ raise UnknownLanguageError.enw(language)
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Nanoc
4
+ module Core
5
+ # @api private
6
+ module TomlLoader
7
+ def self.load(string)
8
+ require 'perfect_toml'
9
+ PerfectTOML.parse(string)
10
+ end
11
+
12
+ def self.load_file(filename)
13
+ require 'perfect_toml'
14
+ load(File.read(filename))
15
+ end
16
+ end
17
+ end
18
+ end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.13.5'
5
+ VERSION = '4.14.0'
6
6
  end
7
7
  end
@@ -10,7 +10,7 @@ module Nanoc
10
10
  contract C::Maybe[C::Or[
11
11
  Nanoc::Core::ViewContextForCompilation,
12
12
  Nanoc::Core::ViewContextForPreCompilation,
13
- Nanoc::Core::ViewContextForShell
13
+ Nanoc::Core::ViewContextForShell,
14
14
  ]] => C::Any
15
15
  def initialize(context)
16
16
  @context = context
@@ -11,8 +11,8 @@ module Nanoc
11
11
 
12
12
  private_constant :OPTIONS
13
13
 
14
- def self.load(yaml_string)
15
- YAML.safe_load(yaml_string, **OPTIONS)
14
+ def self.load(string)
15
+ YAML.safe_load(string, **OPTIONS)
16
16
  end
17
17
 
18
18
  def self.load_file(filename)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanoc-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.13.5
4
+ version: 4.14.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
@@ -286,9 +286,11 @@ files:
286
286
  - lib/nanoc/core/snapshot_def.rb
287
287
  - lib/nanoc/core/store.rb
288
288
  - lib/nanoc/core/string_pattern.rb
289
+ - lib/nanoc/core/structured_data_loader.rb
289
290
  - lib/nanoc/core/temp_filename_factory.rb
290
291
  - lib/nanoc/core/textual_compiled_content_cache.rb
291
292
  - lib/nanoc/core/textual_content.rb
293
+ - lib/nanoc/core/toml_loader.rb
292
294
  - lib/nanoc/core/trivial_error.rb
293
295
  - lib/nanoc/core/utils.rb
294
296
  - lib/nanoc/core/version.rb
@@ -302,7 +304,7 @@ licenses:
302
304
  - MIT
303
305
  metadata:
304
306
  rubygems_mfa_required: 'true'
305
- source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.13.5/nanoc-core
307
+ source_code_uri: https://github.com/nanoc/nanoc/tree/nanoc-core-v4.14.0/nanoc-core
306
308
  rdoc_options: []
307
309
  require_paths:
308
310
  - lib
@@ -310,14 +312,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
310
312
  requirements:
311
313
  - - ">="
312
314
  - !ruby/object:Gem::Version
313
- version: '3.1'
315
+ version: '3.2'
314
316
  required_rubygems_version: !ruby/object:Gem::Requirement
315
317
  requirements:
316
318
  - - ">="
317
319
  - !ruby/object:Gem::Version
318
320
  version: '0'
319
321
  requirements: []
320
- rubygems_version: 3.6.7
322
+ rubygems_version: 3.7.2
321
323
  specification_version: 4
322
324
  summary: Core of Nanoc
323
325
  test_files: []