nestful 0.0.8 → 1.0.0.pre

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,13 +0,0 @@
1
- module Nestful
2
- module Formats
3
- class BlankFormat < Format
4
- def encode(params, options = nil)
5
- raise 'Choose an encoding format, such as :form'
6
- end
7
-
8
- def decode(body)
9
- body
10
- end
11
- end
12
- end
13
- end
@@ -1,17 +0,0 @@
1
- module Nestful
2
- module Formats
3
- class TextFormat < Format
4
- def mime_type
5
- 'text/plain'
6
- end
7
-
8
- def encode(body)
9
- body
10
- end
11
-
12
- def decode(body)
13
- body
14
- end
15
- end
16
- end
17
- end
@@ -1,34 +0,0 @@
1
- require 'active_support/core_ext/hash/conversions'
2
-
3
- module Nestful
4
- module Formats
5
- class XmlFormat < Format
6
- def extension
7
- 'xml'
8
- end
9
-
10
- def mime_type
11
- 'application/xml'
12
- end
13
-
14
- def encode(hash, options={})
15
- hash.to_xml(options)
16
- end
17
-
18
- def decode(xml)
19
- from_xml_data(Hash.from_xml(xml))
20
- end
21
-
22
- private
23
- # Manipulate from_xml Hash, because xml_simple is not exactly what we
24
- # want for Active Resource.
25
- def from_xml_data(data)
26
- if data.is_a?(Hash) && data.keys.size == 1
27
- data.values.first
28
- else
29
- data
30
- end
31
- end
32
- end
33
- end
34
- end
data/lib/nestful/oauth.rb DELETED
@@ -1,24 +0,0 @@
1
- require 'roauth'
2
-
3
- module Nestful
4
- class Request
5
- attr_accessor :oauth
6
-
7
- def oauth_sign
8
- return unless oauth
9
- params = method == :get ? self.params : {}
10
-
11
- signature = ROAuth.header(
12
- oauth,
13
- uri.to_s,
14
- params,
15
- method
16
- )
17
-
18
- self.headers ||= {}
19
- self.headers['Authorization'] = signature
20
- end
21
-
22
- before_request(&:oauth_sign)
23
- end
24
- end
@@ -1,28 +0,0 @@
1
- module Nestful
2
- class Request
3
- module Callbacks
4
- CALLBACKS = [
5
- :before_request,
6
- :after_request,
7
- :progress
8
- ]
9
-
10
- def self.included(base)
11
- CALLBACKS.each do |callback|
12
- base.instance_eval(<<-EOS, __FILE__, __LINE__ + 1)
13
- def #{callback}(method = nil, &block)
14
- callbacks(:#{callback}) << (method||block)
15
- end
16
- EOS
17
-
18
- base.class_eval(<<-EOS, __FILE__, __LINE__ + 1)
19
- def #{callback}(method = nil, &block)
20
- callbacks(:#{callback}) << (method||block)
21
- end
22
- alias_method :#{callback}=, :#{callback}
23
- EOS
24
- end
25
- end
26
- end
27
- end
28
- end