Sha256: ae7d7915be845a18d61c94508749e9372f22b401a8aebcd0385b8821dbdae785

Contents?: true

Size: 853 Bytes

Versions: 9

Compression:

Stored size: 853 Bytes

Contents

module PictureTag
  module Parsers
    # Handles the specific tag image set to construct.
    class Preset
      attr_reader :name

      def initialize(name)
        @name = name
      end

      def [](key)
        content[key]
      end

      protected

      def content
        @content ||= DEFAULT_PRESET.merge settings
      end

      private

      def settings
        PictureTag.site.data.dig('picture', 'presets', name) ||
          STOCK_PRESETS[name] ||
          no_preset
      end

      def no_preset
        unless name == 'default'
          Utils.warning(
            <<~HEREDOC
              Preset "#{name}" not found in #{PictureTag.config['data_dir']}/picture.yml
              under 'presets' key, or in stock presets. Using default values."
            HEREDOC
          )
        end

        {}
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
jekyll_picture_tag-2.1.2 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.1.1 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.1.0 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.0.4 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.0.3 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.0.2 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.0.1 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.0.0 lib/jekyll_picture_tag/parsers/preset.rb
jekyll_picture_tag-2.0.0pre1 lib/jekyll_picture_tag/parsers/preset.rb