nanoc-core 4.12.14 → 4.12.16

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: f6002d238861027abd84a4b7499c56f95be1e8bf3dec412eb21051c91c11fcce
4
- data.tar.gz: 3788262a93f33920e549372a34d5fcacc4a2c6d120d3acf1562499eaaaca0cfb
3
+ metadata.gz: 504696dcd7c11b5e8b4c960c59888723781485ed7059bb9a39cd8538f17ed6b0
4
+ data.tar.gz: aa3660ab2fd38cb60575d224f47525aab6dca804dbfbeb0d056b0c8e0fee5df7
5
5
  SHA512:
6
- metadata.gz: 869cddca22933872511ec0b10d7a09c9d37ff3dd89de4340f88b2d6fcceee725779d0c0dd9e891f2c28e2a25adb6f7a909f378537d8d88bd5a4f128fc76b86de
7
- data.tar.gz: 208bd267925b4d51df67bd0293fe6f903671089f4899c529fc63cc8d5ecd0130c434662211b2e232e115bb532a2234301c6c44e5b74fff4acfc74e93288d703d
6
+ metadata.gz: 6fc2dd2a837e71c286ec441ecd67199782d5498026b8670f61f0ba3e216be08ce65857a2d09921770e193621fa6da72aa4c755d357efaffc6837f4f23ccc8fdc
7
+ data.tar.gz: b0db461960d33ff772a1831688c140595edd58a531fc2f3b506924cc46c1b4a7792bfad74f41930eae9d2aedf08be0ea24066747e5e891bfa37207813b8e7d91
@@ -61,7 +61,7 @@ module Nanoc
61
61
 
62
62
  private
63
63
 
64
- def update(obj, digest, visited = Hamster::Set.new)
64
+ def update(obj, digest, visited = Immutable::Set.new)
65
65
  digest.update(obj.class.to_s)
66
66
 
67
67
  if visited.include?(obj)
@@ -276,11 +276,15 @@ module Nanoc
276
276
 
277
277
  class RescueUpdateBehavior < UpdateBehavior
278
278
  def self.update(obj, digest)
279
+ # rubocop:disable Style/ClassEqualityComparison
280
+ # This Rubocop rule is disabled because the class
281
+ # itself might not be loaded (yet).
279
282
  if obj.class.to_s == 'Sass::Importers::Filesystem'
280
283
  digest.update('root=')
281
284
  digest.update(obj.root)
282
285
  return
283
286
  end
287
+ # rubocop:enable Style/ClassEqualityComparison
284
288
 
285
289
  data =
286
290
  begin
@@ -5,6 +5,16 @@ module Nanoc
5
5
  class Compiler
6
6
  include Nanoc::Core::ContractsSupport
7
7
 
8
+ contract Nanoc::Core::Site => C::Any
9
+ def self.compile(site)
10
+ new_for(site).run_until_end
11
+ end
12
+
13
+ contract Nanoc::Core::Site => Nanoc::Core::Compiler
14
+ def self.new_for(site)
15
+ Nanoc::Core::CompilerLoader.new.load(site)
16
+ end
17
+
8
18
  def initialize(site, compiled_content_cache:, checksum_store:, action_sequence_store:, action_provider:, dependency_store:, outdatedness_store:)
9
19
  @site = site
10
20
 
@@ -21,16 +31,6 @@ module Nanoc
21
31
  @compiled_content_store = Nanoc::Core::CompiledContentStore.new
22
32
  end
23
33
 
24
- contract Nanoc::Core::Site => C::Any
25
- def self.compile(site)
26
- new_for(site).run_until_end
27
- end
28
-
29
- contract Nanoc::Core::Site => Nanoc::Core::Compiler
30
- def self.new_for(site)
31
- Nanoc::Core::CompilerLoader.new.load(site)
32
- end
33
-
34
34
  def run_until_preprocessed
35
35
  @_res_preprocessed ||= begin
36
36
  preprocess_stage.call
@@ -5,6 +5,19 @@ module Nanoc
5
5
  class Content
6
6
  include Nanoc::Core::ContractsSupport
7
7
 
8
+ contract C::Or[self, String, Proc], C::KeywordArgs[binary: C::Optional[C::Bool], filename: C::Optional[C::Maybe[String]]] => self
9
+ def self.create(content, binary: false, filename: nil)
10
+ if content.nil?
11
+ raise ArgumentError, 'Cannot create nil content'
12
+ elsif content.is_a?(Nanoc::Core::Content)
13
+ content
14
+ elsif binary
15
+ Nanoc::Core::BinaryContent.new(content)
16
+ else
17
+ Nanoc::Core::TextualContent.new(content, filename: filename)
18
+ end
19
+ end
20
+
8
21
  contract C::None => C::Maybe[String]
9
22
  attr_reader :filename
10
23
 
@@ -24,19 +37,6 @@ module Nanoc
24
37
  self
25
38
  end
26
39
 
27
- contract C::Or[self, String, Proc], C::KeywordArgs[binary: C::Optional[C::Bool], filename: C::Optional[C::Maybe[String]]] => self
28
- def self.create(content, binary: false, filename: nil)
29
- if content.nil?
30
- raise ArgumentError, 'Cannot create nil content'
31
- elsif content.is_a?(Nanoc::Core::Content)
32
- content
33
- elsif binary
34
- Nanoc::Core::BinaryContent.new(content)
35
- else
36
- Nanoc::Core::TextualContent.new(content, filename: filename)
37
- end
38
- end
39
-
40
40
  contract C::None => C::Bool
41
41
  def binary?
42
42
  raise NotImplementedError
@@ -20,7 +20,7 @@ module Nanoc
20
20
  # contract C::Or[Hash, C::Named['Nanoc::Core::Configuration']], C::IterOf[C::RespondTo[:identifier]], C::Maybe[String] => C::Any
21
21
  def initialize_basic(config, objects = [], name = nil)
22
22
  @config = config
23
- @objects = Hamster::Vector.new(objects)
23
+ @objects = Immutable::Vector.new(objects)
24
24
  @name = name
25
25
  end
26
26
 
@@ -164,7 +164,7 @@ module Nanoc
164
164
  end
165
165
 
166
166
  s = File.extname(@string)
167
- s && s[1..-1]
167
+ s && s[1..]
168
168
  end
169
169
 
170
170
  contract C::None => String
@@ -195,7 +195,7 @@ module Nanoc
195
195
  if res.empty?
196
196
  []
197
197
  else
198
- res[1..-1]
198
+ res[1..]
199
199
  end
200
200
  end
201
201
 
@@ -6,6 +6,13 @@ module Nanoc
6
6
  def reference
7
7
  @_reference ||= "item:#{identifier}"
8
8
  end
9
+
10
+ def identifier=(new_identifier)
11
+ super(new_identifier)
12
+
13
+ # Invalidate memoization cache
14
+ @_reference = nil
15
+ end
9
16
  end
10
17
  end
11
18
  end
@@ -6,6 +6,25 @@ module Nanoc
6
6
  class ItemRepBuilder
7
7
  include Nanoc::Core::ContractsSupport
8
8
 
9
+ contract Nanoc::Core::ActionSequence, Nanoc::Core::ItemRep => C::ArrayOf[Nanoc::Core::SnapshotDef]
10
+ def self.snapshot_defs_for(action_sequence, rep)
11
+ is_binary = rep.item.content.binary?
12
+ snapshot_defs = []
13
+
14
+ action_sequence.each do |action|
15
+ case action
16
+ when Nanoc::Core::ProcessingActions::Snapshot
17
+ action.snapshot_names.each do |snapshot_name|
18
+ snapshot_defs << Nanoc::Core::SnapshotDef.new(snapshot_name, binary: is_binary)
19
+ end
20
+ when Nanoc::Core::ProcessingActions::Filter
21
+ is_binary = Nanoc::Core::Filter.named!(action.filter_name).to_binary?
22
+ end
23
+ end
24
+
25
+ snapshot_defs
26
+ end
27
+
9
28
  attr_reader :reps
10
29
 
11
30
  contract Nanoc::Core::Site, Nanoc::Core::ActionProvider, Nanoc::Core::ItemRepRepo => C::Any
@@ -30,25 +49,6 @@ module Nanoc
30
49
 
31
50
  action_sequences
32
51
  end
33
-
34
- contract Nanoc::Core::ActionSequence, Nanoc::Core::ItemRep => C::ArrayOf[Nanoc::Core::SnapshotDef]
35
- def self.snapshot_defs_for(action_sequence, rep)
36
- is_binary = rep.item.content.binary?
37
- snapshot_defs = []
38
-
39
- action_sequence.each do |action|
40
- case action
41
- when Nanoc::Core::ProcessingActions::Snapshot
42
- action.snapshot_names.each do |snapshot_name|
43
- snapshot_defs << Nanoc::Core::SnapshotDef.new(snapshot_name, binary: is_binary)
44
- end
45
- when Nanoc::Core::ProcessingActions::Filter
46
- is_binary = Nanoc::Core::Filter.named!(action.filter_name).to_binary?
47
- end
48
- end
49
-
50
- snapshot_defs
51
- end
52
52
  end
53
53
  end
54
54
  end
@@ -6,6 +6,13 @@ module Nanoc
6
6
  def reference
7
7
  @_reference ||= "layout:#{identifier}"
8
8
  end
9
+
10
+ def identifier=(new_identifier)
11
+ super(new_identifier)
12
+
13
+ # Invalidate memoization cache
14
+ @_reference = nil
15
+ end
9
16
  end
10
17
  end
11
18
  end
@@ -80,8 +80,8 @@ module Nanoc
80
80
  )
81
81
  end
82
82
 
83
- contract C_OBJ, Hamster::Set => C::Bool
84
- def outdated_due_to_dependencies?(obj, processed = Hamster::Set.new)
83
+ contract C_OBJ, Immutable::Set => C::Bool
84
+ def outdated_due_to_dependencies?(obj, processed = Immutable::Set.new)
85
85
  # Convert from rep to item if necessary
86
86
  obj = obj.item if obj.is_a?(Nanoc::Core::ItemRep)
87
87
 
@@ -168,7 +168,7 @@ module Nanoc
168
168
  # outdatedness.
169
169
  matching_objects.any? do |obj|
170
170
  status = basic_outdatedness_statuses.fetch(obj)
171
- status.reasons.any? { |r| Nanoc::Core::OutdatednessReasons::DocumentAdded == r }
171
+ status.reasons.any? { |r| r == Nanoc::Core::OutdatednessReasons::DocumentAdded }
172
172
  end
173
173
  end
174
174
 
@@ -7,19 +7,16 @@ module Nanoc
7
7
  include Nanoc::Core::ContractsSupport
8
8
  include Singleton
9
9
 
10
- def call(obj, outdatedness_checker)
11
- Nanoc::Core::Instrumentor.call(:outdatedness_rule_ran, self.class) do
12
- apply(obj, outdatedness_checker)
13
- end
10
+ def self.affects_path?
11
+ @affects_path
14
12
  end
15
13
 
16
- def apply(_obj, _outdatedness_checker)
17
- raise NotImplementedError.new('Nanoc::Core::OutdatednessRule subclasses must implement #apply')
14
+ def self.affects_attributes?
15
+ @affects_attributes
18
16
  end
19
17
 
20
- contract C::None => String
21
- def inspect
22
- "#{self.class.name}(#{reason})"
18
+ def self.affects_compiled_content?
19
+ @affects_compiled_content
23
20
  end
24
21
 
25
22
  def self.affects_props(*names)
@@ -46,16 +43,19 @@ module Nanoc
46
43
  @affects_raw_content
47
44
  end
48
45
 
49
- def self.affects_attributes?
50
- @affects_attributes
46
+ def call(obj, outdatedness_checker)
47
+ Nanoc::Core::Instrumentor.call(:outdatedness_rule_ran, self.class) do
48
+ apply(obj, outdatedness_checker)
49
+ end
51
50
  end
52
51
 
53
- def self.affects_compiled_content?
54
- @affects_compiled_content
52
+ def apply(_obj, _outdatedness_checker)
53
+ raise NotImplementedError.new('Nanoc::Core::OutdatednessRule subclasses must implement #apply')
55
54
  end
56
55
 
57
- def self.affects_path?
58
- @affects_path
56
+ contract C::None => String
57
+ def inspect
58
+ "#{self.class.name}(#{reason})"
59
59
  end
60
60
  end
61
61
  end
@@ -15,7 +15,7 @@ module Nanoc
15
15
  format(
16
16
  '<%s %s>',
17
17
  self.class.to_s,
18
- serialize[1..-1].map(&:inspect).join(', '),
18
+ serialize[1..].map(&:inspect).join(', '),
19
19
  )
20
20
  end
21
21
  end
@@ -34,7 +34,7 @@ module Nanoc
34
34
  contract String => String
35
35
  def strip_output_dir(filename)
36
36
  if filename.start_with?(@config.output_dir)
37
- filename[@config.output_dir.size..-1]
37
+ filename[@config.output_dir.size..]
38
38
  else
39
39
  filename
40
40
  end
@@ -4,16 +4,15 @@ module Nanoc
4
4
  module Core
5
5
  class SiteLoader
6
6
  ENCODING_REGEX = /\A#\s+(-\*-\s+)?(en)?coding: (?<encoding>[^\s]+)(\s+-\*-\s*)?\n{0,2}/.freeze
7
-
8
- def new_from_cwd
9
- site_from_config(Nanoc::Core::ConfigLoader.new.new_from_cwd)
10
- end
11
-
12
7
  # @return [Boolean]
13
8
  def self.cwd_is_nanoc_site?
14
9
  Nanoc::Core::ConfigLoader.cwd_is_nanoc_site?
15
10
  end
16
11
 
12
+ def new_from_cwd
13
+ site_from_config(Nanoc::Core::ConfigLoader.new.new_from_cwd)
14
+ end
15
+
17
16
  def gen_data_source_for_config(config)
18
17
  data_sources_to_aggregate =
19
18
  with_data_sources(config) do |data_sources|
@@ -13,6 +13,22 @@ module Nanoc
13
13
  class Store
14
14
  include Nanoc::Core::ContractsSupport
15
15
 
16
+ # Logic for building tmp path from active environment and store name
17
+ # @api private
18
+ contract C::KeywordArgs[config: Nanoc::Core::Configuration, store_name: String] => C::AbsolutePathString
19
+ def self.tmp_path_for(store_name:, config:)
20
+ File.absolute_path(
21
+ File.join(tmp_path_prefix(config.output_dir), store_name),
22
+ config.dir,
23
+ )
24
+ end
25
+
26
+ contract String => String
27
+ def self.tmp_path_prefix(output_dir)
28
+ dir = Digest::SHA1.hexdigest(output_dir)[0..12]
29
+ File.join('tmp', 'nanoc', dir)
30
+ end
31
+
16
32
  # @return [String] The name of the file where data will be loaded from and
17
33
  # stored to.
18
34
  attr_reader :filename
@@ -35,22 +51,6 @@ module Nanoc
35
51
  @version = version
36
52
  end
37
53
 
38
- # Logic for building tmp path from active environment and store name
39
- # @api private
40
- contract C::KeywordArgs[config: Nanoc::Core::Configuration, store_name: String] => C::AbsolutePathString
41
- def self.tmp_path_for(store_name:, config:)
42
- File.absolute_path(
43
- File.join(tmp_path_prefix(config.output_dir), store_name),
44
- config.dir,
45
- )
46
- end
47
-
48
- contract String => String
49
- def self.tmp_path_prefix(output_dir)
50
- dir = Digest::SHA1.hexdigest(output_dir)[0..12]
51
- File.join('tmp', 'nanoc', dir)
52
- end
53
-
54
54
  # @group Loading and storing data
55
55
 
56
56
  # @return The data that should be written to the disk
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Nanoc
4
4
  module Core
5
- VERSION = '4.12.14'
5
+ VERSION = '4.12.16'
6
6
  end
7
7
  end
data/lib/nanoc/core.rb CHANGED
@@ -14,7 +14,7 @@ require 'concurrent-ruby'
14
14
  require 'json_schema'
15
15
  require 'ddmetrics'
16
16
  require 'ddplugin'
17
- require 'hamster'
17
+ require 'immutable'
18
18
  require 'memo_wise'
19
19
  require 'slow_enumerator_tools'
20
20
  require 'tty-platform'
@@ -47,7 +47,7 @@ module Nanoc
47
47
  #
48
48
  # @api private
49
49
  def self.version_information
50
- "Nanoc #{Nanoc::VERSION} © 2007–2022 Denis Defreyne.\n" \
50
+ "Nanoc #{Nanoc::VERSION} © 2007–… Denis Defreyne.\n" \
51
51
  "Running #{RUBY_ENGINE} #{RUBY_VERSION} (#{RUBY_RELEASE_DATE}) on #{RUBY_PLATFORM} with RubyGems #{Gem::VERSION}.\n"
52
52
  end
53
53
 
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.12.14
4
+ version: 4.12.16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Defreyne
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-12-03 00:00:00.000000000 Z
11
+ date: 2023-06-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: concurrent-ruby
@@ -53,19 +53,19 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: '1.0'
55
55
  - !ruby/object:Gem::Dependency
56
- name: hamster
56
+ name: immutable-ruby
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
59
  - - "~>"
60
60
  - !ruby/object:Gem::Version
61
- version: '3.0'
61
+ version: '0.1'
62
62
  type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
66
  - - "~>"
67
67
  - !ruby/object:Gem::Version
68
- version: '3.0'
68
+ version: '0.1'
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: json_schema
71
71
  requirement: !ruby/object:Gem::Requirement
@@ -316,7 +316,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
316
316
  - !ruby/object:Gem::Version
317
317
  version: '0'
318
318
  requirements: []
319
- rubygems_version: 3.4.0.dev
319
+ rubygems_version: 3.4.14
320
320
  signing_key:
321
321
  specification_version: 4
322
322
  summary: Core of Nanoc