<commit_before>require 'active_record/connection_adapters/abstract/quoting'
require 'ambition/proc_to_ruby'

module Ambition
  class Processor 
    include ActiveRecord::ConnectionAdapters::Quoting

    attr_reader :key, :join_string, :prefix, :includes

    def initialize
      @unsupported = [:alloca, :cfunc, :cref, :evstr, :ifunc, :last, :memo, :newline, :opt_n, :method] # internal nodes that you can't get to
      @includes = []
    end

    ##
    # Processing methods
    def process_proc(exp)
      receiver, body = process(exp.shift), exp.shift
      process(body)
    end

    def process_dasgn_curr(exp)
      @receiver = exp.first
      @receiver.to_s
    end
    alias_method :process_dasgn, :process_dasgn_curr

    def process_array(exp)
      if exp.first.first == :call
        require 'ruby2ruby'
        exp.unshift :array
        value RubyToRuby.new.process(exp)
      else
        arrayed = exp.map { |m| process(m) }
        arrayed.join(', ')
      end
    end

    ##
    # Helper methods
    def to_s
      process(@block.to_sexp).squeeze(' ')
    end

    def value(variable)
      sanitize eval(variable, @block)
    end

    def sanitize(value)
      if value.is_a? Array
        return value.map { |v| sanitize(v) }.join(', ')
      end

      case value
      when true,  'true'  
        '1'
      when false, 'false' 
        '0'
      when Regexp
        "'#{value.source}'"<commit_msg>try to brute-force-figure out if were calling something on ourselves or not<commit_after>require 'active_record/connection_adapters/abstract/quoting'
require 'ambition/proc_to_ruby'

module Ambition
  class Processor 
    include ActiveRecord::ConnectionAdapters::Quoting

    attr_reader :key, :join_string, :prefix, :includes

    def initialize
      @unsupported = [:alloca, :cfunc, :cref, :evstr, :ifunc, :last, :memo, :newline, :opt_n, :method] # internal nodes that you can't get to
      @includes = []
    end

    ##
    # Processing methods
    def process_proc(exp)
      receiver, body = process(exp.shift), exp.shift
      process(body)
    end

    def process_dasgn_curr(exp)
      @receiver = exp.first
      @receiver.to_s
    end
    alias_method :process_dasgn, :process_dasgn_curr

    def process_array(exp)
      if ruby = rubify(exp)
        value ruby
      else
        arrayed = exp.map { |m| process(m) }
        arrayed.join(', ')
      end
    end

    def rubify(exp)
      if exp.first.first == :call && exp.first[1].last != @receiver && Array(exp.first[1][1]).last != @receiver
        require 'ruby2ruby'
        RubyToRuby.new.process(exp.first)
      end
    end

    ##
    # Helper methods
    def to_s
      process(@block.to_sexp).squeeze(' ')
    end

    def value(variable)
      sanitize eval(variable, @block)
    end

    def sanitize(value)
      if value.is_a? Array
        return value.map { |v| sanitize(v) }.join(', ')
      end

      case value
      when true,  'true'  
        '1'
      when false, 'false' 
        '0'
      when Regexp
        "'#{value.source}'"
{'fraction_non_alphanumeric': 0.1123152709359606, 'fraction_numerical': 0.002955665024630542, 'mean_word_length': 2.407158836689038, 'pattern_counts': {'":': 0, '<': 3, '<?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': '6479322', 'n_tokens_mistral': 1035, 'n_tokens_neox': 996, 'n_words': 242}