restrack 0.1.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +0 -0
- data/README.markdown +14 -13
- data/lib/restrack/generator/config.ru.erb +0 -0
- data/lib/restrack/support.rb +4 -4
- data/lib/restrack/version.rb +1 -1
- data/restrack.gemspec +0 -0
- metadata +2 -2
data/Gemfile
CHANGED
File without changes
|
data/README.markdown
CHANGED
@@ -27,7 +27,7 @@ requests will then render the view template with the builder gem, rather than ge
|
|
27
27
|
development of lightweight data services as easy as possible, while still giving you a performant and extensible
|
28
28
|
framework. The primary goal of of the development of RESTRack was to add as little as possible to the framework to give
|
29
29
|
the web developer a good application space for developing JSON and XML services.
|
30
|
-
|
30
|
+
|
31
31
|
Rails 3 instantiates approximately 80K more objects than RESTRack to do a hello world or nothing type response with
|
32
32
|
the default setup. Trimming Rails down by eliminating ActiveRecord, ActionMailer, and ActiveResource, it still
|
33
33
|
instantiates over 47K more objects than RESTRack.
|
@@ -38,7 +38,7 @@ instantiates over 47K more objects than RESTRack.
|
|
38
38
|
- restrack generate service foo\_bar
|
39
39
|
- restrack gen serv foo\_bar
|
40
40
|
- restrack g s foo\_bar
|
41
|
-
|
41
|
+
|
42
42
|
### Generate a new controller \(FooBar::BazController\)
|
43
43
|
- restrack generate controller baz
|
44
44
|
- restrack gen cont baz
|
@@ -47,10 +47,10 @@ instantiates over 47K more objects than RESTRack.
|
|
47
47
|
### Generate a new controller that descends from another \(FooBar::NewController < FooBar::BazController\)
|
48
48
|
- restrack generate controller new descendant\_from baz
|
49
49
|
- restrack g controller new parent baz
|
50
|
-
|
50
|
+
|
51
51
|
### Start up a server on default rackup port 9292
|
52
52
|
- restrack server
|
53
|
-
|
53
|
+
|
54
54
|
### Start up a server on port 3456
|
55
55
|
- restrack server 3456
|
56
56
|
- restrack s 3456
|
@@ -69,14 +69,14 @@ supported\(\*\).
|
|
69
69
|
RESTRack enforces a strict URL pattern through the contruct of controller relationships, rather than a routing file.
|
70
70
|
Defining a controller for a resource means that you plan to expose that resource to requests to your service.
|
71
71
|
Defining a controller relationship means that you plan to expose a path from this resource to another.
|
72
|
-
|
72
|
+
|
73
73
|
### "pass\_through\_to"
|
74
74
|
An open, or pass-through, path can be defined via the "pass\_through\_to" class method for resource controllers. This
|
75
75
|
exposes URL patterns like the following:
|
76
|
-
|
76
|
+
|
77
77
|
GET /foo/123/bar/234 <= simple pass-through from Foo 123 to show Bar 234
|
78
78
|
GET /foo/123/bar <= simple pass-through from Foo 123 to Bar index
|
79
|
-
|
79
|
+
|
80
80
|
### "has\_relationship\_to"
|
81
81
|
A direct path to a single related resource's controller can be defined with the "has\_relationship\_to" method. This
|
82
82
|
allows you to define a one-to-one relationship from this resource to a related resource, which means that the id of
|
@@ -93,7 +93,7 @@ This exposes URL patterns like the following:
|
|
93
93
|
GET /people/Sally/spouse <= direct route to show Sally's spouse
|
94
94
|
PUT /people/Henry/spouse <= direct route to update Henry's spouse
|
95
95
|
POST /people/Jane/spouse <= direct route to add Jane's spouse
|
96
|
-
|
96
|
+
|
97
97
|
### "has\_relationships\_to" and "has\_defined\_relationships\_to"
|
98
98
|
A direct path to many related resources' controller can be defined with the "has\_relationships\_to" and
|
99
99
|
"has\_defined\_relationships\_to" methods. These allows you to define one-to-many relationships. They work similar to
|
@@ -120,7 +120,7 @@ exposes URL patterns:
|
|
120
120
|
|
121
121
|
GET /people/Nancy/children/George <= route to show child George
|
122
122
|
DELETE /people/Robert/children/Jerry <= route to destroy child Jerry
|
123
|
-
|
123
|
+
|
124
124
|
### "has\_mapped\_relationships\_to"
|
125
125
|
Multiple named one-to-many relationships can be exposed with the "has\_mapped\_relationships\_to" method. This allows
|
126
126
|
you to define many named or keyword paths to related resources. The method's code block should accepts the parent id
|
@@ -158,12 +158,13 @@ by setting :DEFAULT_FORMAT to :XML in `config/constants.yml`.
|
|
158
158
|
|
159
159
|
### With XmlSimple
|
160
160
|
RESTRack will attempt to serialize the data structures that your action methods return automatically using the
|
161
|
-
xml-simple gem.
|
162
|
-
|
161
|
+
xml-simple gem. Complex objects may not serialize correctly, or you may want to define a particular structure for your
|
162
|
+
XML, in which case a builder template should be defined (see next heading).
|
163
|
+
|
163
164
|
### With Builder
|
164
|
-
Custom XML serialization can be done by providing Builder gem templates in `views/<controller>/<action>.xml.builder`.
|
165
|
+
Custom XML serialization can be done by providing [Builder](http://builder.rubyforge.org/) gem templates in `views/<controller>/<action>.xml.builder`.
|
166
|
+
|
165
167
|
|
166
|
-
|
167
168
|
## Inputs
|
168
169
|
|
169
170
|
### Query string parameters
|
File without changes
|
data/lib/restrack/support.rb
CHANGED
@@ -37,7 +37,7 @@ module RESTRack
|
|
37
37
|
return false
|
38
38
|
end
|
39
39
|
end
|
40
|
-
|
40
|
+
|
41
41
|
def self.controller_class_for(resource_name)
|
42
42
|
Kernel.const_get( RESTRack::CONFIG[:SERVICE_NAME].to_sym ).const_get( controller_name(resource_name).to_sym )
|
43
43
|
end
|
@@ -45,16 +45,16 @@ module RESTRack
|
|
45
45
|
def self.controller_name(resource_name)
|
46
46
|
"#{resource_name.to_s.camelize}Controller".to_sym
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
def self.controller_has_action?(resource_name, action)
|
50
50
|
controller_class_for(resource_name).const_defined?( action.to_sym )
|
51
51
|
end
|
52
52
|
|
53
53
|
end
|
54
54
|
|
55
|
-
class Object
|
56
|
-
# Courtesy of Rails' ActiveSupport, thank you DHH et al.
|
55
|
+
class Object
|
57
56
|
def blank?
|
57
|
+
# Courtesy of Rails' ActiveSupport, thank you DHH et al.
|
58
58
|
respond_to?(:empty?) ? empty? : !self
|
59
59
|
end
|
60
60
|
end
|
data/lib/restrack/version.rb
CHANGED
data/restrack.gemspec
CHANGED
File without changes
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: restrack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.
|
5
|
+
version: 1.0.0
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Chris St. John
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-
|
13
|
+
date: 2011-05-18 00:00:00 -04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|