described_routes 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
data/History.txt
CHANGED
@@ -55,9 +55,12 @@ module DescribedRoutes
|
|
55
55
|
hash = {}
|
56
56
|
hash["name"] = name if name && !name.empty?
|
57
57
|
hash["rel"] = rel if rel && !rel.empty?
|
58
|
-
hash["uri_template"] = path_template if uri_template && !
|
58
|
+
hash["uri_template"] = path_template if uri_template && !uri_template.empty?
|
59
59
|
hash["path_template"] = path_template if path_template && !path_template.empty?
|
60
60
|
|
61
|
+
hash["params"] = params if params && !params.empty?
|
62
|
+
hash["optional_params"] = optional_params if optional_params && !optional_params.empty?
|
63
|
+
|
61
64
|
hash["options"] = options if options && !options.empty?
|
62
65
|
|
63
66
|
hashes = DescribedRoutes::ResourceTemplate.to_parsed(resource_templates)
|
data/lib/described_routes.rb
CHANGED
@@ -1 +1 @@
|
|
1
|
-
[{"name":"root","path_template":"\/"},{"name":"admin_products","resource_templates":[{"name":"admin_product","resource_templates":[{"name":"edit_admin_product","options":["GET"],"path_template":"\/admin\/products\/{product_id}\/edit{-prefix|.|format}","rel":"edit"}],"options":["GET","PUT","DELETE"],"path_template":"\/admin\/products\/{product_id}{-prefix|.|format}"},{"name":"new_admin_product","options":["GET"],"path_template":"\/admin\/products\/new{-prefix|.|format}","rel":"new_admin_product"}],"options":["GET","POST"],"path_template":"\/admin\/products{-prefix|.|format}"},{"name":"described_routes","resource_templates":[{"name":"new_described_route","options":["GET"],"path_template":"\/described_routes\/new{-prefix|.|format}","rel":"new_described_route"},{"name":"described_route","resource_templates":[{"name":"edit_described_route","options":["GET"],"path_template":"\/described_routes\/{route_name}\/edit{-prefix|.|format}","rel":"edit"}],"options":["GET","PUT","DELETE"],"path_template":"\/described_routes\/{route_name}{-prefix|.|format}","rel":"described_route"}],"options":["GET","POST"],"path_template":"\/described_routes{-prefix|.|format}"},{"name":"pages","resource_templates":[{"name":"page","resource_templates":[{"name":"edit_page","options":["GET"],"path_template":"\/pages\/{page_id}\/edit{-prefix|.|format}","rel":"edit"},{"name":"summary_page","options":["GET"],"path_template":"\/pages\/{page_id}\/summary{-prefix|.|format}","rel":"summary"},{"name":"toggle_visibility_page","options":["POST"],"path_template":"\/pages\/{page_id}\/toggle_visibility{-prefix|.|format}","rel":"toggle_visibility"}],"options":["GET","PUT","DELETE"],"path_template":"\/pages\/{page_id}{-prefix|.|format}"},{"name":"new_page","options":["GET"],"path_template":"\/pages\/new{-prefix|.|format}","rel":"new_page"}],"options":["GET","POST"],"path_template":"\/pages{-prefix|.|format}"},{"name":"users","resource_templates":[{"name":"user","resource_templates":[{"name":"user_articles","resource_templates":[{"name":"user_article","resource_templates":[{"name":"edit_user_article","options":["GET"],"path_template":"\/users\/{user_id}\/articles\/{article_id}\/edit{-prefix|.|format}","rel":"edit"}],"options":["GET","PUT","DELETE"],"path_template":"\/users\/{user_id}\/articles\/{article_id}{-prefix|.|format}"},{"name":"new_user_article","options":["GET"],"path_template":"\/users\/{user_id}\/articles\/new{-prefix|.|format}","rel":"new_user_article"},{"name":"recent_user_articles","options":["GET"],"path_template":"\/users\/{user_id}\/articles\/recent{-prefix|.|format}","rel":"recent"}],"options":["GET","POST"],"path_template":"\/users\/{user_id}\/articles{-prefix|.|format}","rel":"articles"},{"name":"edit_user","options":["GET"],"path_template":"\/users\/{user_id}\/edit{-prefix|.|format}","rel":"edit"},{"name":"user_profile","resource_templates":[{"name":"edit_user_profile","options":["GET"],"path_template":"\/users\/{user_id}\/profile\/edit{-prefix|.|format}","rel":"edit"},{"name":"new_user_profile","options":["GET"],"path_template":"\/users\/{user_id}\/profile\/new{-prefix|.|format}","rel":"new"}],"options":["GET","PUT","DELETE","POST"],"path_template":"\/users\/{user_id}\/profile{-prefix|.|format}","rel":"profile"}],"options":["GET","PUT","DELETE"],"path_template":"\/users\/{user_id}{-prefix|.|format}"},{"name":"new_user","options":["GET"],"path_template":"\/users\/new{-prefix|.|format}","rel":"new_user"}],"options":["GET","POST"],"path_template":"\/users{-prefix|.|format}"}]
|
1
|
+
[{"name":"root","path_template":"\/"},{"name":"admin_products","resource_templates":[{"name":"admin_product","resource_templates":[{"name":"edit_admin_product","options":["GET"],"path_template":"\/admin\/products\/{product_id}\/edit{-prefix|.|format}","rel":"edit","optional_params":["format"],"params":["product_id"]}],"options":["GET","PUT","DELETE"],"path_template":"\/admin\/products\/{product_id}{-prefix|.|format}","optional_params":["format"],"params":["product_id"]},{"name":"new_admin_product","options":["GET"],"path_template":"\/admin\/products\/new{-prefix|.|format}","rel":"new_admin_product","optional_params":["format"]}],"options":["GET","POST"],"path_template":"\/admin\/products{-prefix|.|format}","optional_params":["format"]},{"name":"described_routes","resource_templates":[{"name":"new_described_route","options":["GET"],"path_template":"\/described_routes\/new{-prefix|.|format}","rel":"new_described_route","optional_params":["format"]},{"name":"described_route","resource_templates":[{"name":"edit_described_route","options":["GET"],"path_template":"\/described_routes\/{route_name}\/edit{-prefix|.|format}","rel":"edit","optional_params":["format"]}],"options":["GET","PUT","DELETE"],"path_template":"\/described_routes\/{route_name}{-prefix|.|format}","rel":"described_route","optional_params":["format"]}],"options":["GET","POST"],"path_template":"\/described_routes{-prefix|.|format}","optional_params":["format"]},{"name":"pages","resource_templates":[{"name":"page","resource_templates":[{"name":"edit_page","options":["GET"],"path_template":"\/pages\/{page_id}\/edit{-prefix|.|format}","rel":"edit","optional_params":["format"],"params":["page_id"]},{"name":"summary_page","options":["GET"],"path_template":"\/pages\/{page_id}\/summary{-prefix|.|format}","rel":"summary","optional_params":["format"],"params":["page_id"]},{"name":"toggle_visibility_page","options":["POST"],"path_template":"\/pages\/{page_id}\/toggle_visibility{-prefix|.|format}","rel":"toggle_visibility","optional_params":["format"],"params":["page_id"]}],"options":["GET","PUT","DELETE"],"path_template":"\/pages\/{page_id}{-prefix|.|format}","optional_params":["format"],"params":["page_id"]},{"name":"new_page","options":["GET"],"path_template":"\/pages\/new{-prefix|.|format}","rel":"new_page","optional_params":["format"]}],"options":["GET","POST"],"path_template":"\/pages{-prefix|.|format}","optional_params":["format"]},{"name":"users","resource_templates":[{"name":"user","resource_templates":[{"name":"user_articles","resource_templates":[{"name":"user_article","resource_templates":[{"name":"edit_user_article","options":["GET"],"path_template":"\/users\/{user_id}\/articles\/{article_id}\/edit{-prefix|.|format}","rel":"edit","optional_params":["format"],"params":["user_id","article_id"]}],"options":["GET","PUT","DELETE"],"path_template":"\/users\/{user_id}\/articles\/{article_id}{-prefix|.|format}","optional_params":["format"],"params":["user_id","article_id"]},{"name":"new_user_article","options":["GET"],"path_template":"\/users\/{user_id}\/articles\/new{-prefix|.|format}","rel":"new_user_article","optional_params":["format"],"params":["user_id"]},{"name":"recent_user_articles","options":["GET"],"path_template":"\/users\/{user_id}\/articles\/recent{-prefix|.|format}","rel":"recent","optional_params":["format"],"params":["user_id"]}],"options":["GET","POST"],"path_template":"\/users\/{user_id}\/articles{-prefix|.|format}","rel":"articles","optional_params":["format"],"params":["user_id"]},{"name":"edit_user","options":["GET"],"path_template":"\/users\/{user_id}\/edit{-prefix|.|format}","rel":"edit","optional_params":["format"],"params":["user_id"]},{"name":"user_profile","resource_templates":[{"name":"edit_user_profile","options":["GET"],"path_template":"\/users\/{user_id}\/profile\/edit{-prefix|.|format}","rel":"edit","optional_params":["format"],"params":["user_id"]},{"name":"new_user_profile","options":["GET"],"path_template":"\/users\/{user_id}\/profile\/new{-prefix|.|format}","rel":"new","optional_params":["format"],"params":["user_id"]}],"options":["GET","PUT","DELETE","POST"],"path_template":"\/users\/{user_id}\/profile{-prefix|.|format}","rel":"profile","optional_params":["format"],"params":["user_id"]}],"options":["GET","PUT","DELETE"],"path_template":"\/users\/{user_id}{-prefix|.|format}","optional_params":["format"],"params":["user_id"]},{"name":"new_user","options":["GET"],"path_template":"\/users\/new{-prefix|.|format}","rel":"new_user","optional_params":["format"]}],"options":["GET","POST"],"path_template":"\/users{-prefix|.|format}","optional_params":["format"]}]
|
@@ -20,8 +20,8 @@ class TestResourceTemplate < Test::Unit::TestCase
|
|
20
20
|
assert_kind_of(DescribedRoutes::ResourceTemplate, edit_user_article)
|
21
21
|
|
22
22
|
assert_equal("user_article", user_article.name)
|
23
|
-
assert_equal([], user_article.params)
|
24
|
-
assert_equal([], user_article.optional_params)
|
23
|
+
assert_equal(["user_id", "article_id"], user_article.params)
|
24
|
+
assert_equal(["format"], user_article.optional_params)
|
25
25
|
|
26
26
|
assert_equal("articles", user_articles.rel)
|
27
27
|
assert_nil(user_article.rel)
|