<commit_before>
require 'net/http'

require 'inteltech_sms'

# Dummy Class for testing

class DummyInteltechSms < InteltechSms 


  attr_accessor :credit, :response_code 

  def initialize(credit, response_code = InteltechSms::SUCCESS_RESPONSE_CODE)
    super('dummy_user', 'a_secret')
    @credit = credit.to_i
    @response_code = response_code
    @last_sms = ''
  end

  def get_credit
    res = InteltechSms::FakeHTTPSuccess.new(@response_code == InteltechSms::SUCCESS_RESPONSE_CODE ? "credit,#{@credit}" : @response_code)
    process_get_credit_response(res)
  end

  def send_sms(sms, message, options = { })
    this_response_code = response_code_for_sms(sms)
    @credit -= 1 if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE
    res = InteltechSms::FakeHTTPSuccess.new(this_response_code)
    process_send_sms_response(res, sms)
  end

  def send_multiple_sms(sms, message, options = { })
    this_response_code = response_code_for_sms(sms)
    sms_array = (sms.respond_to?(:each) ? sms : sms.split(','))
    @credit -= sms_array.size if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE

    ret = [ ]
    sms_array.each do |this_sms|
      ret << Response.factory(this_sms.strip, this_response_code)
    end
    ret
  end

  private

  def response_code_for_sms(sms)
    ret = @response_code
    if ret == InteltechSms::SUCCESS_RESPONSE_CODE
      if @credit <= 0 
        ret = InteltechSms::NO_CREDIT_RESPONSE_CODE
      else
        ret = @last_sms == sms ? InteltechSms::DUPLICATE_RESPONSE_CODE : @response_code
        @last_sms = sms
      end
    end
    ret
  end

end

# vi:ai sw=2:<commit_msg>Fix test error on ruby != 1.8.7<commit_after>
require 'net/http'

require 'inteltech_sms'

# Dummy Class for testing

class DummyInteltechSms < InteltechSms 


  attr_accessor :credit, :response_code 

  def initialize(credit, response_code = InteltechSms::SUCCESS_RESPONSE_CODE)
    super('dummy_user', 'a_secret')
    @credit = credit.to_i
    @response_code = response_code
    @last_sms = ''
  end

  def get_credit
    res = InteltechSms::FakeHTTPSuccess.new(@response_code == InteltechSms::SUCCESS_RESPONSE_CODE ? "credit,#{@credit}" : @response_code)
    process_get_credit_response(res)
  end

  def send_sms(sms, message, options = { })
    this_response_code = response_code_for_sms(sms)
    @credit -= 1 if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE
    res = InteltechSms::FakeHTTPSuccess.new(this_response_code)
    process_send_sms_response(res, sms)
  end

  def send_multiple_sms(sms, message, options = { })
    this_response_code = response_code_for_sms(sms)
    sms_array = (sms.is_a?(Array) ? sms : sms.split(','))
    @credit -= sms_array.size if this_response_code == InteltechSms::SUCCESS_RESPONSE_CODE

    ret = [ ]
    sms_array.each do |this_sms|
      ret << Response.factory(this_sms.strip, this_response_code)
    end
    ret
  end

  private

  def response_code_for_sms(sms)
    ret = @response_code
    if ret == InteltechSms::SUCCESS_RESPONSE_CODE
      if @credit <= 0 
        ret = InteltechSms::NO_CREDIT_RESPONSE_CODE
      else
        ret = @last_sms == sms ? InteltechSms::DUPLICATE_RESPONSE_CODE : @response_code
        @last_sms = sms
      end
    end
    ret
  end

end

# vi:ai sw=2:
{'fraction_non_alphanumeric': 0.09847560975609757, 'fraction_numerical': 0.00274390243902439, 'mean_word_length': 3.904334828101644, 'pattern_counts': {'":': 0, '<': 11, '<?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': '4595162', 'n_tokens_mistral': 1250, 'n_tokens_neox': 1208, 'n_words': 214}