nestful 0.0.6 → 0.0.7
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/README.markdown +8 -2
- data/VERSION +1 -1
- data/lib/nestful/formats/text_format.rb +17 -0
- data/lib/nestful/formats.rb +2 -1
- data/lib/nestful/request.rb +16 -6
- data/lib/nestful/resource.rb +2 -2
- metadata +30 -52
- data/.gitignore +0 -2
data/README.markdown
CHANGED
@@ -42,7 +42,9 @@ Connection options:
|
|
42
42
|
### POST request
|
43
43
|
|
44
44
|
Nestful.post 'http://example.com', :format => :form #=> "body"
|
45
|
-
|
45
|
+
|
46
|
+
other supported mime-type formats are :json, :multipart, :xml
|
47
|
+
|
46
48
|
### Parameters
|
47
49
|
|
48
50
|
Nestful.get 'http://example.com', :params => {:nestled => {:params => 1}}
|
@@ -55,8 +57,12 @@ Connection options:
|
|
55
57
|
|
56
58
|
### Resource
|
57
59
|
|
60
|
+
The Resource class provides a single object to work with restful services. The following example does a GET request to the URL; http://example.com/assets/1/
|
61
|
+
|
58
62
|
Nestful::Resource.new('http://example.com')['assets'][1].get(:format => :xml) #=> {:xml_hash => 1}
|
59
63
|
|
64
|
+
The Resource class also supports, post, json_post and json_get methods.
|
65
|
+
|
60
66
|
### Buffer download, return Tempfile
|
61
67
|
|
62
68
|
Nestful.get 'http://example.com/file.jpg', :buffer => true #=> <File ...>
|
@@ -79,4 +85,4 @@ Nestful uses ROAuth for OAuth support - check out supported options: http://gith
|
|
79
85
|
Nestful.get 'http://example.com', :oauth => {}
|
80
86
|
|
81
87
|
## Credits
|
82
|
-
Large parts of the connection code were taken from ActiveResource
|
88
|
+
Large parts of the connection code were taken from ActiveResource
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.0.
|
1
|
+
0.0.7
|
data/lib/nestful/formats.rb
CHANGED
@@ -15,6 +15,7 @@ module Nestful
|
|
15
15
|
end
|
16
16
|
|
17
17
|
autoload :BlankFormat, 'nestful/formats/blank_format'
|
18
|
+
autoload :TextFormat, 'nestful/formats/text_format'
|
18
19
|
autoload :MultipartFormat, 'nestful/formats/multipart_format'
|
19
20
|
autoload :FormFormat, 'nestful/formats/form_format'
|
20
21
|
autoload :XmlFormat, 'nestful/formats/xml_format'
|
@@ -28,4 +29,4 @@ module Nestful
|
|
28
29
|
Nestful::Formats.const_get(ActiveSupport::Inflector.camelize(mime_type_reference.to_s) + "Format")
|
29
30
|
end
|
30
31
|
end
|
31
|
-
end
|
32
|
+
end
|
data/lib/nestful/request.rb
CHANGED
@@ -7,7 +7,7 @@ module Nestful
|
|
7
7
|
end
|
8
8
|
|
9
9
|
attr_reader :url, :options, :format
|
10
|
-
attr_accessor :params, :body, :buffer, :method, :headers, :callbacks
|
10
|
+
attr_accessor :params, :body, :buffer, :method, :headers, :callbacks, :raw, :extension
|
11
11
|
|
12
12
|
# Connection options
|
13
13
|
attr_accessor :proxy, :user, :password, :auth_type, :timeout, :ssl_options
|
@@ -50,8 +50,9 @@ module Nestful
|
|
50
50
|
http_url = url.match(/^http/) ? url : "http://#{url}"
|
51
51
|
uri = URI.parse(http_url)
|
52
52
|
uri.path = "/" if uri.path.empty?
|
53
|
-
if
|
54
|
-
|
53
|
+
if extension
|
54
|
+
extension = format.extension if extension.is_a?(Boolean)
|
55
|
+
uri.path += ".#{extension}"
|
55
56
|
end
|
56
57
|
uri
|
57
58
|
end
|
@@ -73,9 +74,17 @@ module Nestful
|
|
73
74
|
callback(:before_request, self)
|
74
75
|
result = nil
|
75
76
|
if [:post, :put].include?(method)
|
76
|
-
connection.send(method, path, encoded, headers) {|res|
|
77
|
+
connection.send(method, path, encoded, headers) {|res|
|
78
|
+
result = decoded(res)
|
79
|
+
result.class_eval { attr_accessor :response }
|
80
|
+
result.response = res
|
81
|
+
}
|
77
82
|
else
|
78
|
-
connection.send(method, query_path, headers) {|res|
|
83
|
+
connection.send(method, query_path, headers) {|res|
|
84
|
+
result = decoded(res)
|
85
|
+
result.class_eval { attr_accessor :response }
|
86
|
+
result.response = res
|
87
|
+
}
|
79
88
|
end
|
80
89
|
callback(:after_request, self, result)
|
81
90
|
result
|
@@ -100,6 +109,7 @@ module Nestful
|
|
100
109
|
data.rewind
|
101
110
|
data
|
102
111
|
else
|
112
|
+
return result if raw
|
103
113
|
data = result.body
|
104
114
|
format ? format.decode(data) : data
|
105
115
|
end
|
@@ -129,4 +139,4 @@ module Nestful
|
|
129
139
|
class Request
|
130
140
|
include Callbacks
|
131
141
|
end
|
132
|
-
end
|
142
|
+
end
|
data/lib/nestful/resource.rb
CHANGED
@@ -12,7 +12,7 @@ module Nestful
|
|
12
12
|
suburl = suburl.to_s
|
13
13
|
base = url
|
14
14
|
base += "/" unless base =~ /\/$/
|
15
|
-
self.class.new(URI.join(base, suburl).to_s)
|
15
|
+
self.class.new(URI.join(base, suburl).to_s, @options)
|
16
16
|
end
|
17
17
|
|
18
18
|
def get(options = {})
|
@@ -31,4 +31,4 @@ module Nestful
|
|
31
31
|
post(:format => :json, :params => params)
|
32
32
|
end
|
33
33
|
end
|
34
|
-
end
|
34
|
+
end
|
metadata
CHANGED
@@ -1,48 +1,34 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: nestful
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
5
|
-
|
6
|
-
- 0
|
7
|
-
- 0
|
8
|
-
- 6
|
9
|
-
version: 0.0.6
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.7
|
5
|
+
prerelease:
|
10
6
|
platform: ruby
|
11
|
-
authors:
|
7
|
+
authors:
|
12
8
|
- Alex MacCaw
|
13
9
|
autorequire:
|
14
10
|
bindir: bin
|
15
11
|
cert_chain: []
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
dependencies:
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2011-08-15 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: activesupport
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70154433041120 !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
26
|
-
- -
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
segments:
|
29
|
-
- 3
|
30
|
-
- 0
|
31
|
-
- 0
|
32
|
-
- beta
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
33
21
|
version: 3.0.0.beta
|
34
22
|
type: :runtime
|
35
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70154433041120
|
36
25
|
description: Simple Ruby HTTP/REST client with a sane API
|
37
26
|
email: info@eribium.org
|
38
27
|
executables: []
|
39
|
-
|
40
28
|
extensions: []
|
41
|
-
|
42
|
-
extra_rdoc_files:
|
29
|
+
extra_rdoc_files:
|
43
30
|
- README.markdown
|
44
|
-
files:
|
45
|
-
- .gitignore
|
31
|
+
files:
|
46
32
|
- MIT-LICENSE
|
47
33
|
- README.markdown
|
48
34
|
- Rakefile
|
@@ -55,43 +41,35 @@ files:
|
|
55
41
|
- lib/nestful/formats/form_format.rb
|
56
42
|
- lib/nestful/formats/json_format.rb
|
57
43
|
- lib/nestful/formats/multipart_format.rb
|
44
|
+
- lib/nestful/formats/text_format.rb
|
58
45
|
- lib/nestful/formats/xml_format.rb
|
59
46
|
- lib/nestful/oauth.rb
|
60
47
|
- lib/nestful/request.rb
|
61
48
|
- lib/nestful/request/callbacks.rb
|
62
49
|
- lib/nestful/resource.rb
|
63
50
|
- nestful.gemspec
|
64
|
-
has_rdoc: true
|
65
51
|
homepage: http://github.com/maccman/nestful
|
66
52
|
licenses: []
|
67
|
-
|
68
53
|
post_install_message:
|
69
|
-
rdoc_options:
|
70
|
-
|
71
|
-
require_paths:
|
54
|
+
rdoc_options: []
|
55
|
+
require_paths:
|
72
56
|
- lib
|
73
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
57
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
58
|
none: false
|
75
|
-
requirements:
|
76
|
-
- -
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
|
79
|
-
|
80
|
-
version: "0"
|
81
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '0'
|
63
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
64
|
none: false
|
83
|
-
requirements:
|
84
|
-
- -
|
85
|
-
- !ruby/object:Gem::Version
|
86
|
-
|
87
|
-
- 0
|
88
|
-
version: "0"
|
65
|
+
requirements:
|
66
|
+
- - ! '>='
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
89
69
|
requirements: []
|
90
|
-
|
91
70
|
rubyforge_project:
|
92
|
-
rubygems_version: 1.
|
71
|
+
rubygems_version: 1.8.6
|
93
72
|
signing_key:
|
94
73
|
specification_version: 3
|
95
74
|
summary: Simple Ruby HTTP/REST client with a sane API
|
96
75
|
test_files: []
|
97
|
-
|
data/.gitignore
DELETED