lib/s3_website/paths.rb in s3_website-0.3.0 vs lib/s3_website/paths.rb in s3_website-0.4.0
- old
+ new
@@ -4,29 +4,39 @@
[Nanoc::SITE_PATH, Jekyll::SITE_PATH]
end
def self.infer_site_path(candidate_path, pwd = Dir.pwd)
if candidate_path == 'infer automatically'
- site_path = site_paths.
- map do |site_path|
- pwd + '/' + site_path
- end.
+ infer_automatically pwd
+ else
+ candidate_path_if_exists candidate_path
+ end
+ rescue NoWebsiteDirectoryFound => e
+ puts e.message
+ exit 1
+ end
+
+ private
+
+ def self.candidate_path_if_exists(candidate_path)
+ raise NoWebsiteDirectoryFound.new(
+ "Can't find a website in " + candidate_path
+ ) unless File.exists? candidate_path
+ candidate_path
+ end
+
+ def self.infer_automatically(pwd)
+ site_path = site_paths.
+ map do |site_path|
+ pwd + '/' + site_path
+ end.
find do |site_path|
- File.exists? site_path
+ File.exists? site_path
end
if site_path
site_path
else
raise NoPredefinedWebsiteDirectoryFound
end
- else
- raise NoWebsiteDirectoryFound.new(
- "Can't find a website in " + candidate_path
- ) unless File.exists? candidate_path
- candidate_path
- end
- rescue NoWebsiteDirectoryFound => e
- puts e.message
- exit 1
end
end
end