lib/nanoc3/base/source_data/site.rb in nanoc3-3.2.0a2 vs lib/nanoc3/base/source_data/site.rb in nanoc3-3.2.0a3
- old
+ new
@@ -206,28 +206,34 @@
item.parent = parent
parent.children << item
end
end
- # TODO document
+ # Prevents all further modifications to itself, its items, its layouts etc.
#
- # @api private
- def objects
- # FIXME remove reference to rules
- items + layouts + code_snippets + [ config, compiler.rules_with_reference ]
+ # @return [void]
+ def freeze
+ super
+
+ config.freeze
+ items.each { |i| i.freeze }
+ layouts.each { |l| l.freeze }
+ code_snippets.each { |cs| cs.freeze }
end
# @deprecated It is no longer necessary to explicitly load site data. It
# is safe to remove all {#load_data} calls.
def load_data(force=false)
warn 'It is no longer necessary to call Nanoc3::Site#load_data. This method no longer has any effect. All calls to this method can be safely removed.'
end
- private
-
# Loads the site data. It is not necessary to call this method explicitly;
# it will be called when it is necessary.
+ #
+ # @api private
+ #
+ # @return [void]
def load
return if @data_loaded
@data_loaded = true
# Load all data
@@ -241,10 +247,12 @@
# Load compiler too
# FIXME this should not be necessary
compiler.load
end
+ private
+
# Loads this site’s code and executes it.
def load_code_snippets
@code_snippets_loaded ||= false
return if @code_snippets_loaded
@code_snippets_loaded = true
@@ -294,9 +302,14 @@
# Builds the configuration hash based on the given argument. Also see
# {#initialize} for details.
def build_config(dir_or_config_hash)
if dir_or_config_hash.is_a? String
+ # Check whether it is supported
+ if dir_or_config_hash != '.'
+ warn 'WARNING: Calling Nanoc3::Site.new with a directory that is not the current working directory is not supported. It is recommended to change the directory before calling Nanoc3::Site.new. For example, instead of Nanoc3::Site.new(\'abc\'), use Dir.chdir(\'abc\') { Nanoc3::Site.new(\'.\') }.'
+ end
+
# Read config from config.yaml in given dir
config_path = File.join(dir_or_config_hash, 'config.yaml')
@config = DEFAULT_CONFIG.merge(YAML.load_file(config_path).symbolize_keys)
@config[:data_sources].map! { |ds| ds.symbolize_keys }
else