Sha256: 7cdbfae2dfe6c3ff9ffbb0f7334e00fd99ceead7a81715a40b708cc15a4d192a

Contents?: true

Size: 800 Bytes

Versions: 1

Compression:

Stored size: 800 Bytes

Contents

module S3Website
  class Paths
    def self.site_paths
      [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.
          find do |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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
s3_website-0.3.0 lib/s3_website/paths.rb