Sha256: d00c59cb56f62b88f4d64af5b5b831d6bb12bd05a46431b7898e601a8099eb33

Contents?: true

Size: 983 Bytes

Versions: 24

Compression:

Stored size: 983 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
    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
          end
        if site_path
          site_path
        else
          raise NoPredefinedWebsiteDirectoryFound
        end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
s3_website-1.6.3 lib/s3_website/paths.rb
s3_website-1.6.2 lib/s3_website/paths.rb
s3_website-1.6.1 lib/s3_website/paths.rb
s3_website-1.6.0 lib/s3_website/paths.rb
s3_website-1.5.0 lib/s3_website/paths.rb
s3_website-1.4.5 lib/s3_website/paths.rb
s3_website-1.4.4 lib/s3_website/paths.rb
s3_website-1.4.3 lib/s3_website/paths.rb
s3_website-1.4.2 lib/s3_website/paths.rb
s3_website-1.4.1 lib/s3_website/paths.rb
s3_website-1.4.0 lib/s3_website/paths.rb
s3_website-1.3.2 lib/s3_website/paths.rb
s3_website-1.3.1 lib/s3_website/paths.rb
s3_website-1.3.0 lib/s3_website/paths.rb
s3_website-1.2.1 lib/s3_website/paths.rb
s3_website-1.2.0 lib/s3_website/paths.rb
s3_website-1.1.2 lib/s3_website/paths.rb
s3_website-1.1.1 lib/s3_website/paths.rb
s3_website-1.1.0 lib/s3_website/paths.rb
s3_website-1.0.3 lib/s3_website/paths.rb