Sha256: 1900cc34cb726d1a86b1de59ed5416593d3f2aa064c31a1221ee6f648130664d

Contents?: true

Size: 731 Bytes

Versions: 2

Compression:

Stored size: 731 Bytes

Contents

module Jekyll
  module Maps
    class OptionsParser
      OPTIONS_SYNTAX     = %r!([^\s]+)\s*:\s*([^\s]+)!
      ALLOWED_ATTRIBUTES = %w(
        id
        width
        height
        class
      ).freeze

      class << self
        def parse(raw_options)
          options = {
            :attributes => {},
            :filters    => {}
          }
          raw_options.scan(OPTIONS_SYNTAX).each do |key, value|
            value = value.split(",") if value.include?(",")
            if ALLOWED_ATTRIBUTES.include?(key)
              options[:attributes][key.to_sym] = value
            else
              options[:filters][key] = value
            end
          end
          options
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-maps-1.1.1 lib/jekyll-maps/options_parser.rb
jekyll-maps-1.1.0 lib/jekyll-maps/options_parser.rb