Sha256: fd2b1d7a18a4a71220c68dfb19d5d879b2f2b6b01fe38bf8c3ace877a10696e9

Contents?: true

Size: 692 Bytes

Versions: 2

Compression:

Stored size: 692 Bytes

Contents

require 'twimock/api/application'
require 'twimock/api/oauth'
require 'sham_rack'

module Twimock
  module API
    extend self

    HOSTNAME    = "api.twitter.com"
    PORT        = 443
    MIDDLEWARES = [ OAuth::AccessToken, OAuth::RequestToken, Account::VerifyCredentials ]

    def on
      ShamRack.at(HOSTNAME, PORT){|env| app.call(env) } unless on?
      true
    end
    
    def off
      ShamRack.unmount_all
      true
    end

    def on?
      !ShamRack.application_for(HOSTNAME, PORT).nil?
    end

    # Rack Application
    def app
      app = Twimock::API::Application.new
      MIDDLEWARES.inject(app) do |app, klass|
        app = klass.new(app)
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
twimock-0.0.2 lib/twimock/api.rb
twimock-0.0.1 lib/twimock/api.rb