reststop 0.2.0 → 0.2.0.50
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/CHANGELOG.txt +7 -0
- data/History.txt +1 -0
- data/Manifest.txt +1 -0
- data/README.txt +7 -10
- data/Rakefile +3 -2
- data/lib/restr.rb +3 -3
- data/lib/reststop.rb +28 -15
- metadata +46 -37
data/CHANGELOG.txt
CHANGED
@@ -1,3 +1,9 @@
|
|
1
|
+
=== 0.2.1 :: In Progress...
|
2
|
+
|
3
|
+
* Restr should now work properly with Rails 2.x (fixes bug #17421).
|
4
|
+
* R helper method should now work properly when a Restful object is fed as
|
5
|
+
input along with a custom action.
|
6
|
+
|
1
7
|
=== 0.2.0 :: 2007-12-10
|
2
8
|
|
3
9
|
* It is now possible to specify the format for rendering a page by appending
|
@@ -17,6 +23,7 @@
|
|
17
23
|
* Pages now correctly return HTTP status code 501 when an unimplemented controller
|
18
24
|
method is called. ActiveRecord::NotFound exceptions are caught and return 404
|
19
25
|
status.
|
26
|
+
* R helper now works for routing RESTful controllers.
|
20
27
|
|
21
28
|
=== 0.1.0 :: 2007-07-30
|
22
29
|
|
data/History.txt
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
See CHANGELOG.txt
|
data/Manifest.txt
CHANGED
data/README.txt
CHANGED
@@ -1,18 +1,15 @@
|
|
1
1
|
= Reststop
|
2
2
|
|
3
|
-
<
|
4
|
-
|
5
|
-
For info and downloads please see:
|
3
|
+
<b>Reststop makes it easy to write RESTful[http://en.wikipedia.org/wiki/Representational_State_Transfer]
|
4
|
+
applications in Camping[http://camping.rubyforge.org/files/README.html].</b>
|
6
5
|
|
7
|
-
|
6
|
+
For info and downloads please see http://rubyforge.org/projects/reststop
|
8
7
|
|
9
|
-
You can contact the author at:
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
*Author*:: Matt Zukowski (matt at roughest dot net)
|
10
|
+
*Copyright*:: Copyright (c) 2007 Urbacon Ltd.
|
11
|
+
*License*:: GNU Lesser General Public License Version 3
|
13
12
|
|
14
|
-
<b>Reststop makes it easy to write RESTful[http://en.wikipedia.org/wiki/Representational_State_Transfer]
|
15
|
-
applications in Camping[http://camping.rubyforge.org/files/README.html].</b>
|
16
13
|
|
17
14
|
For an example of a complete Reststop-based Camping app, have a look at
|
18
15
|
http://reststop.rubyforge.org/svn/trunk/examples/blog.rb
|
@@ -98,7 +95,7 @@ example of RESTful interaction with Restr:
|
|
98
95
|
kitten = Restr.put('http://example.com/kittens/1.xml', kitten)
|
99
96
|
|
100
97
|
|
101
|
-
|
98
|
+
== License
|
102
99
|
|
103
100
|
Reststop is free software; you can redistribute it and/or modify
|
104
101
|
it under the terms of the GNU Lesser General Public License as published
|
data/Rakefile
CHANGED
@@ -18,10 +18,11 @@ GEM_NAME = "reststop"
|
|
18
18
|
RUBYFORGE_PROJECT = "reststop" # The unix name for your project
|
19
19
|
HOMEPATH = "http://#{RUBYFORGE_PROJECT}.rubyforge.org"
|
20
20
|
|
21
|
+
ENV['NODOT'] = '1'
|
21
22
|
|
22
23
|
NAME = "reststop"
|
23
|
-
REV = nil
|
24
|
-
|
24
|
+
#REV = nil
|
25
|
+
REV = `svn info`[/Revision: (\d+)/, 1] rescue nil
|
25
26
|
VERS = ENV['VERSION'] || (Reststop::VERSION::STRING + (REV ? ".#{REV}" : ""))
|
26
27
|
CLEAN.include ['**/.*.sw?', '*.gem', '.config']
|
27
28
|
RDOC_OPTS = ['--quiet', '--title', "#{NAME} #{VERS} documentation",
|
data/lib/restr.rb
CHANGED
@@ -90,7 +90,7 @@ class Restr
|
|
90
90
|
end
|
91
91
|
|
92
92
|
unless method_mod == 'Get'
|
93
|
-
req.set_form_data(params, '
|
93
|
+
req.set_form_data(params, '&')
|
94
94
|
end
|
95
95
|
|
96
96
|
@@log.debug("Sending #{method.inspect} request to #{url.inspect} with data #{params.inspect}"+
|
@@ -115,8 +115,8 @@ class Restr
|
|
115
115
|
return res.body
|
116
116
|
end
|
117
117
|
else
|
118
|
-
$LAST_ERROR_BODY = res.body # FIXME: this is dumb
|
119
|
-
@@log.error("Got error
|
118
|
+
$LAST_ERROR_BODY = res.body # FIXME: this is dumb... need a better way of reporting errors
|
119
|
+
@@log.error("Got error response '#{res.message}(#{res.code})': #{$LAST_ERROR_BODY}") if @@log
|
120
120
|
res.error!
|
121
121
|
end
|
122
122
|
end
|
data/lib/reststop.rb
CHANGED
@@ -100,12 +100,12 @@ module Camping
|
|
100
100
|
# The format can also be specified in other ways (shown in this order
|
101
101
|
# of precedence):
|
102
102
|
#
|
103
|
-
#
|
104
|
-
#
|
105
|
-
#
|
106
|
-
#
|
107
|
-
#
|
108
|
-
#
|
103
|
+
# 1. By providing a second parameter to render()
|
104
|
+
# (eg: <tt>render(:foo, :HTML)</tt>)
|
105
|
+
# 2. By setting the @format variable
|
106
|
+
# 3. By providing a 'format' parameter in the request (i.e. @input[:format])
|
107
|
+
# 4. By adding a file-format extension to the url (e.g. /items.xml or
|
108
|
+
# /items/2.html).
|
109
109
|
#
|
110
110
|
# For example, you could have:
|
111
111
|
#
|
@@ -237,8 +237,8 @@ module Camping
|
|
237
237
|
# * list
|
238
238
|
#
|
239
239
|
# Routes will be automatically created based on the resource name fed to the
|
240
|
-
# REST method.
|
241
|
-
# name as the resource name
|
240
|
+
# REST method. <b>Your class must have the same (but CamelCaps'ed)
|
241
|
+
# name as the resource name.</b> So if your resource name is 'kittens',
|
242
242
|
# your controller class must be Kittens.
|
243
243
|
#
|
244
244
|
# For example:
|
@@ -267,11 +267,22 @@ module Camping
|
|
267
267
|
# end
|
268
268
|
# end
|
269
269
|
#
|
270
|
+
# Custom actions are also possible. For example, to implement a 'meow'
|
271
|
+
# action simply add a 'meow' method to the above controller:
|
270
272
|
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
274
|
-
#
|
273
|
+
# # POST/GET/PUT/DELETE /kittens/meow
|
274
|
+
# # POST/GET/PUT/DELETE /kittens/(\d+)/meow
|
275
|
+
# def meow(id)
|
276
|
+
# end
|
277
|
+
#
|
278
|
+
# Note that a custom action will respond to all four HTTP methods
|
279
|
+
# (POST/GET/PUT/DELETE).
|
280
|
+
#
|
281
|
+
# Optionally, you can specify a <tt>:prefix</tt> key that will prepend the
|
282
|
+
# given string to the routes. For example, the following will create all
|
283
|
+
# of the above routes, prefixed with "/pets"
|
284
|
+
# (i.e. <tt>POST '/pets/kittens'</tt>, <tt>GET '/pets/kittens/(\d+)'</tt>,
|
285
|
+
# etc.):
|
275
286
|
#
|
276
287
|
# module Foobar::Controllers
|
277
288
|
# class Items < REST 'kittens', :prefix => '/pets'
|
@@ -279,8 +290,9 @@ module Camping
|
|
279
290
|
# end
|
280
291
|
# end
|
281
292
|
#
|
282
|
-
#
|
283
|
-
# a list of kittens in XML format, place a
|
293
|
+
# Format-based routing similar to that in ActiveResource is also implemented.
|
294
|
+
# For example, to get a list of kittens in XML format, place a
|
295
|
+
# <tt>GET</tt> call to <tt>/kittens.xml</tt>.
|
284
296
|
# See the documentation for the render() method for more info.
|
285
297
|
#
|
286
298
|
def REST(r, options = {})
|
@@ -402,7 +414,8 @@ module Camping
|
|
402
414
|
if Controllers.constants.include?(cl = c.class.name.split("::").last.pluralize)
|
403
415
|
path = "/#{cl.underscore}/#{c.id}"
|
404
416
|
path << ".#{@format.to_s.downcase}" if @format
|
405
|
-
path << "
|
417
|
+
path << "/#{g.shift}" unless g.empty?
|
418
|
+
# FIXME: undefined behaviour if there are multiple arguments left... maybe we should allow for arbitrary params as a Hash?
|
406
419
|
self / path
|
407
420
|
elsif c.respond_to?(:restful?) && c.restful?
|
408
421
|
base = c.name.split("::").last.underscore
|
metadata
CHANGED
@@ -1,35 +1,33 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
|
-
rubygems_version: 0.9.2
|
3
|
-
specification_version: 1
|
4
2
|
name: reststop
|
5
3
|
version: !ruby/object:Gem::Version
|
6
|
-
version: 0.2.0
|
7
|
-
date: 2007-12-18 00:00:00 -05:00
|
8
|
-
summary: Convenient RESTfulness for all your Camping needs (i.e. makes it easy to implement RESTful controllers in Camping).
|
9
|
-
require_paths:
|
10
|
-
- lib
|
11
|
-
email: matt@roughest.net
|
12
|
-
homepage: http://reststop.rubyforge.org
|
13
|
-
rubyforge_project: reststop
|
14
|
-
description: Convenient RESTfulness for all your Camping needs (i.e. makes it easy to implement RESTful controllers in Camping).
|
15
|
-
autorequire:
|
16
|
-
default_executable:
|
17
|
-
bindir: bin
|
18
|
-
has_rdoc: true
|
19
|
-
required_ruby_version: !ruby/object:Gem::Version::Requirement
|
20
|
-
requirements:
|
21
|
-
- - ">"
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version: 0.0.0
|
24
|
-
version:
|
4
|
+
version: 0.2.0.50
|
25
5
|
platform: ruby
|
26
|
-
signing_key:
|
27
|
-
cert_chain:
|
28
|
-
post_install_message:
|
29
6
|
authors:
|
30
7
|
- Matt Zukowski
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
|
12
|
+
date: 2008-03-10 00:00:00 -04:00
|
13
|
+
default_executable:
|
14
|
+
dependencies: []
|
15
|
+
|
16
|
+
description: Convenient RESTfulness for all your Camping needs (i.e. makes it easy to implement RESTful controllers in Camping).
|
17
|
+
email: matt@roughest.net
|
18
|
+
executables: []
|
19
|
+
|
20
|
+
extensions: []
|
21
|
+
|
22
|
+
extra_rdoc_files:
|
23
|
+
- CHANGELOG.txt
|
24
|
+
- History.txt
|
25
|
+
- LICENSE.txt
|
26
|
+
- Manifest.txt
|
27
|
+
- README.txt
|
31
28
|
files:
|
32
29
|
- CHANGELOG.txt
|
30
|
+
- History.txt
|
33
31
|
- LICENSE.txt
|
34
32
|
- Manifest.txt
|
35
33
|
- README.txt
|
@@ -41,21 +39,32 @@ files:
|
|
41
39
|
- setup.rb
|
42
40
|
- test/reststop_test.rb
|
43
41
|
- test/test_helper.rb
|
44
|
-
|
45
|
-
|
42
|
+
has_rdoc: true
|
43
|
+
homepage: http://reststop.rubyforge.org
|
44
|
+
post_install_message:
|
46
45
|
rdoc_options:
|
47
46
|
- --main
|
48
47
|
- README.txt
|
49
|
-
|
50
|
-
-
|
51
|
-
|
52
|
-
|
53
|
-
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: "0"
|
55
|
+
version:
|
56
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - ">="
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: "0"
|
61
|
+
version:
|
58
62
|
requirements: []
|
59
63
|
|
60
|
-
|
61
|
-
|
64
|
+
rubyforge_project: reststop
|
65
|
+
rubygems_version: 1.0.1
|
66
|
+
signing_key:
|
67
|
+
specification_version: 2
|
68
|
+
summary: Convenient RESTfulness for all your Camping needs (i.e. makes it easy to implement RESTful controllers in Camping).
|
69
|
+
test_files:
|
70
|
+
- test/reststop_test.rb
|