faraday_middleware 0.8.0 → 0.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,41 +1,54 @@
1
1
  Faraday Middleware
2
2
  ==================
3
3
 
4
- A collection of some useful [Faraday](https://github.com/technoweenie/faraday) middleware
4
+ A collection of useful [Faraday][] middleware. [See the documentation][docs].
5
5
 
6
- <a name="installation">Installation</a>
7
- ------------
8
6
  gem install faraday_middleware
9
7
 
10
- <a name="examples">Examples</a>
8
+ Dependencies
9
+ ------------
10
+
11
+ Some dependent libraries are needed only when using specific middleware:
12
+
13
+ * FaradayMiddleware::EncodeJson & FaradayMiddleware::ParseJson: "json"
14
+ for ruby older than 1.9
15
+ * FaradayMiddleware::ParseXml: "multi_xml"
16
+ * FaradayMiddleware::OAuth: "simple_oauth"
17
+ * FaradayMiddleware::Mashify: "hashie"
18
+ * FaradayMiddleware::Rashify: "rash"
19
+ * FaradayMiddleware::Instrumentation: "activesupport"
20
+
21
+ Examples
11
22
  --------
12
- Let's decode the response body with [MultiJson](https://github.com/intridea/multi_json)!
13
23
 
14
- connection = Faraday.new(:url => 'http://api.twitter.com/1') do |builder|
15
- builder.use Faraday::Response::ParseJson
16
- builder.adapter Faraday.default_adapter
17
- end
24
+ ``` rb
25
+ require 'faraday_middleware'
26
+
27
+ ## in Faraday 0.8 or above:
28
+ connection = Faraday.new 'http://example.com/api' do |conn|
29
+ conn.request :oauth2, 'TOKEN'
30
+ conn.request :json
31
+
32
+ conn.response :xml, :content_type => /\bxml$/
33
+ conn.response :json, :content_type => /\bjson$/
18
34
 
19
- response = connection.get do |request|
20
- request.url '/users/show.json', :screen_name => 'pengwynn'
21
- end
35
+ conn.use :instrumentation
36
+ conn.adapter Faraday.default_adapter
37
+ end
22
38
 
23
- u = response.body
24
- u['name']
25
- # => "Wynn Netherland"
39
+ ## with Faraday 0.7:
40
+ connection = Faraday.new 'http://example.com/api' do |builder|
41
+ builder.use FaradayMiddleware::OAuth2, 'TOKEN'
42
+ builder.use FaradayMiddleware::EncodeJson
26
43
 
27
- Want to ditch the brackets and use dot notation? [Mashify](https://github.com/intridea/hashie) it!
44
+ builder.use FaradayMiddleware::ParseXml, :content_type => /\bxml$/
45
+ builder.use FaradayMiddleware::ParseJson, :content_type => /\bjson$/
28
46
 
29
- connection = Faraday.new(:url => 'http://api.twitter.com/1') do |builder|
30
- builder.use Faraday::Response::Mashify
31
- builder.use Faraday::Response::ParseJson
32
- builder.adapter Faraday.default_adapter
33
- end
47
+ builder.use FaradayMiddleware::Instrumentation
48
+ builder.adapter Faraday.default_adapter
49
+ end
50
+ ```
34
51
 
35
- response = connection.get do |request|
36
- request.url '/users/show.json', :screen_name => 'pengwynn'
37
- end
38
52
 
39
- u = response.body
40
- u.name
41
- # => "Wynn Netherland"
53
+ [faraday]: https://github.com/technoweenie/faraday#readme
54
+ [docs]: https://github.com/pengwynn/faraday_middleware/wiki
@@ -20,7 +20,6 @@ module FaradayMiddleware
20
20
  # # default token value is optional:
21
21
  # OAuth2.new(app, :param_name => 'my_oauth_token')
22
22
  class OAuth2 < Faraday::Middleware
23
- dependency 'oauth2'
24
23
 
25
24
  PARAM_NAME = 'access_token'.freeze
26
25
  AUTH_HEADER = 'Authorization'.freeze
@@ -1,3 +1,3 @@
1
1
  module FaradayMiddleware
2
- VERSION = "0.8.0"
2
+ VERSION = "0.8.1"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: faraday_middleware
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.8.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ date: 2012-01-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
- requirement: &70328307940220 !ruby/object:Gem::Requirement
17
+ requirement: &70347691081480 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ! '>='
@@ -25,10 +25,10 @@ dependencies:
25
25
  version: '0.9'
26
26
  type: :runtime
27
27
  prerelease: false
28
- version_requirements: *70328307940220
28
+ version_requirements: *70347691081480
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: multi_xml
31
- requirement: &70328307938460 !ruby/object:Gem::Requirement
31
+ requirement: &70347691079020 !ruby/object:Gem::Requirement
32
32
  none: false
33
33
  requirements:
34
34
  - - ~>
@@ -36,10 +36,10 @@ dependencies:
36
36
  version: '0.2'
37
37
  type: :development
38
38
  prerelease: false
39
- version_requirements: *70328307938460
39
+ version_requirements: *70347691079020
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
42
- requirement: &70328307937560 !ruby/object:Gem::Requirement
42
+ requirement: &70347691078240 !ruby/object:Gem::Requirement
43
43
  none: false
44
44
  requirements:
45
45
  - - ~>
@@ -47,10 +47,10 @@ dependencies:
47
47
  version: '0.9'
48
48
  type: :development
49
49
  prerelease: false
50
- version_requirements: *70328307937560
50
+ version_requirements: *70347691078240
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: hashie
53
- requirement: &70328307936700 !ruby/object:Gem::Requirement
53
+ requirement: &70347691102060 !ruby/object:Gem::Requirement
54
54
  none: false
55
55
  requirements:
56
56
  - - ~>
@@ -58,10 +58,10 @@ dependencies:
58
58
  version: '1.2'
59
59
  type: :development
60
60
  prerelease: false
61
- version_requirements: *70328307936700
61
+ version_requirements: *70347691102060
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rash
64
- requirement: &70328307935660 !ruby/object:Gem::Requirement
64
+ requirement: &70347691101540 !ruby/object:Gem::Requirement
65
65
  none: false
66
66
  requirements:
67
67
  - - ~>
@@ -69,10 +69,10 @@ dependencies:
69
69
  version: '0.3'
70
70
  type: :development
71
71
  prerelease: false
72
- version_requirements: *70328307935660
72
+ version_requirements: *70347691101540
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
- requirement: &70328307934840 !ruby/object:Gem::Requirement
75
+ requirement: &70347691100960 !ruby/object:Gem::Requirement
76
76
  none: false
77
77
  requirements:
78
78
  - - ~>
@@ -80,10 +80,10 @@ dependencies:
80
80
  version: '2.6'
81
81
  type: :development
82
82
  prerelease: false
83
- version_requirements: *70328307934840
83
+ version_requirements: *70347691100960
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: simple_oauth
86
- requirement: &70328307953240 !ruby/object:Gem::Requirement
86
+ requirement: &70347691100460 !ruby/object:Gem::Requirement
87
87
  none: false
88
88
  requirements:
89
89
  - - ~>
@@ -91,10 +91,10 @@ dependencies:
91
91
  version: '0.1'
92
92
  type: :development
93
93
  prerelease: false
94
- version_requirements: *70328307953240
94
+ version_requirements: *70347691100460
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rack-cache
97
- requirement: &70328307951820 !ruby/object:Gem::Requirement
97
+ requirement: &70347691099980 !ruby/object:Gem::Requirement
98
98
  none: false
99
99
  requirements:
100
100
  - - ~>
@@ -102,7 +102,7 @@ dependencies:
102
102
  version: '1.1'
103
103
  type: :development
104
104
  prerelease: false
105
- version_requirements: *70328307951820
105
+ version_requirements: *70347691099980
106
106
  description: Various middleware for Faraday
107
107
  email:
108
108
  - sferik@gmail.com