<commit_before>############################################################################
## 
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
## All rights reserved. 
## Contact: Nokia Corporation (<EMAIL>) 
## 
## This file is part of Testability Driver. 
## 
## If you have questions regarding the use of this file, please contact 
## Nokia at <EMAIL> . 
## 
## This library is free software; you can redistribute it and/or 
## modify it under the terms of the GNU Lesser General Public 
## License version 2.1 as published by the Free Software Foundation 
## and appearing in the file LICENSE.LGPL included in the packaging 
## of this file. 
## 
############################################################################

module Kernel

  def warn_caller( message, remove_eval = true )

    # verify that message argument type is correct
    raise TypeError, "wrong argument type #{ message.class } for message (expected String)" unless message.kind_of?( String )

    # verify that remove_eval argument type is correct
    raise TypeError, "wrong argument type #{ remove_eval.class } for remove_eval value (expected TrueClass or FalseClass)" unless [ TrueClass, FalseClass ].include?( remove_eval.class )

    # retrieve caller method, file and line number
    begin

      # remove evals if required
      caller_stack = ( remove_eval == true ? caller.select{ | str | str !~ /^\(eval\)\:/ and str !~ /`eval'$/ } : caller )

      # retrieve filename, line number and method name
      /(.+)\:(\d+)\:in `(.+)'/.match( caller_stack.reverse[ -2 ] )

      # store matches
      file, line, method = $1, $2, $3

    rescue

      # could not retrieve filename, line number and method name
      file, line, method = [ '##', '##', 'unknown' ]

    end 
  
    # print warning to STDOUT
    warn message.gsub( '$1', file ).gsub( '$2', line ).gsub( '$3', method )

  end

end<commit_msg>tdriver#util/common/kernel.rb: fixed Kernel#warn_caller<commit_after>############################################################################
## 
## Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). 
## All rights reserved. 
## Contact: Nokia Corporation (<EMAIL>) 
## 
## This file is part of Testability Driver. 
## 
## If you have questions regarding the use of this file, please contact 
## Nokia at <EMAIL> . 
## 
## This library is free software; you can redistribute it and/or 
## modify it under the terms of the GNU Lesser General Public 
## License version 2.1 as published by the Free Software Foundation 
## and appearing in the file LICENSE.LGPL included in the packaging 
## of this file. 
## 
############################################################################

module Kernel

  def warn_caller( message, remove_eval = true )

    # verify that message argument type is correct
    raise TypeError, "wrong argument type #{ message.class } for message (expected String)" unless message.kind_of?( String )

    # verify that remove_eval argument type is correct
    raise TypeError, "wrong argument type #{ remove_eval.class } for remove evaluate calls value (expected TrueClass or FalseClass)" unless [ TrueClass, FalseClass ].include?( remove_eval.class )

    # retrieve caller method, file and line number
    begin

      # remove evals if required
      caller_stack = ( remove_eval == true ? caller.select{ | str | str !~ /^\(eval\)\:/ and str !~ /`eval'$/ } : caller )

      # retrieve filename, line number and method name
      /^(.+?):(\d+)(?::in `(.*)')?/.match( caller_stack.reverse[ -2 ].to_s )

      # store matches
      file, line, method = $1, $2, $3

    rescue

      # could not retrieve filename, line number and method name
      file, line, method = [ '##', '##', 'unknown' ]

    end 
  
    # print warning to STDOUT
    warn message.gsub( '$1', file.to_s ).gsub( '$2', line.to_s ).gsub( '$3', method.to_s )

  end

end
{'fraction_non_alphanumeric': 0.1873878492694181, 'fraction_numerical': 0.0066649577031530375, 'mean_word_length': 3.569086651053864, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4102469', 'n_tokens_mistral': 1118, 'n_tokens_neox': 1053, 'n_words': 418}