Class: Nanoc::Core::Site Private

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/core/site.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Defined Under Namespace

Classes: DuplicateIdentifierError

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

enabled?, included, setup_once, warn_about_performance

Constructor Details

#initialize(config:, code_snippets:, data_source:) ⇒ Site

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Site.



21
22
23
24
25
26
27
28
29
30
# File 'lib/nanoc/core/site.rb', line 21

def initialize(config:, code_snippets:, data_source:)
  @config = config
  @code_snippets = code_snippets
  @data_source = data_source

  @preprocessed = false

  ensure_identifier_uniqueness(@data_source.items, 'item')
  ensure_identifier_uniqueness(@data_source.layouts, 'layout')
end

Instance Attribute Details

#code_snippetsObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



16
17
18
# File 'lib/nanoc/core/site.rb', line 16

def code_snippets
  @code_snippets
end

#configObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



17
18
19
# File 'lib/nanoc/core/site.rb', line 17

def config
  @config
end

#data_sourceObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



18
19
20
# File 'lib/nanoc/core/site.rb', line 18

def data_source
  @data_source
end

Instance Method Details

#ensure_identifier_uniqueness(objects, type) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



58
59
60
61
62
63
64
65
66
67
68
# File 'lib/nanoc/core/site.rb', line 58

def ensure_identifier_uniqueness(objects, type)
  seen = Set.new
  objects.each do |obj|
    if seen.include?(obj.identifier)
      raise DuplicateIdentifierError.new(obj.identifier, type)
    end

    seen << obj.identifier
  end
  self
end

#freezeObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



49
50
51
52
53
54
55
# File 'lib/nanoc/core/site.rb', line 49

def freeze
  config.freeze
  items.freeze
  layouts.freeze
  code_snippets.__nanoc_freeze_recursively
  self
end

#itemsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



40
41
42
# File 'lib/nanoc/core/site.rb', line 40

def items
  @data_source.items
end

#layoutsObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



44
45
46
# File 'lib/nanoc/core/site.rb', line 44

def layouts
  @data_source.layouts
end

#mark_as_preprocessedObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



32
33
34
# File 'lib/nanoc/core/site.rb', line 32

def mark_as_preprocessed
  @preprocessed = true
end

#preprocessed?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


36
37
38
# File 'lib/nanoc/core/site.rb', line 36

def preprocessed?
  @preprocessed
end