Sha256: 93a1116496f9d034260414ae2aaac5257ae625ff5f97a17e354bbfd3b1c8fb55

Contents?: true

Size: 899 Bytes

Versions: 17

Compression:

Stored size: 899 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)
      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

17 entries across 17 versions & 1 rubygems

Version Path
s3_website_monadic-0.0.19 lib/s3_website/paths.rb
s3_website_monadic-0.0.18 lib/s3_website/paths.rb
s3_website_monadic-0.0.16 lib/s3_website/paths.rb
s3_website_monadic-0.0.15 lib/s3_website/paths.rb
s3_website_monadic-0.0.14 lib/s3_website/paths.rb
s3_website_monadic-0.0.13 lib/s3_website/paths.rb
s3_website_monadic-0.0.12 lib/s3_website/paths.rb
s3_website_monadic-0.0.11 lib/s3_website/paths.rb
s3_website_monadic-0.0.9 lib/s3_website/paths.rb
s3_website_monadic-0.0.8 lib/s3_website/paths.rb
s3_website_monadic-0.0.7 lib/s3_website/paths.rb
s3_website_monadic-0.0.6 lib/s3_website/paths.rb
s3_website_monadic-0.0.5 lib/s3_website/paths.rb
s3_website_monadic-0.0.4 lib/s3_website/paths.rb
s3_website_monadic-0.0.3 lib/s3_website/paths.rb
s3_website_monadic-0.0.2 lib/s3_website/paths.rb
s3_website_monadic-0.0.1 lib/s3_website/paths.rb