<commit_before>module TinyMCE
  # The base module we include into ActionController::Base
  module Base
    # When this module is included, extend it with the available class methods
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      # The controller declaration to enable tiny_mce on certain actions.
      # Takes options hash, raw_options string, and any normal params you
      # can send to a before_filter (only, except etc)
      def uses_tiny_mce(options = {})
        tiny_mce_options = options.delete(:options) || {}
        raw_tiny_mce_options = options.delete(:raw_options) || ''

        # Allow users to have default options in config/tiny_mce.yml so that
        # they do not need to specify the same options over all controllers
        tiny_mce_yaml_filepath = File.join(RAILS_ROOT, 'config', 'tiny_mce.yml')
        if File.exist?(tiny_mce_yaml_filepath)
          yaml_options = YAML::load(IO.read(tiny_mce_yaml_filepath)) rescue Hash.new
          tiny_mce_options = yaml_options.merge(tiny_mce_options)
        end

        # If the tiny_mce plugins includes the spellchecker, then form a spellchecking path,
        # add it to the tiny_mce_options, and include the SpellChecking module
        if !tiny_mce_options[:plugins].blank? && tiny_mce_options[:plugins].include?('spellchecker')
          tiny_mce_options.reverse_merge!(:spellchecker_rpc_url => "/" + self.controller_name + "/spellchecker")
          self.class_eval do
            include TinyMCE::SpellChecker
          end
        end

        # Set instance vars in the current class
        proc = Proc.new do |c|
          c.instance_variable_set(:@tiny_mce_options, tiny_mce_options)<commit_msg>Only merge yaml_options if the YAML::load returned a result<commit_after>module TinyMCE
  # The base module we include into ActionController::Base
  module Base
    # When this module is included, extend it with the available class methods
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      # The controller declaration to enable tiny_mce on certain actions.
      # Takes options hash, raw_options string, and any normal params you
      # can send to a before_filter (only, except etc)
      def uses_tiny_mce(options = {})
        tiny_mce_options = options.delete(:options) || {}
        raw_tiny_mce_options = options.delete(:raw_options) || ''

        # Allow users to have default options in config/tiny_mce.yml so that
        # they do not need to specify the same options over all controllers
        tiny_mce_yaml_filepath = File.join(RAILS_ROOT, 'config', 'tiny_mce.yml')
        if File.exist?(tiny_mce_yaml_filepath)
          yaml_options = YAML::load(IO.read(tiny_mce_yaml_filepath)) rescue Hash.new
          tiny_mce_options = yaml_options.merge(tiny_mce_options) if yaml_options
        end

        # If the tiny_mce plugins includes the spellchecker, then form a spellchecking path,
        # add it to the tiny_mce_options, and include the SpellChecking module
        if !tiny_mce_options[:plugins].blank? && tiny_mce_options[:plugins].include?('spellchecker')
          tiny_mce_options.reverse_merge!(:spellchecker_rpc_url => "/" + self.controller_name + "/spellchecker")
          self.class_eval do
            include TinyMCE::SpellChecker
          end
        end

        # Set instance vars in the current class
        proc = Proc.new do |c|
          c.instance_variable_set(:@tiny_mce_options, tiny_mce_options)
{'fraction_non_alphanumeric': 0.07426303854875284, 'fraction_numerical': 0.0, 'mean_word_length': 3.127485380116959, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '311895', 'n_tokens_mistral': 1037, 'n_tokens_neox': 1016, 'n_words': 297}