faraday_middleware 0.8.2 → 0.8.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,34 +1,19 @@
1
1
  require 'faraday'
2
2
 
3
3
  module FaradayMiddleware
4
- class << self
5
- middleware = {
6
- :OAuth => 'request/oauth',
7
- :OAuth2 => 'request/oauth2',
8
- :EncodeJson => 'request/encode_json',
9
- :Mashify => 'response/mashify',
10
- :Rashify => 'response/rashify',
11
- :ParseJson => 'response/parse_json',
12
- :ParseXml => 'response/parse_xml',
13
- :ParseMarshal => 'response/parse_marshal',
14
- :ParseYaml => 'response/parse_yaml',
15
- :Caching => 'response/caching',
16
- :RackCompatible => 'rack_compatible',
17
- :FollowRedirects => 'response/follow_redirects',
18
- :Instrumentation => 'instrumentation'
19
- }
20
-
21
- # autoload without the autoload
22
- define_method(:const_missing) { |const|
23
- if middleware.member? const
24
- require "faraday_middleware/#{middleware[const]}"
25
- raise NameError, "missing #{const} middleware" unless const_defined? const
26
- const_get const
27
- else
28
- super
29
- end
30
- }
31
- end
4
+ autoload :OAuth, 'faraday_middleware/request/oauth'
5
+ autoload :OAuth2, 'faraday_middleware/request/oauth2'
6
+ autoload :EncodeJson, 'faraday_middleware/request/encode_json'
7
+ autoload :Mashify, 'faraday_middleware/response/mashify'
8
+ autoload :Rashify, 'faraday_middleware/response/rashify'
9
+ autoload :ParseJson, 'faraday_middleware/response/parse_json'
10
+ autoload :ParseXml, 'faraday_middleware/response/parse_xml'
11
+ autoload :ParseMarshal, 'faraday_middleware/response/parse_marshal'
12
+ autoload :ParseYaml, 'faraday_middleware/response/parse_yaml'
13
+ autoload :Caching, 'faraday_middleware/response/caching'
14
+ autoload :RackCompatible, 'faraday_middleware/rack_compatible'
15
+ autoload :FollowRedirects, 'faraday_middleware/response/follow_redirects'
16
+ autoload :Instrumentation, 'faraday_middleware/instrumentation'
32
17
 
33
18
  if Faraday.respond_to? :register_middleware
34
19
  Faraday.register_middleware :request,
@@ -1,30 +1,15 @@
1
- deprecation_warning = lambda { |old, new, trace|
2
- warn "Deprecation warning: #{old} is deprecated; use #{new}"
3
- warn trace[0,10].join("\n") if $DEBUG
4
- }
1
+ # deprecated constants
5
2
 
6
- Faraday::Request.extend Module.new {
7
- legacy = [:OAuth, :OAuth2]
8
- define_method(:const_missing) { |const|
9
- if legacy.include? const
10
- klass = FaradayMiddleware.const_get(const)
11
- deprecation_warning.call "Faraday::Request::#{const}", klass.name, caller
12
- const_set const, klass
13
- else
14
- super
15
- end
16
- }
17
- }
3
+ Faraday::Request.class_eval do
4
+ autoload :OAuth, 'faraday_middleware/request/oauth'
5
+ autoload :OAuth2, 'faraday_middleware/request/oauth2'
6
+ end
18
7
 
19
- Faraday::Response.extend Module.new {
20
- legacy = [:Mashify, :Rashify, :ParseJson, :ParseMarshal, :ParseXml, :ParseYaml]
21
- define_method(:const_missing) { |const|
22
- if legacy.include? const
23
- klass = FaradayMiddleware.const_get(const)
24
- deprecation_warning.call "Faraday::Response::#{const}", klass.name, caller
25
- const_set const, klass
26
- else
27
- super
28
- end
29
- }
30
- }
8
+ Faraday::Response.class_eval do
9
+ autoload :Mashify, 'faraday_middleware/response/mashify'
10
+ autoload :Rashify, 'faraday_middleware/response/rashify'
11
+ autoload :ParseJson, 'faraday_middleware/response/parse_json'
12
+ autoload :ParseXml, 'faraday_middleware/response/parse_xml'
13
+ autoload :ParseMarshal, 'faraday_middleware/response/parse_marshal'
14
+ autoload :ParseYaml, 'faraday_middleware/response/parse_yaml'
15
+ end
@@ -59,3 +59,6 @@ module FaradayMiddleware
59
59
  end
60
60
  end
61
61
  end
62
+
63
+ # deprecated alias
64
+ Faraday::Request::OAuth = FaradayMiddleware::OAuth
@@ -57,3 +57,6 @@ module FaradayMiddleware
57
57
  end
58
58
  end
59
59
  end
60
+
61
+ # deprecated alias
62
+ Faraday::Request::OAuth2 = FaradayMiddleware::OAuth2
@@ -2,13 +2,14 @@ require 'faraday'
2
2
 
3
3
  module FaradayMiddleware
4
4
  class Mashify < Faraday::Response::Middleware
5
- dependency 'hashie/mash'
6
-
7
5
  class << self
8
6
  attr_accessor :mash_class
9
7
  end
10
8
 
11
- self.mash_class = ::Hashie::Mash
9
+ dependency do
10
+ require 'hashie/mash'
11
+ self.mash_class = ::Hashie::Mash
12
+ end
12
13
 
13
14
  def parse(body)
14
15
  case body
@@ -22,3 +23,6 @@ module FaradayMiddleware
22
23
  end
23
24
  end
24
25
  end
26
+
27
+ # deprecated alias
28
+ Faraday::Response::Mashify = FaradayMiddleware::Mashify
@@ -33,3 +33,6 @@ module FaradayMiddleware
33
33
  end
34
34
  end
35
35
  end
36
+
37
+ # deprecated alias
38
+ Faraday::Response::ParseJson = FaradayMiddleware::ParseJson
@@ -8,3 +8,6 @@ module FaradayMiddleware
8
8
  }
9
9
  end
10
10
  end
11
+
12
+ # deprecated alias
13
+ Faraday::Response::ParseMarshal = FaradayMiddleware::ParseMarshal
@@ -9,3 +9,6 @@ module FaradayMiddleware
9
9
  }
10
10
  end
11
11
  end
12
+
13
+ # deprecated alias
14
+ Faraday::Response::ParseXml = FaradayMiddleware::ParseXml
@@ -8,3 +8,6 @@ module FaradayMiddleware
8
8
  define_parser { |body| ::YAML.load body }
9
9
  end
10
10
  end
11
+
12
+ # deprecated alias
13
+ Faraday::Response::ParseYaml = FaradayMiddleware::ParseYaml
@@ -2,8 +2,12 @@ require 'faraday_middleware/response/mashify'
2
2
 
3
3
  module FaradayMiddleware
4
4
  class Rashify < Mashify
5
- dependency 'rash'
6
-
7
- self.mash_class = ::Hashie::Rash
5
+ dependency do
6
+ require 'rash'
7
+ self.mash_class = ::Hashie::Rash
8
+ end
8
9
  end
9
10
  end
11
+
12
+ # deprecated alias
13
+ Faraday::Response::Rashify = FaradayMiddleware::Rashify
@@ -1,3 +1,3 @@
1
1
  module FaradayMiddleware
2
- VERSION = "0.8.2"
2
+ VERSION = "0.8.3"
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.2
4
+ version: 0.8.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-01-28 00:00:00.000000000 Z
13
+ date: 2012-01-29 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: faraday
17
- requirement: &70338088113740 !ruby/object:Gem::Requirement
17
+ requirement: &70166886053120 !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: *70338088113740
28
+ version_requirements: *70166886053120
29
29
  - !ruby/object:Gem::Dependency
30
30
  name: multi_xml
31
- requirement: &70338088112100 !ruby/object:Gem::Requirement
31
+ requirement: &70166886068140 !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: *70338088112100
39
+ version_requirements: *70166886068140
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: rake
42
- requirement: &70338088111080 !ruby/object:Gem::Requirement
42
+ requirement: &70166886066400 !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: *70338088111080
50
+ version_requirements: *70166886066400
51
51
  - !ruby/object:Gem::Dependency
52
52
  name: hashie
53
- requirement: &70338088108700 !ruby/object:Gem::Requirement
53
+ requirement: &70166886064880 !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: *70338088108700
61
+ version_requirements: *70166886064880
62
62
  - !ruby/object:Gem::Dependency
63
63
  name: rash
64
- requirement: &70338088107120 !ruby/object:Gem::Requirement
64
+ requirement: &70166886062240 !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: *70338088107120
72
+ version_requirements: *70166886062240
73
73
  - !ruby/object:Gem::Dependency
74
74
  name: rspec
75
- requirement: &70338088128460 !ruby/object:Gem::Requirement
75
+ requirement: &70166886080220 !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: *70338088128460
83
+ version_requirements: *70166886080220
84
84
  - !ruby/object:Gem::Dependency
85
85
  name: simple_oauth
86
- requirement: &70338088148700 !ruby/object:Gem::Requirement
86
+ requirement: &70166886078240 !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: *70338088148700
94
+ version_requirements: *70166886078240
95
95
  - !ruby/object:Gem::Dependency
96
96
  name: rack-cache
97
- requirement: &70338088146280 !ruby/object:Gem::Requirement
97
+ requirement: &70166886075580 !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: *70338088146280
105
+ version_requirements: *70166886075580
106
106
  description: Various middleware for Faraday
107
107
  email:
108
108
  - sferik@gmail.com