Sha256: b9d6c5a81b3c35e16843139f985caae5bc0b6bd485094a285365aa89d4a9cd86

Contents?: true

Size: 956 Bytes

Versions: 10

Compression:

Stored size: 956 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
          puts "Could not find a website directory. Specify one with the --site parameter."
          exit
        end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
s3_website_monadic-0.0.29 lib/s3_website/paths.rb
s3_website_monadic-0.0.28 lib/s3_website/paths.rb
s3_website_monadic-0.0.27 lib/s3_website/paths.rb
s3_website_monadic-0.0.26 lib/s3_website/paths.rb
s3_website_monadic-0.0.25 lib/s3_website/paths.rb
s3_website_monadic-0.0.24 lib/s3_website/paths.rb
s3_website_monadic-0.0.23 lib/s3_website/paths.rb
s3_website_monadic-0.0.22 lib/s3_website/paths.rb
s3_website_monadic-0.0.21 lib/s3_website/paths.rb
s3_website_monadic-0.0.20 lib/s3_website/paths.rb