Sha256: a5e5e19bd2fba75cc00d928408b857c09be878d1d9614929f72bdd07b2173fd3

Contents?: true

Size: 990 Bytes

Versions: 1

Compression:

Stored size: 990 Bytes

Contents

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

      class << self
        def parse(raw_options)
          options = {
            :attributes => {},
            :filters    => {},
            :flags      => {}
          }
          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
          ALLOWED_FLAGS.each do |key|
            options[:flags][key.to_sym] = true if raw_options.include?(key)
          end
          options
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
jekyll-maps-1.1.5 lib/jekyll-maps/options_parser.rb