Sha256: d09b9b721c8af8ff0ed47fe954fa9ee1668f9f1c107316dcbc9a58ed91d48898
Contents?: true
Size: 1.21 KB
Versions: 1
Compression:
Stored size: 1.21 KB
Contents
# frozen_string_literal: true module Jekyll module Imgproxy class Tag class ImgproxyConfig extend Forwardable attr_reader \ :context, :base_url, :key, :salt, :aws_bucket def initialize(context) @context = context @base_url = fetch_config(:base_url) @key = fetch_config(:key) @salt = fetch_config(:salt) @aws_bucket = fetch_config(:aws_bucket) end private def fetch_config(key) check_config! value = imgproxy_config[key.to_s] return ENV[value.gsub(/^ENV_/, '')] if value&.match?(/^ENV_/) value end def check_config! raise Jekyll::Imgproxy::Tag::Errors::ConfigNotFound if imgproxy_config.nil? raise Jekyll::Imgproxy::Tag::Errors::SaltNotSet if imgproxy_config['salt'].nil? raise Jekyll::Imgproxy::Tag::Errors::KeyNotSet if imgproxy_config['key'].nil? raise Jekyll::Imgproxy::Tag::Errors::BaseUrlNotSet if imgproxy_config['base_url'].nil? end def imgproxy_config context['site']['imgproxy'] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
jekyll-imgproxy-tag-0.4.0 | lib/jekyll/imgproxy/tag/imgproxy_config.rb |