<commit_before>require 'image_optim'

class ImageOptim
  class Railtie < Rails::Railtie
    initializer 'image_optim.initializer' do |app|
      if app.config.assets.compress != false && app.config.assets.image_optim != false && app.assets

        image_optim = if app.config.assets.image_optim == true
                        ImageOptim.new
                      else
                        ImageOptim.new(app.config.assets.image_optim || {})
                      end

        processor = proc do |context, data|
          image_optim.optimize_image_data(data) || data
        end

        app.assets.register_preprocessor 'image/gif', :image_optim, &processor
        app.assets.register_preprocessor 'image/jpeg', :image_optim, &processor
        app.assets.register_preprocessor 'image/png', :image_optim, &processor
        app.assets.register_preprocessor 'image/svg+xml', :image_optim, &processor

      end
    end
  end
end
<commit_msg>separate getting options in railtie<commit_after>require 'image_optim'

class ImageOptim
  class Railtie < Rails::Railtie
    initializer 'image_optim.initializer' do |app|
      if app.config.assets.compress != false && app.config.assets.image_optim != false && app.assets

        options = if app.config.assets.image_optim == true
          {}
        else
          app.config.assets.image_optim || {}
        end

        image_optim = ImageOptim.new(options)

        processor = proc do |context, data|
          image_optim.optimize_image_data(data) || data
        end

        app.assets.register_preprocessor 'image/gif', :image_optim, &processor
        app.assets.register_preprocessor 'image/jpeg', :image_optim, &processor
        app.assets.register_preprocessor 'image/png', :image_optim, &processor
        app.assets.register_preprocessor 'image/svg+xml', :image_optim, &processor

      end
    end
  end
end

{'fraction_non_alphanumeric': 0.09802876931273309, 'fraction_numerical': 0.0, 'mean_word_length': 2.6115384615384616, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 2}, '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': '5494283', 'n_tokens_mistral': 547, 'n_tokens_neox': 524, 'n_words': 111}