lib/nanoc3/base/site.rb in nanoc3-3.1.4 vs lib/nanoc3/base/site.rb in nanoc3-3.1.5

- old
+ new

@@ -342,10 +342,13 @@ raise Nanoc3::Errors::NoMatchingRoutingRuleFound.new(rep) if rule.nil? # Get basic path by applying matching rule basic_path = rule.apply_to(rep) next if basic_path.nil? + if basic_path !~ %r{^/} + raise RuntimeError, "The path returned for the #{rep.inspect} item representation, “#{basic_path}”, does not start with a slash. Please ensure that all routing rules return a path that starts with a slash.".make_compatible_with_env + end # Get raw path by prepending output directory rep.raw_path = self.config[:output_dir] + basic_path # Get normal path by stripping index filename @@ -362,9 +365,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 } @config_mtime = File.stat(config_path).mtime