faraday 0.4.6 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile +3 -0
- data/Gemfile.lock +28 -0
- data/README.md +84 -0
- data/Rakefile +111 -34
- data/faraday.gemspec +85 -82
- data/lib/faraday.rb +17 -26
- data/lib/faraday/adapter.rb +102 -0
- data/lib/faraday/adapter/action_dispatch.rb +39 -0
- data/lib/faraday/adapter/net_http.rb +20 -8
- data/lib/faraday/adapter/patron.rb +10 -4
- data/lib/faraday/adapter/test.rb +28 -15
- data/lib/faraday/adapter/typhoeus.rb +16 -6
- data/lib/faraday/builder.rb +6 -6
- data/lib/faraday/connection.rb +33 -46
- data/lib/faraday/error.rb +25 -1
- data/lib/faraday/middleware.rb +0 -30
- data/lib/faraday/request.rb +5 -5
- data/lib/faraday/request/active_support_json.rb +1 -1
- data/lib/faraday/request/yajl.rb +1 -1
- data/lib/faraday/response/active_support_json.rb +9 -2
- data/lib/faraday/response/yajl.rb +8 -2
- data/lib/faraday/upload_io.rb +15 -0
- data/lib/faraday/utils.rb +64 -0
- data/test/adapters/live_test.rb +24 -15
- data/test/adapters/test_middleware_test.rb +11 -0
- data/test/connection_test.rb +6 -7
- data/test/env_test.rb +2 -2
- data/test/form_post_test.rb +42 -0
- data/test/helper.rb +6 -2
- data/test/live_server.rb +6 -1
- data/test/multipart_test.rb +48 -0
- data/test/request_middleware_test.rb +9 -2
- data/test/response_middleware_test.rb +8 -1
- metadata +75 -29
- data/.document +0 -5
- data/.gitignore +0 -21
- data/README.rdoc +0 -86
- data/VERSION +0 -1
data/README.rdoc
DELETED
@@ -1,86 +0,0 @@
|
|
1
|
-
= faraday
|
2
|
-
|
3
|
-
Modular HTTP client library using middleware heavily inspired by Rack.
|
4
|
-
|
5
|
-
This mess is gonna get raw, like sushi. So, haters to the left.
|
6
|
-
|
7
|
-
== Usage
|
8
|
-
|
9
|
-
conn = Faraday::Connection.new(:url => 'http://sushi.com') do |builder|
|
10
|
-
builder.use Faraday::Request::Yajl # convert body to json with Yajl lib
|
11
|
-
builder.use Faraday::Adapter::Logger # log the request somewhere?
|
12
|
-
builder.use Faraday::Adapter::Typhoeus # make http request with typhoeus
|
13
|
-
builder.use Faraday::Response::Yajl # # parse body with yajl
|
14
|
-
|
15
|
-
# or use shortcuts
|
16
|
-
builder.request :yajl # Faraday::Request::Yajl
|
17
|
-
builder.adapter :logger # Faraday::Adapter::Logger
|
18
|
-
builder.adapter :typhoeus # Faraday::Adapter::Typhoeus
|
19
|
-
builder.response :yajl # Faraday::Response::Yajl
|
20
|
-
end
|
21
|
-
|
22
|
-
resp1 = conn.get '/nigiri/sake.json'
|
23
|
-
resp2 = conn.post do |req|
|
24
|
-
req.url "/nigiri.json", :page => 2
|
25
|
-
req[:content_type] = 'application/json'
|
26
|
-
req.body = {:name => 'Unagi'}
|
27
|
-
end
|
28
|
-
|
29
|
-
# If you're ready to roll with just the bare minimum (net/http):
|
30
|
-
resp1 = Faraday.get 'http://sushi.com/nigiri/sake.json'
|
31
|
-
|
32
|
-
== Testing
|
33
|
-
|
34
|
-
# It's possible to define stubbed request outside a test adapter block.
|
35
|
-
stubs = Faraday::Test::Stubs.new do |stub|
|
36
|
-
stub.get('/tamago') { [200, {}, 'egg'] }
|
37
|
-
end
|
38
|
-
|
39
|
-
# You can pass stubbed request to the test adapter or define them in a block
|
40
|
-
# or a combination of the two.
|
41
|
-
test = Faraday::Connection.new do |builder|
|
42
|
-
builder.adapter :test, stubs do |stub|
|
43
|
-
stub.get('/ebi') {[ 200, {}, 'shrimp' ]}
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
# It's also possible to stub additional requests after the connection has
|
48
|
-
# been initialized. This is useful for testing.
|
49
|
-
stubs.get('/uni') {[ 200, {}, 'urchin' ]}
|
50
|
-
|
51
|
-
resp = test.get '/tamago'
|
52
|
-
resp.body # => 'egg'
|
53
|
-
resp = test.get '/ebi'
|
54
|
-
resp.body # => 'shrimp'
|
55
|
-
resp = test.get '/uni'
|
56
|
-
resp.body # => 'urchin'
|
57
|
-
resp = test.get '/else' #=> raises "no such stub" error
|
58
|
-
|
59
|
-
# If you like, you can treat your stubs as mocks by verifying that all of the
|
60
|
-
# stubbed calls were made. NOTE that this feature is still fairly
|
61
|
-
# experimental: It will not verify the order or count of any stub, only that
|
62
|
-
# it was called once during the course of the test.
|
63
|
-
stubs.verify_stubbed_calls
|
64
|
-
|
65
|
-
== TODO
|
66
|
-
|
67
|
-
* Add curb/em-http support
|
68
|
-
* Add xml parsing
|
69
|
-
* Support timeouts, proxy servers, ssl options on Typhoeus/Patron
|
70
|
-
* Add streaming requests and responses
|
71
|
-
* Add default middleware load out for common cases
|
72
|
-
* Add symbol => string index for mime types (:json => 'application/json')
|
73
|
-
|
74
|
-
== Note on Patches/Pull Requests
|
75
|
-
|
76
|
-
* Fork the project.
|
77
|
-
* Make your feature addition or bug fix.
|
78
|
-
* Add tests for it. This is important so I don't break it in a
|
79
|
-
future version unintentionally.
|
80
|
-
* Commit, do not mess with rakefile, version, or history.
|
81
|
-
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
82
|
-
* Send me a pull request. Bonus points for topic branches.
|
83
|
-
|
84
|
-
== Copyright
|
85
|
-
|
86
|
-
Copyright (c) 2009-2010 rick, hobson. See LICENSE for details.
|
data/VERSION
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
0.4.6
|