rack-client 0.3.0 → 0.3.1.pre.a
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +12 -14
- data/lib/rack/client/adapter/base.rb +23 -14
- data/lib/rack/client/adapter/base.rbc +1802 -0
- data/lib/rack/client/adapter/simple.rb +53 -21
- data/lib/rack/client/adapter/simple.rbc +2063 -0
- data/lib/rack/client/adapter.rbc +225 -0
- data/lib/rack/client/{dual_band.rb → core/dual_band.rb} +0 -0
- data/lib/rack/client/core/dual_band.rbc +380 -0
- data/lib/rack/client/{headers.rb → core/headers.rb} +1 -1
- data/lib/rack/client/core/headers.rbc +1811 -0
- data/lib/rack/client/core/response.rb +50 -0
- data/lib/rack/client/core/response.rbc +1105 -0
- data/lib/rack/client/core.rb +3 -0
- data/lib/rack/client/core.rbc +85 -0
- data/lib/rack/client/handler/em-http.rb +3 -7
- data/lib/rack/client/handler/em-http.rbc +1648 -0
- data/lib/rack/client/handler/excon.rb +6 -14
- data/lib/rack/client/handler/excon.rbc +1270 -0
- data/lib/rack/client/handler/net_http.rb +7 -4
- data/lib/rack/client/handler/net_http.rbc +2400 -0
- data/lib/rack/client/handler/typhoeus.rb +12 -5
- data/lib/rack/client/handler/typhoeus.rbc +1885 -0
- data/lib/rack/client/handler.rbc +340 -0
- data/lib/rack/client/{auth → middleware/auth}/abstract/challenge.rb +0 -0
- data/lib/rack/client/middleware/auth/abstract/challenge.rbc +1453 -0
- data/lib/rack/client/{auth → middleware/auth}/basic.rb +0 -0
- data/lib/rack/client/middleware/auth/basic.rbc +1566 -0
- data/lib/rack/client/{auth → middleware/auth}/digest/challenge.rb +0 -0
- data/lib/rack/client/middleware/auth/digest/challenge.rbc +1124 -0
- data/lib/rack/client/{auth → middleware/auth}/digest/md5.rb +0 -0
- data/lib/rack/client/middleware/auth/digest/md5.rbc +2241 -0
- data/lib/rack/client/{auth → middleware/auth}/digest/params.rb +0 -0
- data/lib/rack/client/middleware/auth/digest/params.rbc +365 -0
- data/lib/rack/client/middleware/auth.rb +5 -0
- data/lib/rack/client/middleware/auth.rbc +117 -0
- data/lib/rack/client/{cache → middleware/cache}/cachecontrol.rb +0 -0
- data/lib/rack/client/middleware/cache/cachecontrol.rbc +1610 -0
- data/lib/rack/client/{cache → middleware/cache}/context.rb +12 -3
- data/lib/rack/client/middleware/cache/context.rbc +2074 -0
- data/lib/rack/client/{cache → middleware/cache}/entitystore.rb +0 -0
- data/lib/rack/client/middleware/cache/entitystore.rbc +1619 -0
- data/lib/rack/client/{cache → middleware/cache}/key.rb +0 -0
- data/lib/rack/client/middleware/cache/key.rbc +1217 -0
- data/lib/rack/client/{cache → middleware/cache}/metastore.rb +0 -0
- data/lib/rack/client/middleware/cache/metastore.rbc +2754 -0
- data/lib/rack/client/{cache → middleware/cache}/options.rb +0 -0
- data/lib/rack/client/middleware/cache/options.rbc +1844 -0
- data/lib/rack/client/{cache → middleware/cache}/request.rb +0 -0
- data/lib/rack/client/middleware/cache/request.rbc +1020 -0
- data/lib/rack/client/{cache → middleware/cache}/response.rb +19 -0
- data/lib/rack/client/middleware/cache/response.rbc +1540 -0
- data/lib/rack/client/{cache → middleware/cache}/storage.rb +0 -0
- data/lib/rack/client/middleware/cache/storage.rbc +1106 -0
- data/lib/rack/client/middleware/cache.rb +19 -0
- data/lib/rack/client/middleware/cache.rbc +528 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/context.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/context.rbc +1576 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/cookie.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/cookie.rbc +2393 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/cookiestore.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/cookiestore.rbc +1209 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/options.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/options.rbc +1305 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/request.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/request.rbc +568 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/response.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/response.rbc +616 -0
- data/lib/rack/client/{cookie_jar → middleware/cookie_jar}/storage.rb +0 -0
- data/lib/rack/client/middleware/cookie_jar/storage.rbc +894 -0
- data/lib/rack/client/middleware/cookie_jar.rb +17 -0
- data/lib/rack/client/middleware/cookie_jar.rbc +471 -0
- data/lib/rack/client/{follow_redirects.rb → middleware/follow_redirects.rb} +0 -0
- data/lib/rack/client/middleware/follow_redirects.rbc +1344 -0
- data/lib/rack/client/middleware.rb +4 -0
- data/lib/rack/client/middleware.rbc +101 -0
- data/lib/rack/client/parser/base.rbc +898 -0
- data/lib/rack/client/parser/body_collection.rbc +1220 -0
- data/lib/rack/client/parser/context.rbc +540 -0
- data/lib/rack/client/parser/request.rbc +631 -0
- data/lib/rack/client/parser/response.rbc +663 -0
- data/lib/rack/client/parser.rbc +484 -0
- data/lib/rack/client/version.rb +1 -1
- data/lib/rack/client/version.rbc +203 -0
- data/lib/rack/client.rb +3 -13
- data/lib/rack/client.rbc +701 -0
- data/spec/core/headers_spec.rb +47 -0
- data/spec/core/headers_spec.rbc +1674 -0
- data/spec/core/response_spec.rb +78 -0
- data/spec/core/response_spec.rbc +2244 -0
- data/spec/handler/em_http_spec.rb +4 -19
- data/spec/handler/em_http_spec.rbc +224 -0
- data/spec/handler/excon_spec.rb +4 -4
- data/spec/handler/excon_spec.rbc +224 -0
- data/spec/handler/net_http_spec.rb +7 -4
- data/spec/handler/net_http_spec.rbc +307 -0
- data/spec/handler/typhoeus_spec.rb +6 -17
- data/spec/handler/typhoeus_spec.rbc +307 -0
- data/spec/helpers/async_helper.rb +31 -0
- data/spec/helpers/async_helper.rbc +843 -0
- data/spec/helpers/em_http_helper.rb +24 -0
- data/spec/helpers/em_http_helper.rbc +663 -0
- data/spec/helpers/excon_helper.rb +13 -0
- data/spec/helpers/excon_helper.rbc +461 -0
- data/spec/helpers/handler_helper.rb +68 -0
- data/spec/helpers/handler_helper.rbc +1769 -0
- data/spec/helpers/net_http_helper.rb +26 -0
- data/spec/helpers/net_http_helper.rbc +806 -0
- data/spec/helpers/sync_helper.rb +9 -0
- data/spec/helpers/sync_helper.rbc +311 -0
- data/spec/helpers/typhoeus_helper.rb +32 -0
- data/spec/helpers/typhoeus_helper.rbc +936 -0
- data/spec/middleware/cache_spec.rb +25 -0
- data/spec/middleware/cache_spec.rbc +712 -0
- data/spec/middleware/cookie_jar_spec.rb +19 -0
- data/spec/middleware/cookie_jar_spec.rbc +614 -0
- data/spec/middleware/etag_spec.rb +10 -0
- data/spec/middleware/etag_spec.rbc +438 -0
- data/spec/middleware/follow_redirects_spec.rb +12 -0
- data/spec/middleware/follow_redirects_spec.rbc +402 -0
- data/spec/middleware/lint_spec.rb +10 -0
- data/spec/middleware/lint_spec.rbc +392 -0
- data/spec/shared/handler_api.rb +33 -0
- data/spec/shared/handler_api.rbc +1340 -0
- data/spec/shared/streamed_response_api.rb +14 -0
- data/spec/shared/streamed_response_api.rbc +508 -0
- data/spec/spec_apps/cache.ru +14 -0
- data/spec/spec_apps/cookie.ru +12 -0
- data/spec/spec_apps/delete.ru +10 -0
- data/spec/spec_apps/get.ru +13 -0
- data/spec/spec_apps/head.ru +10 -0
- data/spec/spec_apps/hello_world.ru +1 -0
- data/spec/spec_apps/redirect.ru +13 -0
- data/spec/spec_apps/stream.ru +9 -0
- data/spec/spec_config.ru +10 -0
- data/spec/spec_helper.rb +14 -12
- metadata +190 -64
- data/lib/rack/client/cache.rb +0 -19
- data/lib/rack/client/cookie_jar.rb +0 -17
- data/lib/rack/client/response.rb +0 -9
- data/spec/apps/example.org.ru +0 -128
- data/spec/auth/basic_spec.rb +0 -69
- data/spec/auth/digest/md5_spec.rb +0 -69
- data/spec/cache_spec.rb +0 -40
- data/spec/cookie_jar_spec.rb +0 -37
- data/spec/endpoint_spec.rb +0 -30
- data/spec/follow_redirect_spec.rb +0 -27
- data/spec/handler/async_api_spec.rb +0 -69
- data/spec/handler/sync_api_spec.rb +0 -55
- data/spec/middleware_helper.rb +0 -37
- data/spec/middleware_spec.rb +0 -53
- data/spec/parser/json_spec.rb +0 -22
- data/spec/parser/yaml_spec.rb +0 -22
- data/spec/server_helper.rb +0 -72
data/Rakefile
CHANGED
@@ -1,18 +1,13 @@
|
|
1
1
|
require 'rubygems'
|
2
2
|
require 'rake'
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require 'rake/gempackagetask'
|
4
|
+
require 'rake/clean'
|
5
|
+
require 'rspec/core/rake_task'
|
6
|
+
|
6
7
|
|
7
8
|
$:.unshift File.join(File.dirname(__FILE__), 'lib')
|
8
9
|
require 'rack/client/version'
|
9
10
|
|
10
|
-
Spec::Rake::SpecTask.new(:spec) do |t|
|
11
|
-
t.spec_files = FileList['spec/**/*_spec.rb']
|
12
|
-
t.spec_opts = ['-c']
|
13
|
-
end
|
14
|
-
|
15
|
-
task :default => :spec
|
16
11
|
|
17
12
|
spec = Gem::Specification.new do |s|
|
18
13
|
s.name = "rack-client"
|
@@ -26,11 +21,7 @@ spec = Gem::Specification.new do |s|
|
|
26
21
|
s.files = %w[History.txt LICENSE README.textile Rakefile] + Dir["lib/**/*"] + Dir["demo/**/*"]
|
27
22
|
s.test_files = Dir["spec/**/*"]
|
28
23
|
|
29
|
-
|
30
|
-
bundle = Bundler::Definition.from_gemfile("Gemfile")
|
31
|
-
bundle.dependencies.
|
32
|
-
select { |d| d.groups.include?(:runtime) }.
|
33
|
-
each { |d| s.add_dependency(d.name, d.version_requirements.to_s) }
|
24
|
+
s.add_bundler_dependencies
|
34
25
|
end
|
35
26
|
|
36
27
|
Rake::GemPackageTask.new(spec) do |package|
|
@@ -42,3 +33,10 @@ task :install => [:clean, :package] do
|
|
42
33
|
gem = Dir['pkg/*.gem'].first
|
43
34
|
sh "sudo gem install --no-rdoc --no-ri --local #{gem}"
|
44
35
|
end
|
36
|
+
|
37
|
+
RSpec::Core::RakeTask.new do |t|
|
38
|
+
t.rspec_opts = %w[ -c -f documentation -r ./spec/spec_helper.rb ]
|
39
|
+
t.pattern = 'spec/**/*_spec.rb'
|
40
|
+
end
|
41
|
+
|
42
|
+
task :default => :spec
|
@@ -11,16 +11,20 @@ module Rack
|
|
11
11
|
|
12
12
|
%w[ options get head post put delete trace connect ].each do |method|
|
13
13
|
eval <<-RUBY, binding, __FILE__, __LINE__ + 1
|
14
|
-
def #{method}(url, headers = {}, body = nil)
|
15
|
-
|
16
|
-
call(build_env('#{method.upcase}', url, headers, body)) {|tuple| yield *tuple }
|
17
|
-
else
|
18
|
-
return *call(build_env('#{method.upcase}', url, headers, body))
|
19
|
-
end
|
14
|
+
def #{method}(url, headers = {}, body = nil, &block)
|
15
|
+
request('#{method.upcase}', url, headers, body, &block)
|
20
16
|
end
|
21
17
|
RUBY
|
22
18
|
end
|
23
19
|
|
20
|
+
def request(method, url, headers = {}, body = nil)
|
21
|
+
if block_given?
|
22
|
+
call(build_env(method.upcase, url, headers, body)) {|tuple| yield *tuple }
|
23
|
+
else
|
24
|
+
return *call(build_env(method.upcase, url, headers, body))
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
24
28
|
def build_env(request_method, url, headers = {}, body = nil)
|
25
29
|
env = Headers.new(headers).to_env
|
26
30
|
|
@@ -33,20 +37,25 @@ module Rack
|
|
33
37
|
path_info = uri.path.empty? ? '/' : uri.path
|
34
38
|
path_info += '?' + uri.query unless uri.query.nil? || uri.query.empty?
|
35
39
|
|
36
|
-
env.update 'PATH_INFO'
|
37
|
-
env.update 'REQUEST_URI'
|
38
|
-
env.update 'SERVER_NAME'
|
39
|
-
env.update 'SERVER_PORT'
|
40
|
-
env.update 'SCRIPT_NAME'
|
40
|
+
env.update 'PATH_INFO' => path_info
|
41
|
+
env.update 'REQUEST_URI' => uri.to_s
|
42
|
+
env.update 'SERVER_NAME' => uri.host
|
43
|
+
env.update 'SERVER_PORT' => uri.port.to_s
|
44
|
+
env.update 'SCRIPT_NAME' => ''
|
45
|
+
env.update 'QUERY_STRING' => uri.query.to_s
|
41
46
|
|
42
47
|
input = case body
|
43
48
|
when nil then StringIO.new
|
44
49
|
when String then StringIO.new(body)
|
45
50
|
end
|
46
51
|
|
47
|
-
env.update 'rack.input'
|
48
|
-
env.update 'rack.errors'
|
49
|
-
env.update 'rack.url_scheme'
|
52
|
+
env.update 'rack.input' => input
|
53
|
+
env.update 'rack.errors' => StringIO.new
|
54
|
+
env.update 'rack.url_scheme' => uri.scheme
|
55
|
+
env.update 'rack.version' => Rack::VERSION
|
56
|
+
env.update 'rack.multithread' => true
|
57
|
+
env.update 'rack.multiprocess' => true
|
58
|
+
env.update 'rack.run_once' => false
|
50
59
|
|
51
60
|
env.update 'HTTPS' => env["rack.url_scheme"] == "https" ? "on" : "off"
|
52
61
|
|