sextant 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,3 +1,7 @@
1
+ ## 1.0.0
2
+ * Render routes as HTML
3
+ * JS now uses asset pipeline
4
+
1
5
  ## 0.1.3
2
6
 
3
7
  * Helper for mounting sextant in cases of catch all routes (via @menkel)
data/README.md CHANGED
@@ -1,6 +1,8 @@
1
1
  # Sextant
2
2
 
3
- Helps you find your routes on a long Journey on Rails.
3
+ [![Build Status](https://travis-ci.org/schneems/sextant.png?branch=master)](https://travis-ci.org/schneems/sextant)
4
+
5
+ Helps you find your routes on a long Journey on Rails, in Rails apps 3.2+.
4
6
 
5
7
  ## What
6
8
 
@@ -30,16 +32,17 @@ end
30
32
 
31
33
  Then run `bundle install` and you're ready to start
32
34
 
33
- ### Optional for user of catch-all route in routes.rb:
35
+ ### Optional for users of catch-all routes
34
36
 
35
- Add sextant to your routes (config/routes.rb) before catch-all routes
37
+ If (and only if) you have catch all routes like `match '*not_found' => 'errors#handle404'
38
+ ` in your app already, you can add sextant to your routes (config/routes.rb) before the catch-all routes like this.
36
39
 
37
40
  ```ruby
38
- mount_sextant
41
+ mount_sextant if Rails.env.development?
39
42
  match '*not_found' => 'errors#handle404'
40
- match "*path" => 'errors#handle404'
41
43
  ```
42
44
 
45
+
43
46
  ## Use
44
47
 
45
48
  Visit `/rails/routes` in your app and you'll see your routes. It's that simple.
@@ -49,4 +52,4 @@ Visit `/rails/routes` in your app and you'll see your routes. It's that simple.
49
52
 
50
53
  If you have a question file an issue or find me on the Twitters [@schneems](http://twitter.com/schneems).
51
54
 
52
- This project rocks and uses MIT-LICENSE.
55
+ This project rocks and uses MIT-LICENSE.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.3
1
+ 0.2.0
@@ -0,0 +1 @@
1
+ //= require_tree .
@@ -0,0 +1,28 @@
1
+ function each(elems, func) {
2
+ if (!elems instanceof Array) { elems = [elems]; }
3
+ for (var i = elems.length; i--; ) {
4
+ func(elems[i]);
5
+ }
6
+ }
7
+
8
+ function setValOn(elems, val) {
9
+ each(elems, function(elem) {
10
+ elem.innerHTML = val;
11
+ });
12
+ }
13
+
14
+ function onClick(elems, func) {
15
+ each(elems, function(elem) {
16
+ elem.onclick = func;
17
+ });
18
+ }
19
+
20
+ // Enables functionality to toggle between `_path` and `_url` helper suffixes
21
+ function setupRouteToggleHelperLinks() {
22
+ var toggleLinks = document.querySelectorAll('#route_table [data-route-helper]');
23
+ onClick(toggleLinks, function(){
24
+ var helperTxt = this.getAttribute("data-route-helper");
25
+ var helperElems = document.querySelectorAll('[data-route-name] span.helper');
26
+ setValOn(helperElems, helperTxt);
27
+ });
28
+ }
@@ -0,0 +1,4 @@
1
+ module Sextant
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,23 @@
1
+ module Sextant
2
+ class RoutesController < ApplicationController
3
+ # layout 'sextant/application'
4
+
5
+ before_filter :require_local!
6
+
7
+ def index
8
+ @routes = Sextant.format_routes
9
+ end
10
+
11
+ private
12
+ def require_local!
13
+ unless local_request?
14
+ render :text => '<p>For security purposes, this information is only available to local requests.</p>', :status => :forbidden
15
+ end
16
+ end
17
+
18
+ def local_request?
19
+ Rails.application.config.consider_all_requests_local || request.local?
20
+ end
21
+
22
+ end
23
+ end
@@ -23,7 +23,9 @@
23
23
  a:visited { color: #666; }
24
24
  a:hover { color: #fff; background-color:#000; }
25
25
  </style>
26
- </head>
26
+ <%= javascript_include_tag "sextant/application" %>
27
+ <%= csrf_meta_tags %>
28
+ </head>
27
29
  <body>
28
30
 
29
31
  <%= yield %>
@@ -0,0 +1,16 @@
1
+ <tr class='route_row' data-helper='path'>
2
+ <td data-route-name='<%= route[:name] %>'>
3
+ <% if route[:name].present? %>
4
+ <%= route[:name] %><span class='helper'>_path</span>
5
+ <% end %>
6
+ </td>
7
+ <td data-route-verb='<%= route[:verb] %>'>
8
+ <%= route[:verb] %>
9
+ </td>
10
+ <td data-route-path='<%= route[:path] %>'>
11
+ <%= route[:path] %>
12
+ </td>
13
+ <td data-route-reqs='<%= route[:reqs] %>'>
14
+ <%= route[:reqs] %>
15
+ </td>
16
+ </tr>
@@ -0,0 +1,27 @@
1
+ <style type='text/css'>
2
+ #route_table td {padding: 0 30px;}
3
+ #route_table {margin: 0 auto 0;}
4
+ </style>
5
+
6
+ <table id='route_table' class='route_table'>
7
+ <thead>
8
+ <tr>
9
+ <th>Helper<br />
10
+ <%= link_to "Path", "#", 'data-route-helper' => '_path',
11
+ title: "Returns a relative path (without the http or domain)" %> /
12
+ <%= link_to "Url", "#", 'data-route-helper' => '_url',
13
+ title: "Returns an absolute url (with the http and domain)" %>
14
+ </th>
15
+ <th>HTTP Verb</th>
16
+ <th>Path</th>
17
+ <th>Controller#Action</th>
18
+ </tr>
19
+ </thead>
20
+ <tbody>
21
+ <%= yield %>
22
+ </tbody>
23
+ </table>
24
+
25
+ <script type='text/javascript'>
26
+ setupRouteToggleHelperLinks();
27
+ </script>
@@ -0,0 +1,11 @@
1
+ <h2>
2
+ Routes
3
+ </h2>
4
+
5
+ <p>
6
+ Routes match in priority from top to bottom
7
+ </p>
8
+
9
+ <%= render layout: "route_wrapper" do %>
10
+ <%= render partial: "route", collection: @routes %>
11
+ <% end %>
@@ -1,7 +1,3 @@
1
1
  Rails.application.routes.draw do
2
2
  mount_sextant
3
3
  end
4
-
5
- # RouteInspector::Engine.routes.draw do
6
- #
7
- # end
@@ -3,9 +3,8 @@ module ActionDispatch::Routing
3
3
  # Includes mount_sextant method for routes. This method is responsible to
4
4
  # generate all needed routes for sextant
5
5
  def mount_sextant
6
- namespace :rails do
7
- resources :routes, :only => [:index, :show]
8
- end
6
+ match "rails/routes" => "sextant/routes#index"
7
+ mount Sextant::Engine => "/sextant", :as => "sextant_engine"
9
8
  end
10
9
  end
11
10
  end
@@ -4,8 +4,9 @@ require 'rails/routes'
4
4
 
5
5
  module Sextant
6
6
  def self.format_routes(routes = all_routes)
7
+ # ActionDispatch::Routing::RoutesInspector.new.collect_routes(_routes.routes)
7
8
  inspector = Rails::Application::RouteInspector.new
8
- inspector.format(routes, ENV['CONTROLLER']).join "\n"
9
+ inspector.collect_routes(routes)
9
10
  end
10
11
 
11
12
  def self.all_routes
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "sextant"
8
- s.version = "0.1.3"
8
+ s.version = "0.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["schneems"]
12
- s.date = "2012-06-01"
12
+ s.date = "2013-01-08"
13
13
  s.description = "Sextant is a Rails engine that quickly shows the routes available"
14
14
  s.email = "richard.schneeman@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -24,9 +24,14 @@ Gem::Specification.new do |s|
24
24
  "README.md",
25
25
  "Rakefile",
26
26
  "VERSION",
27
- "app/controllers/rails/routes_controller.rb",
28
- "app/views/layouts/rails/routes.html.erb",
29
- "app/views/rails/routes/index.html.erb",
27
+ "app/assets/javascripts/sextant/application.js",
28
+ "app/assets/javascripts/sextant/sextant.js",
29
+ "app/controllers/sextant/application_controller.rb",
30
+ "app/controllers/sextant/routes_controller.rb",
31
+ "app/views/layouts/sextant/application.html.erb",
32
+ "app/views/sextant/routes/_route.html.erb",
33
+ "app/views/sextant/routes/_route_wrapper.html.erb",
34
+ "app/views/sextant/routes/index.html.erb",
30
35
  "config/routes.rb",
31
36
  "lib/rails/routes.rb",
32
37
  "lib/sextant.rb",
@@ -59,13 +64,6 @@ Gem::Specification.new do |s|
59
64
  "test/dummy/public/500.html",
60
65
  "test/dummy/public/favicon.ico",
61
66
  "test/dummy/public/index.html",
62
- "test/dummy/public/javascripts/application.js",
63
- "test/dummy/public/javascripts/controls.js",
64
- "test/dummy/public/javascripts/dragdrop.js",
65
- "test/dummy/public/javascripts/effects.js",
66
- "test/dummy/public/javascripts/prototype.js",
67
- "test/dummy/public/javascripts/rails.js",
68
- "test/dummy/public/stylesheets/.gitkeep",
69
67
  "test/dummy/script/rails",
70
68
  "test/integration/sextant_test.rb",
71
69
  "test/route_inspector_test.rb",
@@ -1,10 +1,6 @@
1
1
  require File.expand_path('../boot', __FILE__)
2
2
 
3
- require "active_model/railtie"
4
- require "active_record/railtie"
5
- require "action_controller/railtie"
6
- require "action_view/railtie"
7
- require "action_mailer/railtie"
3
+ require 'rails/all'
8
4
 
9
5
  Bundler.require
10
6
 
@@ -42,5 +38,7 @@ module Dummy
42
38
 
43
39
  # Configure sensitive parameters which will be filtered from the log file.
44
40
  config.filter_parameters += [:password]
41
+
42
+ config.assets.enabled = true
45
43
  end
46
44
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sextant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-06-01 00:00:00.000000000Z
12
+ date: 2013-01-08 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
16
- requirement: &70254073682540 !ruby/object:Gem::Requirement
16
+ requirement: &70123812715880 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70254073682540
24
+ version_requirements: *70123812715880
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rails
27
- requirement: &70254073681720 !ruby/object:Gem::Requirement
27
+ requirement: &70123812715300 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '3.2'
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70254073681720
35
+ version_requirements: *70123812715300
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rake
38
- requirement: &70254073680980 !ruby/object:Gem::Requirement
38
+ requirement: &70123812714780 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70254073680980
46
+ version_requirements: *70123812714780
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: jeweler
49
- requirement: &70254073680360 !ruby/object:Gem::Requirement
49
+ requirement: &70123812714160 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ~>
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: 1.6.4
55
55
  type: :development
56
56
  prerelease: false
57
- version_requirements: *70254073680360
57
+ version_requirements: *70123812714160
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: capybara
60
- requirement: &70254073679660 !ruby/object:Gem::Requirement
60
+ requirement: &70123812688360 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: 0.4.0
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70254073679660
68
+ version_requirements: *70123812688360
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: sqlite3
71
- requirement: &70254073679040 !ruby/object:Gem::Requirement
71
+ requirement: &70123812687760 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,10 +76,10 @@ dependencies:
76
76
  version: '0'
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70254073679040
79
+ version_requirements: *70123812687760
80
80
  - !ruby/object:Gem::Dependency
81
81
  name: launchy
82
- requirement: &70254073651460 !ruby/object:Gem::Requirement
82
+ requirement: &70123812687200 !ruby/object:Gem::Requirement
83
83
  none: false
84
84
  requirements:
85
85
  - - ~>
@@ -87,10 +87,10 @@ dependencies:
87
87
  version: 2.1.0
88
88
  type: :development
89
89
  prerelease: false
90
- version_requirements: *70254073651460
90
+ version_requirements: *70123812687200
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: rcov
93
- requirement: &70254073650940 !ruby/object:Gem::Requirement
93
+ requirement: &70123812686660 !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
96
96
  - - ! '>='
@@ -98,10 +98,10 @@ dependencies:
98
98
  version: '0'
99
99
  type: :development
100
100
  prerelease: false
101
- version_requirements: *70254073650940
101
+ version_requirements: *70123812686660
102
102
  - !ruby/object:Gem::Dependency
103
103
  name: simplecov
104
- requirement: &70254073650460 !ruby/object:Gem::Requirement
104
+ requirement: &70123812685760 !ruby/object:Gem::Requirement
105
105
  none: false
106
106
  requirements:
107
107
  - - ! '>='
@@ -109,7 +109,7 @@ dependencies:
109
109
  version: '0'
110
110
  type: :development
111
111
  prerelease: false
112
- version_requirements: *70254073650460
112
+ version_requirements: *70123812685760
113
113
  description: Sextant is a Rails engine that quickly shows the routes available
114
114
  email: richard.schneeman@gmail.com
115
115
  executables: []
@@ -125,9 +125,14 @@ files:
125
125
  - README.md
126
126
  - Rakefile
127
127
  - VERSION
128
- - app/controllers/rails/routes_controller.rb
129
- - app/views/layouts/rails/routes.html.erb
130
- - app/views/rails/routes/index.html.erb
128
+ - app/assets/javascripts/sextant/application.js
129
+ - app/assets/javascripts/sextant/sextant.js
130
+ - app/controllers/sextant/application_controller.rb
131
+ - app/controllers/sextant/routes_controller.rb
132
+ - app/views/layouts/sextant/application.html.erb
133
+ - app/views/sextant/routes/_route.html.erb
134
+ - app/views/sextant/routes/_route_wrapper.html.erb
135
+ - app/views/sextant/routes/index.html.erb
131
136
  - config/routes.rb
132
137
  - lib/rails/routes.rb
133
138
  - lib/sextant.rb
@@ -160,13 +165,6 @@ files:
160
165
  - test/dummy/public/500.html
161
166
  - test/dummy/public/favicon.ico
162
167
  - test/dummy/public/index.html
163
- - test/dummy/public/javascripts/application.js
164
- - test/dummy/public/javascripts/controls.js
165
- - test/dummy/public/javascripts/dragdrop.js
166
- - test/dummy/public/javascripts/effects.js
167
- - test/dummy/public/javascripts/prototype.js
168
- - test/dummy/public/javascripts/rails.js
169
- - test/dummy/public/stylesheets/.gitkeep
170
168
  - test/dummy/script/rails
171
169
  - test/integration/sextant_test.rb
172
170
  - test/route_inspector_test.rb
@@ -187,7 +185,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
187
185
  version: '0'
188
186
  segments:
189
187
  - 0
190
- hash: -4159701652236955647
188
+ hash: -3140928192778270063
191
189
  required_rubygems_version: !ruby/object:Gem::Requirement
192
190
  none: false
193
191
  requirements: