<commit_before>$:.unshift File.dirname(__FILE__)

require 'rubygems'
require 'ruby-debug'
require 'messenger/errors'
require 'system_timer'


module Messenger

  MESSAGER_VERSION = [0,1] unless defined?(MESSAGER_VERSION)
  APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(APP_ROOT)

  def self.version
    MESSAGER_VERSION.join(".")
  end

  def self.root
    APP_ROOT
  end


  def self.valid_url?(url)
    service_handler = handler(url)
    service_handler.valid_url?(url)
  rescue ProtocolError
    false
  end

  def self.send(url, message, options={})
    service_handler = handler(url)
    SystemTimer.timeout_after(options[:timeout] || 15) do
      service_handler.send(url, message, options)
    end
  end

  def self.obfuscate(url)
    service_handler = handler(url)
    service_handler.obfuscate(url)
  end


  def self.protocol(url)
    # TODO: More services
    #   sms://1231231234
    #   twitter://username
    #   aim://username
    case url
    when /^mailto/:   :email
    when /^http/:     :http
    when /^campfire/: :campfire
    when /^jabber/:   :jabber
    end
  end

  def self.handler(url)
    case protocol(url)
    when :email:    Email
    when :http:     Web
    when :campfire: Campfire
    when :jabber:   Jabber
    else
      raise ProtocolError, "Malformed service URL: #{url}. Either this syntax is wrong or this service type is not yet implemented."
    end
  end


  autoload :Result, "messenger/result"
  autoload :Email, "messenger/email"
  autoload :Web, "messenger/web"
  autoload :Campfire, "messenger/campfire"
  autoload :Jabber, "messenger/jabber"

end
<commit_msg>Not requiring ruby-debug.<commit_after>$:.unshift File.dirname(__FILE__)

require 'rubygems'
require 'messenger/errors'
require 'system_timer'


module Messenger

  MESSAGER_VERSION = [0,1] unless defined?(MESSAGER_VERSION)
  APP_ROOT = File.expand_path(File.dirname(__FILE__) + '/..') unless defined?(APP_ROOT)

  def self.version
    MESSAGER_VERSION.join(".")
  end

  def self.root
    APP_ROOT
  end


  def self.valid_url?(url)
    service_handler = handler(url)
    service_handler.valid_url?(url)
  rescue ProtocolError
    false
  end

  def self.send(url, message, options={})
    service_handler = handler(url)
    SystemTimer.timeout_after(options[:timeout] || 15) do
      service_handler.send(url, message, options)
    end
  end

  def self.obfuscate(url)
    service_handler = handler(url)
    service_handler.obfuscate(url)
  end


  def self.protocol(url)
    # TODO: More services
    #   sms://1231231234
    #   twitter://username
    #   aim://username
    case url
    when /^mailto/:   :email
    when /^http/:     :http
    when /^campfire/: :campfire
    when /^jabber/:   :jabber
    end
  end

  def self.handler(url)
    case protocol(url)
    when :email:    Email
    when :http:     Web
    when :campfire: Campfire
    when :jabber:   Jabber
    else
      raise ProtocolError, "Malformed service URL: #{url}. Either this syntax is wrong or this service type is not yet implemented."
    end
  end


  autoload :Result, "messenger/result"
  autoload :Email, "messenger/email"
  autoload :Web, "messenger/web"
  autoload :Campfire, "messenger/campfire"
  autoload :Jabber, "messenger/jabber"

end

{'fraction_non_alphanumeric': 0.10866238138965412, 'fraction_numerical': 0.008570554025099479, 'mean_word_length': 3.1472081218274113, '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': '5064007', 'n_tokens_mistral': 1162, 'n_tokens_neox': 1101, 'n_words': 270}