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.
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_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.
16 17 18 |
# File 'lib/nanoc/core/site.rb', line 16 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.
17 18 19 |
# File 'lib/nanoc/core/site.rb', line 17 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.
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 |
#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.
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 |
#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.
40 41 42 |
# File 'lib/nanoc/core/site.rb', line 40 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.
44 45 46 |
# File 'lib/nanoc/core/site.rb', line 44 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.
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.
36 37 38 |
# File 'lib/nanoc/core/site.rb', line 36 def preprocessed? @preprocessed end |