Sha256: 1ed549f8144d377ad9e8141aa79f03673d0a933097a952c5c9e314eb081977fd

Contents?: true

Size: 1.63 KB

Versions: 1

Compression:

Stored size: 1.63 KB

Contents

module Twitter
  class JSONStream
    protected
    def reconnect_after timeout
      @reconnect_callback.call(timeout, @reconnect_retries) if @reconnect_callback

      if timeout == 0
        reconnect @options[:host], @options[:port]
        start_tls if @options[:ssl]
      else
        EventMachine.add_timer(timeout) do
          reconnect @options[:host], @options[:port]
          start_tls if @options[:ssl]
        end
      end
    end
  end
end

module TwitterOAuth
  class Client
    private
    def consumer
      @consumer ||= OAuth::Consumer.new(
        @consumer_key,
        @consumer_secret,
        { :site => 'https://api.twitter.com', :proxy => @proxy }
      )
    end
  end
end

class String
  def c(*codes)
    codes = codes.flatten.map { |code|
      case code
      when String, Symbol
        Earthquake.config[:color][code.to_sym] rescue nil
      else
        code
      end
    }.compact.unshift(0)
    "\e[#{codes.join(';')}m#{self}\e[0m"
  end

  def coloring(pattern, color = nil, &block)
    self.gsub(pattern) do |i|
      applied_colors = self[0...$~.begin(0)].scan(/\e\[[\d;]+m/)
      color ||= block.call(i)
      "#{i.c(color)}#{applied_colors.join}"
    end
  end

  def u
    gsub(/&(lt|gt|amp|quot|apos);/) do |s|
      case s
        when '&' then '&'
        when '&lt;' then '<'
        when '&gt;' then '>'
        when '&apos;' then "'"
        when '&quot;' then '"'
      end
    end
  end

  def e
    gsub(/[&<>'"]/) do |s|
      case s
        when '&' then '&amp;'
        when '<' then '&lt;'
        when '>' then '&gt;'
        when "'" then '&apos;'
        when '"' then '&quot;'
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
earthquake-0.6.8 lib/earthquake/ext.rb