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 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#get_etag} and {Rackful::Resource#get_last_modified} for more information on
146
+ * {Rackful::Resource#get\_etag} and {Rackful::Resource#get\_last\_modified} for more information on
147
147
  conditional requests.
148
- * {Rackful::Resource#do_METHOD} for more information about writing your own request
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 comment
116
+ =end
110
117
 
111
118
 
112
119
 
@@ -31,17 +31,15 @@ module Resource
31
31
  module ClassMethods
32
32
 
33
33
 
34
- =begin markdown
35
- Meta-programmer method.
36
- @example Have your resource rendered in XML and JSON
37
- class MyResource
38
- add_serializer MyResource2XML
39
- add_serializer MyResource2JSON, 0.5
40
- end
41
- @param serializer [Serializer]
42
- @param quality [Float]
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
- =begin markdown
78
- Meta-programmer method.
79
- @example Have your resource accept XML and JSON in `PUT` requests
80
- class MyResource
81
- add_parser XML2MyResource, :PUT
82
- add_parser JSON2MyResource, :PUT
83
- end
84
- @param parser [Parser]
85
- @param method [#to_sym]
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
- # =begin markdown
150
- # @param content_type [String]
151
- # @param method [#to_s]
152
- # @return [Serializer]
153
- # =end
154
- # def parser request
155
- # method = request.request_method.upcase.to_sym
156
- # if !parsers[method] || !parsers[method][request.media_type]
157
- # raise HTTP415UnsupportedMediaType, ( parsers[method] ? parsers[method].keys : [] )
158
- # end
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
- =begin markdown
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
- def do_PATCH request, response
189
- response['Content-Type'] = 'text/plain'
190
- response.body = [ 'Hello world!' ]
191
- end
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 = Path.new(path.to_s)
202
+ @path = path.to_s.to_path
210
203
  end
211
204
 
212
205
 
@@ -36,6 +36,7 @@ class Serializer
36
36
  Every serializer must implement this method.
37
37
  @abstract
38
38
  @since 0.1.0
39
+ @yield [data] the entity body
39
40
  =end
40
41
  def each
41
42
  raise HTTP500InternalServerError, "Class #{self.class} doesn't implement #each()."
@@ -41,7 +41,7 @@ If there's no resource at the given path, but you'd still like to respond to
41
41
 
42
42
 
43
43
  =begin markdown
44
- {include:Server#resource_factory}
44
+ @param resource_factory [#[]] see Server#resource_factory
45
45
  @since 0.0.1
46
46
  =end
47
47
  def initialize(resource_factory)
data/mkdoc.sh CHANGED
@@ -2,5 +2,5 @@
2
2
 
3
3
  cd "`dirname "$0"`"
4
4
 
5
- rm -rf docs/* .yardoc/
5
+ rm -rf doc/* .yardoc/
6
6
  exec yard "$@"
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.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
- date: 2012-08-05 00:00:00.000000000Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
12
+
13
+ date: 2012-10-11 00:00:00 Z
14
+ dependencies:
15
+ - !ruby/object:Gem::Dependency
15
16
  name: rack
16
- requirement: &70177120280540 !ruby/object:Gem::Requirement
17
+ prerelease: false
18
+ requirement: &id001 !ruby/object:Gem::Requirement
17
19
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '1.4'
20
+ requirements:
21
+ - - ">="
22
+ - !ruby/object:Gem::Version
23
+ version: "1.4"
22
24
  type: :runtime
23
- prerelease: false
24
- version_requirements: *70177120280540
25
- description: ! 'Rackful provides a minimal interface for developing ReSTful web services
26
- with
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
- files:
41
- - CHANGES.md
42
- - LICENSE.md
39
+
40
+ files:
43
41
  - RACKFUL.md
44
42
  - README.md
45
- - example/config.ru
43
+ - LICENSE.md
44
+ - CHANGES.md
46
45
  - example/config2.ru
47
- - lib/rackful/header_spoofing.rb
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/rackful_path.rb
53
- - lib/rackful_request.rb
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
- require_paths:
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: '0'
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: '0'
75
+ requirements:
76
+ - - ">="
77
+ - !ruby/object:Gem::Version
78
+ version: "0"
78
79
  requirements: []
80
+
79
81
  rubyforge_project:
80
- rubygems_version: 1.8.10
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: