faraday 0.4.6 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -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