Class: Nanoc::Core::Site Private
- Inherits:
-
Object
- Object
- Nanoc::Core::Site
- 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
- #code_snippets ⇒ Object readonly private
- #config ⇒ Object readonly private
- #data_source ⇒ Object private
Instance Method Summary collapse
- #ensure_identifier_uniqueness(objects, type) ⇒ Object private
- #freeze ⇒ Object private
-
#initialize(config:, code_snippets:, data_source:) ⇒ Site
constructor
private
A new instance of Site.
- #items ⇒ Object private
- #layouts ⇒ Object private
- #mark_as_preprocessed ⇒ Object private
- #preprocessed? ⇒ Boolean private
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.
26 27 28 29 30 31 32 33 34 35 |
# File 'lib/nanoc/core/site.rb', line 26 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_snippets ⇒ Object (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.
18 19 20 |
# File 'lib/nanoc/core/site.rb', line 18 def code_snippets @code_snippets end |
#config ⇒ Object (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.
19 20 21 |
# File 'lib/nanoc/core/site.rb', line 19 def config @config end |
#data_source ⇒ 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.
20 21 22 |
# File 'lib/nanoc/core/site.rb', line 20 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.
64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/nanoc/core/site.rb', line 64 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 |
#freeze ⇒ 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.
54 55 56 57 58 59 60 |
# File 'lib/nanoc/core/site.rb', line 54 def freeze config.freeze items.freeze layouts.freeze code_snippets.__nanoc_freeze_recursively self end |
#items ⇒ 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.
45 46 47 |
# File 'lib/nanoc/core/site.rb', line 45 def items @data_source.items end |
#layouts ⇒ 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.
49 50 51 |
# File 'lib/nanoc/core/site.rb', line 49 def layouts @data_source.layouts end |
#mark_as_preprocessed ⇒ 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.
37 38 39 |
# File 'lib/nanoc/core/site.rb', line 37 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.
41 42 43 |
# File 'lib/nanoc/core/site.rb', line 41 def preprocessed? @preprocessed end |