Class: Nanoc::Int::Site Private

Inherits:
Object
  • Object
show all
Includes:
ContractsSupport
Defined in:
lib/nanoc/base/entities/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.

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ContractsSupport

included

Constructor Details

#initialize(config:, code_snippets:, items:, layouts:) ⇒ 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.

Parameters:



13
14
15
16
17
18
19
20
21
# File 'lib/nanoc/base/entities/site.rb', line 13

def initialize(config:, code_snippets:, items:, layouts:)
  @config = config
  @code_snippets = code_snippets
  @items = items
  @layouts = layouts

  ensure_identifier_uniqueness(@items, 'item')
  ensure_identifier_uniqueness(@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.



43
44
45
# File 'lib/nanoc/base/entities/site.rb', line 43

def code_snippets
  @code_snippets
end

#compilerNanoc::Int::Compiler

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 the compiler for this site. Will create a new compiler if none exists yet.

Returns:



39
40
41
# File 'lib/nanoc/base/entities/site.rb', line 39

def compiler
  @compiler
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.



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

def config
  @config
end

#itemsObject (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.



45
46
47
# File 'lib/nanoc/base/entities/site.rb', line 45

def items
  @items
end

#layoutsObject (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.



46
47
48
# File 'lib/nanoc/base/entities/site.rb', line 46

def layouts
  @layouts
end

Instance Method Details

#compilevoid

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.

This method returns an undefined value.

Compiles the site.

Since:

  • 3.2.0



29
30
31
32
# File 'lib/nanoc/base/entities/site.rb', line 29

def compile
  compiler.run_all
  self
end

#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.



61
62
63
64
65
66
67
68
69
70
# File 'lib/nanoc/base/entities/site.rb', line 61

def ensure_identifier_uniqueness(objects, type)
  seen = Set.new
  objects.each do |obj|
    if seen.include?(obj.identifier)
      raise Nanoc::Int::Errors::DuplicateIdentifier.new(obj.identifier, type)
    end
    seen << obj.identifier
  end
  self
end

#freezevoid

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.

This method returns an undefined value.

Prevents all further modifications to itself, its items, its layouts etc.



52
53
54
55
56
57
58
# File 'lib/nanoc/base/entities/site.rb', line 52

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