described_routes 0.3.5 → 0.3.6

Sign up to get free protection for your applications and to get access to all the features.
data/History.txt CHANGED
@@ -1,6 +1,6 @@
1
+ == 0.3.6 2009-05-12
1
2
 
2
- * Framework-neutral metadata describing Rails routes in JSON, YAML, XML and plain text formats.
3
- * Please comment on the roadmap at http://positiveincline.com/?p=213
3
+ * add ResourceTemplate#positional_params
4
4
 
5
5
  == 0.3.5 2009-05-06
6
6
 
data/README.rdoc CHANGED
@@ -1,8 +1,8 @@
1
1
  = described_routes README
2
2
 
3
- Framework-neutral descriptions of Rails routes in JSON, YAML, XML and plain text formats.
3
+ Framework-neutral descriptions of Rails routes in JSON, YAML, XML and plain text formats. Also the home (for now at least) of the ResourceTemplate class.
4
4
 
5
- Please comment on the roadmap at http://positiveincline.com/?p=213
5
+ Note to reader: you are invited to comment on the roadmap at http://positiveincline.com/?p=213
6
6
 
7
7
  == DESCRIPTION:
8
8
 
@@ -56,8 +56,7 @@ The text output looks like this:
56
56
  edit edit_user_profile GET /users/{user_id}/profile/edit{-prefix|.|format}
57
57
  new new_user_profile GET /users/{user_id}/profile/new{-prefix|.|format}
58
58
 
59
- You can specify the base URL of your application by appending the following
60
- parameter "BASE=http://..." to the rake command line. The output will then
59
+ You can specify the base URL of your application by appending "BASE=http://..." to the rake command line. The output will then
61
60
  include full URI templates.
62
61
 
63
62
  The JSON, XML and YAML formats (of which the YAML is the most readable) are designed for program consumption.
@@ -2,5 +2,5 @@ require 'described_routes/resource_template'
2
2
 
3
3
  module DescribedRoutes
4
4
  # rubygem version
5
- VERSION = "0.3.5"
5
+ VERSION = "0.3.6"
6
6
  end
@@ -171,6 +171,7 @@ module DescribedRoutes
171
171
  h
172
172
  end
173
173
 
174
+ # for #to_text
174
175
  def self.to_table(resource_templates, parent_template = nil, t = [], indent = '')
175
176
  resource_templates.inject(t) do |table, resource_template|
176
177
  if parent_template
@@ -192,6 +193,7 @@ module DescribedRoutes
192
193
  t
193
194
  end
194
195
 
196
+ # text report
195
197
  def self.to_text(resource_templates)
196
198
  table = self.to_table(resource_templates)
197
199
 
@@ -204,6 +206,16 @@ module DescribedRoutes
204
206
 
205
207
  table.map{|row| row.join(' ')}.join("\n") + "\n"
206
208
  end
209
+
210
+ # returns params and any optional_params in order, removing the parent's params
211
+ def positional_params(parent)
212
+ all_params = params + optional_params
213
+ if parent
214
+ all_params - parent.params
215
+ else
216
+ all_params
217
+ end
218
+ end
207
219
  end
208
220
  end
209
221
 
@@ -4,7 +4,6 @@ require 'described_routes/resource_template'
4
4
  class TestResourceTemplate < Test::Unit::TestCase
5
5
  attr_reader :json, :resource_templates, :resource_templates_by_name, :user_articles, :user_article, :edit_user_article
6
6
 
7
-
8
7
  def setup
9
8
  @json ||= File.read(File.dirname(__FILE__) + "/fixtures/described_routes_test.json")
10
9
  @resource_templates = DescribedRoutes::ResourceTemplate.parse_json(json)
@@ -45,4 +44,9 @@ class TestResourceTemplate < Test::Unit::TestCase
45
44
  JSON.parse(json),
46
45
  YAML.load(DescribedRoutes::ResourceTemplate.to_yaml(resource_templates)))
47
46
  end
47
+
48
+ def test_positional_params
49
+ assert_equal(["user_id", "article_id", "format"], user_article.positional_params(nil))
50
+ assert_equal(["article_id", "format"], user_article.positional_params(user_articles))
51
+ end
48
52
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: described_routes
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Burrows
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2009-05-06 00:00:00 +01:00
12
+ date: 2009-05-12 00:00:00 +01:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency