Sha256: 81637f9fe59ae3d4b21f877e83e36797fc0b2848d06a4e9056fcf7156a4c76e2

Contents?: true

Size: 1.07 KB

Versions: 12

Compression:

Stored size: 1.07 KB

Contents

class Rad::Http::HttpAdapter
  inject conveyors: :conveyors

  def call env, workspace = {}, &block
    # result, opt = nil, opt.to_openobject
    workspace = conveyors.web.call(
      {env: env, response: Rad::Http::Response.new}.merge(workspace),
      &block
    )
  
    response = workspace.response.must_be.defined
    result = response.finish
          
    result
  end
  # synchronize_method :call

  # def mock_call env = {}, workspace = {}, &block
  #   env['PATH_INFO'] ||= '/'
  #   env['rack.input'] ||= StringIO.new        
  #   
  #   call env, workspace, &block
  # end

  def mock_environment url = nil
    env = {
      'rack.url_scheme' => 'http',
      'PATH_INFO' => '/',
      'HTTP_HOST' => 'spec',
      'rack.input' => StringIO.new
    }
    if url
      uri = Uri.parse url
      env.merge!(
        'HTTP_HOST'    => %(#{uri.host}#{":#{uri.port}" if uri.port.present?}),
        # 'REQUEST_PATH' => uri.path,
        'PATH_INFO'    => uri.path,
        # 'REQUEST_URI'  => uri.path,
        'QUERY_STRING' => uri.query            
      )
    end
    env
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
rad_core-0.0.25 lib/rad/http/_http_adapter.rb
rad_core-0.0.24 lib/rad/http/_http_adapter.rb
rad_core-0.0.23 lib/rad/http/_http_adapter.rb
rad_core-0.0.22 lib/rad/http/_http_adapter.rb
rad_core-0.0.21 lib/rad/http/_http_adapter.rb
rad_core-0.0.20 lib/rad/http/_http_adapter.rb
rad_core-0.0.19 lib/rad/http/_http_adapter.rb
rad_core-0.0.18 lib/rad/http/_http_adapter.rb
rad_core-0.0.17 lib/rad/http/_http_adapter.rb
rad_core-0.0.16 lib/rad/http/_http_adapter.rb
rad_core-0.0.15 lib/rad/http/_http_adapter.rb
rad_core-0.0.14 lib/rad/http/_http_adapter.rb