rackful 0.1.1 → 0.1.2
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/RACKFUL.md +3 -3
- data/lib/rackful_path.rb +8 -1
- data/lib/rackful_resource.rb +44 -51
- data/lib/rackful_serializer.rb +1 -0
- data/lib/rackful_server.rb +1 -1
- data/mkdoc.sh +1 -1
- data/rackful.gemspec +1 -1
- metadata +47 -44
data/RACKFUL.md
CHANGED
@@ -143,9 +143,9 @@ response body, the server kindly points out exactly which precondition.
|
|
143
143
|
Further reading
|
144
144
|
---------------
|
145
145
|
* {Rackful::Server#initialize} for more information about your Resource Factory.
|
146
|
-
* {Rackful::Resource#
|
146
|
+
* {Rackful::Resource#get\_etag} and {Rackful::Resource#get\_last\_modified} for more information on
|
147
147
|
conditional requests.
|
148
|
-
* {Rackful::Resource#
|
148
|
+
* {Rackful::Resource#do\_METHOD} for more information about writing your own request
|
149
149
|
handlers.
|
150
150
|
* {Rackful::RelativeLocation} for more information about this piece of Rack middleware
|
151
151
|
which allows you to return relative and absolute paths in the `Location:`
|
@@ -155,5 +155,5 @@ Licensing
|
|
155
155
|
---------
|
156
156
|
Copyright ©2011-2012 Pieter van Beek <pieterb@sara.nl>
|
157
157
|
|
158
|
-
Licensed under the Apache License 2.0. You should have received a copy of the
|
158
|
+
Licensed under the {file:LICENSE.md Apache License 2.0}. You should have received a copy of the
|
159
159
|
license as part of this distribution.
|
data/lib/rackful_path.rb
CHANGED
@@ -49,6 +49,13 @@ class Path < String
|
|
49
49
|
|
50
50
|
# An alias for Rack::Utils.unescape
|
51
51
|
def unescape( encoding = Encoding::UTF_8 ); Rack::Utils.unescape(self, encoding); end
|
52
|
+
|
53
|
+
# @return [Array<String>] An array of unencoded segments
|
54
|
+
def segments
|
55
|
+
r = self.split('/').collect { |s| Rack::Utils.unescape( s, Encoding::UTF_8 ) }
|
56
|
+
r.shift
|
57
|
+
r
|
58
|
+
end
|
52
59
|
|
53
60
|
end # class Path
|
54
61
|
|
@@ -106,7 +113,7 @@ class URI::Generic
|
|
106
113
|
end
|
107
114
|
|
108
115
|
end # class ::URI::Generic
|
109
|
-
=end
|
116
|
+
=end
|
110
117
|
|
111
118
|
|
112
119
|
|
data/lib/rackful_resource.rb
CHANGED
@@ -31,17 +31,15 @@ module Resource
|
|
31
31
|
module ClassMethods
|
32
32
|
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
add_serializer
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@return [self]
|
44
|
-
=end
|
34
|
+
#Meta-programmer method.
|
35
|
+
#@example Have your resource rendered in XML and JSON
|
36
|
+
# class MyResource
|
37
|
+
# add_serializer MyResource2XML
|
38
|
+
# add_serializer MyResource2JSON, 0.5
|
39
|
+
# end
|
40
|
+
#@param serializer [Serializer]
|
41
|
+
#@param quality [Float]
|
42
|
+
#@return [self]
|
45
43
|
def add_serializer serializer, quality = 1.0
|
46
44
|
quality = quality.to_f
|
47
45
|
quality = 1.0 if quality > 1.0
|
@@ -74,17 +72,15 @@ Meta-programmer method.
|
|
74
72
|
end
|
75
73
|
|
76
74
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
add_parser
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
@return [self]
|
87
|
-
=end
|
75
|
+
#Meta-programmer method.
|
76
|
+
#@example Have your resource accept XML and JSON in `PUT` requests
|
77
|
+
# class MyResource
|
78
|
+
# add_parser XML2MyResource, :PUT
|
79
|
+
# add_parser JSON2MyResource, :PUT
|
80
|
+
# end
|
81
|
+
#@param parser [Parser]
|
82
|
+
#@param method [#to_sym]
|
83
|
+
#@return [self]
|
88
84
|
def add_media_type media_type, method = :PUT
|
89
85
|
method = method.to_sym
|
90
86
|
self.media_types[method] ||= []
|
@@ -146,18 +142,16 @@ The best media type for the response body, given the current HTTP request.
|
|
146
142
|
end
|
147
143
|
|
148
144
|
|
149
|
-
#
|
150
|
-
# @param
|
151
|
-
# @
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
# parsers[method][request.media_type].new( request )
|
160
|
-
# end
|
145
|
+
#~ # @param content_type [String]
|
146
|
+
#~ # @param method [#to_s]
|
147
|
+
#~ # @return [Serializer]
|
148
|
+
#~ def parser request
|
149
|
+
#~ method = request.request_method.upcase.to_sym
|
150
|
+
#~ if !parsers[method] || !parsers[method][request.media_type]
|
151
|
+
#~ raise HTTP415UnsupportedMediaType, ( parsers[method] ? parsers[method].keys : [] )
|
152
|
+
#~ end
|
153
|
+
#~ parsers[method][request.media_type].new( request )
|
154
|
+
#~ end
|
161
155
|
|
162
156
|
|
163
157
|
end # module ClassMethods
|
@@ -178,22 +172,21 @@ The best media type for the response body, given the current HTTP request.
|
|
178
172
|
@return [#to_json, #each_pair]
|
179
173
|
=end
|
180
174
|
|
181
|
-
|
182
|
-
@!method do_METHOD( Request, Rack::Response )
|
183
|
-
HTTP/1.1 method handler.
|
184
|
-
|
185
|
-
To handle certain HTTP/1.1 request methods, resources must implement methods
|
186
|
-
called `do_<HTTP_METHOD>`.
|
187
|
-
@example Handling `PATCH` requests
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
@abstract
|
193
|
-
@return [void]
|
194
|
-
@raise [HTTPStatus, RuntimeError]
|
195
|
-
@since 0.0.1
|
196
|
-
=end
|
175
|
+
|
176
|
+
# @!method do_METHOD( Request, Rack::Response )
|
177
|
+
# HTTP/1.1 method handler.
|
178
|
+
#
|
179
|
+
# To handle certain HTTP/1.1 request methods, resources must implement methods
|
180
|
+
# called `do_<HTTP_METHOD>`.
|
181
|
+
# @example Handling `PATCH` requests
|
182
|
+
# def do_PATCH request, response
|
183
|
+
# response['Content-Type'] = 'text/plain'
|
184
|
+
# response.body = [ 'Hello world!' ]
|
185
|
+
# end
|
186
|
+
# @abstract
|
187
|
+
# @return [void]
|
188
|
+
# @raise [HTTPStatus, RuntimeError]
|
189
|
+
# @since 0.0.1
|
197
190
|
|
198
191
|
|
199
192
|
=begin markdown
|
@@ -206,7 +199,7 @@ The path of this resource.
|
|
206
199
|
|
207
200
|
|
208
201
|
def path= path
|
209
|
-
@path =
|
202
|
+
@path = path.to_s.to_path
|
210
203
|
end
|
211
204
|
|
212
205
|
|
data/lib/rackful_serializer.rb
CHANGED
data/lib/rackful_server.rb
CHANGED
data/mkdoc.sh
CHANGED
data/rackful.gemspec
CHANGED
@@ -2,7 +2,7 @@ Gem::Specification.new do |s|
|
|
2
2
|
|
3
3
|
# Required properties:
|
4
4
|
s.name = 'rackful'
|
5
|
-
s.version = '0.1.
|
5
|
+
s.version = '0.1.2'
|
6
6
|
s.summary = "Library for building ReSTful web services with Rack"
|
7
7
|
s.description = <<EOS
|
8
8
|
Rackful provides a minimal interface for developing ReSTful web services with
|
metadata
CHANGED
@@ -1,85 +1,88 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rackful
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.1
|
3
|
+
version: !ruby/object:Gem::Version
|
5
4
|
prerelease:
|
5
|
+
version: 0.1.2
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Pieter van Beek
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
12
|
+
|
13
|
+
date: 2012-10-11 00:00:00 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
15
16
|
name: rack
|
16
|
-
|
17
|
+
prerelease: false
|
18
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
17
19
|
none: false
|
18
|
-
requirements:
|
19
|
-
- -
|
20
|
-
- !ruby/object:Gem::Version
|
21
|
-
version:
|
20
|
+
requirements:
|
21
|
+
- - ">="
|
22
|
+
- !ruby/object:Gem::Version
|
23
|
+
version: "1.4"
|
22
24
|
type: :runtime
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
Rack and Ruby. Instead of writing HTTP method handlers, you''ll implement
|
29
|
-
|
25
|
+
version_requirements: *id001
|
26
|
+
description: |
|
27
|
+
Rackful provides a minimal interface for developing ReSTful web services with
|
28
|
+
Rack and Ruby. Instead of writing HTTP method handlers, you'll implement
|
30
29
|
resource objects, which expose their state at URLs.
|
31
|
-
|
32
|
-
|
30
|
+
|
33
31
|
This version is NOT backward compatible with versions 0.0.x.
|
34
32
|
|
35
|
-
'
|
36
33
|
email: rackful@djinnit.com
|
37
34
|
executables: []
|
35
|
+
|
38
36
|
extensions: []
|
37
|
+
|
39
38
|
extra_rdoc_files: []
|
40
|
-
|
41
|
-
|
42
|
-
- LICENSE.md
|
39
|
+
|
40
|
+
files:
|
43
41
|
- RACKFUL.md
|
44
42
|
- README.md
|
45
|
-
-
|
43
|
+
- LICENSE.md
|
44
|
+
- CHANGES.md
|
46
45
|
- example/config2.ru
|
47
|
-
-
|
46
|
+
- example/config.ru
|
47
|
+
- lib/rackful_request.rb
|
48
|
+
- lib/rackful_path.rb
|
48
49
|
- lib/rackful/method_spoofing.rb
|
50
|
+
- lib/rackful/header_spoofing.rb
|
49
51
|
- lib/rackful/relative_location.rb
|
50
|
-
- lib/rackful.rb
|
51
52
|
- lib/rackful_http_status.rb
|
52
|
-
- lib/
|
53
|
-
- lib/
|
53
|
+
- lib/rackful_server.rb
|
54
|
+
- lib/rackful.rb
|
54
55
|
- lib/rackful_resource.rb
|
55
56
|
- lib/rackful_serializer.rb
|
56
|
-
- lib/rackful_server.rb
|
57
57
|
- rackful.gemspec
|
58
58
|
- mkdoc.sh
|
59
59
|
homepage: http://pieterb.github.com/Rackful/
|
60
|
-
licenses:
|
60
|
+
licenses:
|
61
61
|
- Apache License 2.0
|
62
62
|
post_install_message:
|
63
63
|
rdoc_options: []
|
64
|
-
|
64
|
+
|
65
|
+
require_paths:
|
65
66
|
- lib
|
66
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
67
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
67
68
|
none: false
|
68
|
-
requirements:
|
69
|
-
- -
|
70
|
-
- !ruby/object:Gem::Version
|
71
|
-
version:
|
72
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
69
|
+
requirements:
|
70
|
+
- - ">="
|
71
|
+
- !ruby/object:Gem::Version
|
72
|
+
version: "0"
|
73
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
73
74
|
none: false
|
74
|
-
requirements:
|
75
|
-
- -
|
76
|
-
- !ruby/object:Gem::Version
|
77
|
-
version:
|
75
|
+
requirements:
|
76
|
+
- - ">="
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: "0"
|
78
79
|
requirements: []
|
80
|
+
|
79
81
|
rubyforge_project:
|
80
|
-
rubygems_version: 1.8.
|
82
|
+
rubygems_version: 1.8.24
|
81
83
|
signing_key:
|
82
84
|
specification_version: 3
|
83
85
|
summary: Library for building ReSTful web services with Rack
|
84
86
|
test_files: []
|
87
|
+
|
85
88
|
has_rdoc:
|