described_routes 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
data/Manifest.txt CHANGED
@@ -5,6 +5,7 @@ PostInstall.txt
5
5
  README.rdoc
6
6
  Rakefile
7
7
  lib/described_routes.rb
8
+ lib/described_routes/rails_controller.rb
8
9
  lib/described_routes/rails_routes.rb
9
10
  lib/described_routes/resource_template.rb
10
11
  lib/tasks/described_routes.rb
@@ -2,7 +2,7 @@ require 'described_routes/resource_template'
2
2
 
3
3
  module DescribedRoutes
4
4
  # rubygem version
5
- VERSION = "0.1.1"
5
+ VERSION = "0.1.2"
6
6
 
7
7
  # Convert an array of ResourceTemplate objects to array of hashes equivalent to their JSON or YAML representations
8
8
  def self.to_parsed(resource_templates)
@@ -0,0 +1,26 @@
1
+ require 'described_routes/rails_routes'
2
+ require 'active_support'
3
+
4
+ module DescribedRoutes
5
+ class RailsController < ActionController::Base
6
+ def index
7
+ base_url = root_url rescue nil
8
+ resources = RailsRoutes.get_resources(base_url)
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => resources.to_json }
13
+ format.yaml do
14
+ yaml = resources.to_yaml
15
+ yaml = yaml.grep(/(name|rel|path_template|uri_template|resources):|^---/).to_s if ['true', '1'].member?(params["short"])
16
+ render :text => yaml
17
+ end
18
+ format.xml do
19
+ render :xml => DescribedRoutes::to_xml(
20
+ Builder::XmlMarkup.new(:indent => 2),
21
+ resources).target!
22
+ end
23
+ end
24
+ end
25
+ end
26
+ 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.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mike Burrows
@@ -52,6 +52,7 @@ files:
52
52
  - README.rdoc
53
53
  - Rakefile
54
54
  - lib/described_routes.rb
55
+ - lib/described_routes/rails_controller.rb
55
56
  - lib/described_routes/rails_routes.rb
56
57
  - lib/described_routes/resource_template.rb
57
58
  - lib/tasks/described_routes.rb