Sha256: 3daa85c3f0a163b92ac026dfb6b96aee9c482fa06be6338a8ec16849f342f5b7

Contents?: true

Size: 909 Bytes

Versions: 20

Compression:

Stored size: 909 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'
        infer_automatically pwd
      else
        candidate_path_if_exists candidate_path
      end
    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
          end
        if site_path
          site_path
        else
          raise NoPredefinedWebsiteDirectoryFound
        end
    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
s3_website-1.8.2 lib/s3_website/paths.rb
s3_website-1.8.1 lib/s3_website/paths.rb
s3_website-1.8.0 lib/s3_website/paths.rb
s3_website-1.7.6 lib/s3_website/paths.rb
s3_website-1.7.5 lib/s3_website/paths.rb
s3_website-1.7.4 lib/s3_website/paths.rb
s3_website-1.7.3 lib/s3_website/paths.rb
s3_website-1.7.2 lib/s3_website/paths.rb
s3_website-1.7.1 lib/s3_website/paths.rb
s3_website-1.7.0 lib/s3_website/paths.rb
s3_website-1.6.13 lib/s3_website/paths.rb
s3_website-1.6.12 lib/s3_website/paths.rb
s3_website-1.6.11 lib/s3_website/paths.rb
s3_website-1.6.10 lib/s3_website/paths.rb
s3_website-1.6.9 lib/s3_website/paths.rb
s3_website-1.6.8 lib/s3_website/paths.rb
s3_website-1.6.7 lib/s3_website/paths.rb
s3_website-1.6.6 lib/s3_website/paths.rb
s3_website-1.6.5 lib/s3_website/paths.rb
s3_website-1.6.4 lib/s3_website/paths.rb