<commit_before>require 'pry'

module Adhearsion
  module Console
    include Adhearsion

    class << self
      ##
      # Start the Adhearsion console
      #
      def run
        Pry.prompt = [ proc { |obj, nest_level, pry_instance = nil| "AHN#{'  ' * nest_level}> " },
                       proc { |obj, nest_level, pry_instance = nil| "AHN#{'  ' * nest_level}? " } ]
        Pry.config.command_prefix = "%"
        pry
      end

      def logger
        Adhearsion::Logging
      end

      def calls
        Adhearsion.active_calls
      end

      def use(call)
        unless call.is_a? Adhearsion::Call
          raise ArgumentError unless Adhearsion.active_calls[call]
          call = Adhearsion.active_calls[call]
        end
        Pry.prompt = [ proc { "AHN<#{call.channel}> "},
                       proc { "AHN<#{call.channel}? "}  ]

        # Pause execution of the thread currently controlling the call
        call.with_command_lock do
          CallWrapper.new(call).pry
        end
      end
    end

    class CallWrapper<commit_msg>[BUGFIX] Fix console incompatibility w/ Ruby 1.8.7<commit_after>require 'pry'

module Adhearsion
  module Console
    include Adhearsion

    class << self
      ##
      # Start the Adhearsion console
      #
      def run
        Pry.prompt = [
                        proc do |*args|
                          obj, nest_level, pry_instance = args
                          "AHN#{'  ' * nest_level}> "
                        end,
                        proc do |*args|
                          obj, nest_level, pry_instance = args
                          "AHN#{'  ' * nest_level}? "
                        end
                      ]
        Pry.config.command_prefix = "%"
        pry
      end

      def logger
        Adhearsion::Logging
      end

      def calls
        Adhearsion.active_calls
      end

      def use(call)
        unless call.is_a? Adhearsion::Call
          raise ArgumentError unless Adhearsion.active_calls[call]
          call = Adhearsion.active_calls[call]
        end
        Pry.prompt = [ proc { "AHN<#{call.channel}> "},
                       proc { "AHN<#{call.channel}? "}  ]

        # Pause execution of the thread currently controlling the call
        call.with_command_lock do
          CallWrapper.new(call).pry
        end
      end
    end

    class CallWrapper
{'fraction_non_alphanumeric': 0.08620689655172414, 'fraction_numerical': 0.001261564339781329, 'mean_word_length': 1.470404984423676, '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': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5077417', 'n_tokens_mistral': 717, 'n_tokens_neox': 697, 'n_words': 163}