<commit_before>require 'multi_json'

module JsonYamlAssets

  class Engine < ::Rails::Engine

    config.json_yaml_assets = ActiveSupport::OrderedOptions.new

    class Template < Tilt::Template

      class << self
        attr_accessor :global_options
      end

      def prepare
      end

      def evaluate(scope, locals = { }, &block)
        if /.json.ya?ml(?:$|\.)/.match(file)
          @output ||= MultiJson.dump(YAML.load(data),
                                     Template.global_options.clone)
        else
          data
        end
      end
    end

    initializer('sprockets.json_yaml_assets',
                :group => :all,
                :after => 'sprockets.environment') do |app|
      next unless app.assets
      app.assets.register_engine '.yaml', Template
      app.assets.register_engine '.yml', Template
      Template.global_options = app.config.json_yaml_assets
    end
  end
end<commit_msg>Register only extension '.jsonyaml' in order to avoid the confusion of actual YAML<commit_after>require 'multi_json'

module JsonYamlAssets

  class Engine < ::Rails::Engine

    config.json_yaml_assets = ActiveSupport::OrderedOptions.new

    class Template < Tilt::Template

      class << self
        attr_accessor :global_options
      end

      def prepare
      end

      def evaluate(scope, locals = { }, &block)
        @output ||= MultiJson.dump(YAML.load(data),
                                   Template.global_options.clone)
      end
    end

    initializer('sprockets.json_yaml_assets',
                :group => :all,
                :after => 'sprockets.environment') do |app|
      next unless app.assets
      app.assets.register_engine '.jsonyaml', Template
      Template.global_options = app.config.json_yaml_assets
    end
  end
end
{'fraction_non_alphanumeric': 0.09473094170403587, 'fraction_numerical': 0.0, 'mean_word_length': 2.1989247311827955, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '99961', 'n_tokens_mistral': 521, 'n_tokens_neox': 497, 'n_words': 113}