<commit_before>module Middleman
  module GeoPattern
    # Extension namespace
    class Extension < ::Middleman::Extension
      option :default_patterns, nil, 'Which patterns should be used'
      option :default_color, nil, 'The color to use'
      option :default_base_color, nil, 'The base color to use'
      option :html_tag, :div, 'Tag to generate'

      def initialize(app, options_hash = {}, &block)
        # Call super to build options from the options_hash
        super

        require 'geo_pattern'

        # set up your extension
        # puts options.my_option
      end

      def after_configuration
        # Do something
      end

      # A Sitemap Manipulator
      # def manipulate_resource_list(resources)
      # end

      helpers do
        # Generate the geo pattern
        #
        # @param [#to_s] input
        #   The input used to generate the pattern
        #
        # @param [Array, Symbol) patterns
        #   The patterns which are allowed to generate
        #
        # @param [String] color
        #   The color to use for the background of the pattern. You can either
        #   use "color" or "base_color".
        #
        # @param [String] base_color
        #   The base_color to use for the background of the pattern. You can
        #   either "use color" or "base_color".
        #
        # @param [Hash] options
        #   All other options are passed on to the tag helper
        #
        # rubocop:disable Metrics/MethodLength
        def geo_pattern(
          input,
          patterns: extensions[:geo_pattern].options.default_patterns,
          color: extensions[:geo_pattern].options.default_color,
          base_color: extensions[:geo_pattern].options.default_base_color,
          **options,
          &block
        )
          pattern = ::GeoPattern.generate(
            input,
            patterns: patterns,
            color: color,
            base_color: base_color
          )

          style = format('background-image: %s', pattern.to_data_uri)
          style += options.delete(:style) if options[:style]

          content_tag(
            extensions[:geo_pattern].options.html_tag.to_sym,
            nil,
            style: style,
            **options,
            &block
          )
        end<commit_msg>Change order to make user options appear before generated background-image<commit_after>module Middleman
  module GeoPattern
    # Extension namespace
    class Extension < ::Middleman::Extension
      option :default_patterns, nil, 'Which patterns should be used'
      option :default_color, nil, 'The color to use'
      option :default_base_color, nil, 'The base color to use'
      option :html_tag, :div, 'Tag to generate'

      def initialize(app, options_hash = {}, &block)
        # Call super to build options from the options_hash
        super

        require 'geo_pattern'

        # set up your extension
        # puts options.my_option
      end

      def after_configuration
        # Do something
      end

      # A Sitemap Manipulator
      # def manipulate_resource_list(resources)
      # end

      helpers do
        # Generate the geo pattern
        #
        # @param [#to_s] input
        #   The input used to generate the pattern
        #
        # @param [Array, Symbol) patterns
        #   The patterns which are allowed to generate
        #
        # @param [String] color
        #   The color to use for the background of the pattern. You can either
        #   use "color" or "base_color".
        #
        # @param [String] base_color
        #   The base_color to use for the background of the pattern. You can
        #   either "use color" or "base_color".
        #
        # @param [Hash] options
        #   All other options are passed on to the tag helper
        #
        # rubocop:disable Metrics/MethodLength
        def geo_pattern(
          input,
          patterns: extensions[:geo_pattern].options.default_patterns,
          color: extensions[:geo_pattern].options.default_color,
          base_color: extensions[:geo_pattern].options.default_base_color,
          **options,
          &block
        )
          pattern = ::GeoPattern.generate(
            input,
            patterns: patterns,
            color: color,
            base_color: base_color
          )

          style = format('background-image: %s', pattern.to_data_uri)
          style += options.delete(:style) if options[:style]

          content_tag(
            extensions[:geo_pattern].options.html_tag.to_sym,
            nil,
            **options,
            style: style,
            &block
          )
        end
{'fraction_non_alphanumeric': 0.07576733204550333, 'fraction_numerical': 0.0, 'mean_word_length': 1.8641671788567917, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6704473', 'n_tokens_mistral': 1228, 'n_tokens_neox': 1203, 'n_words': 386}