<commit_before>module Crosstest
  class Psychic
    module Execution
      class TokenStrategy < DefaultStrategy
        def execute(*extra_args)
          template = File.read(absolute_file)
          # Default token pattern/replacement (used by php-opencloud) should be configurable
          token_handler = Tokens::RegexpTokenHandler.new(template, /'\{(\w+)\}'/, "'\\1'")
          confirm_or_update_parameters(token_handler.tokens)
          content = token_handler.render(script.params)
          temporarily_overwrite(absolute_file, content) do
            super(*extra_args)
          end
        end

        private

        def temporarily_overwrite(file, content)
          backup_file = "#{file}.bak"<commit_msg>Allow TokenHandler to use single or double quotes<commit_after>module Crosstest
  class Psychic
    module Execution
      class TokenStrategy < DefaultStrategy
        def execute(*extra_args)
          template = File.read(absolute_file)
          # Default token pattern/replacement (used by php-opencloud) should be configurable
          token_handler = Tokens::RegexpTokenHandler.new(template, /["']\{(\w+)\}(["'])/, '\2\1\2')
          confirm_or_update_parameters(token_handler.tokens)
          content = token_handler.render(script.params)
          temporarily_overwrite(absolute_file, content) do
            super(*extra_args)
          end
        end

        private

        def temporarily_overwrite(file, content)
          backup_file = "#{file}.bak"
{'fraction_non_alphanumeric': 0.09297658862876254, 'fraction_numerical': 0.0026755852842809363, 'mean_word_length': 2.675675675675676, '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': '4733363', 'n_tokens_mistral': 402, 'n_tokens_neox': 398, 'n_words': 88}