pretty_routes 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: f84cfbb4b6608a21ae01c2d4c57d87f18d119006
4
+ data.tar.gz: 2223f52b9d7df19ecab2e7017ec630feae9f0c47
5
+ SHA512:
6
+ metadata.gz: 04a137881e22b96dcefbef7b49424c8bb27cefaee5ca15e363d7983387280adcaf3aa3636070dcd743f08fd00f9b93851dc460124c48fb2bc526cdc9eb0fda84
7
+ data.tar.gz: bd8e17d021988bc6744423defb5d8e8d200bd136734ad4ed1790d458708f638991c7b7973b9ff645d9c316b5d5294dacaf6758350bc5b3723e2c3b95373a3542
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright 2012 Schneems
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,25 @@
1
+ # PrettyRoutes [![Build Status](https://travis-ci.org/Angelmmiguel/pretty_routes.svg?branch=master)](https://travis-ci.org/Angelmmiguel/pretty_routes)
2
+
3
+ Working with Rails routes won't be a nightmare. This is PrettyRoutes.
4
+
5
+ ## Install
6
+
7
+ Add this to the development group in your Gemfile:
8
+
9
+ ```ruby
10
+ group :development do
11
+ gem 'pretty_routes'
12
+ end
13
+ ```
14
+
15
+ Then run `bundle install` and you're ready to start
16
+
17
+ ## Use
18
+
19
+ Visit `/rails/routes` in your app and you'll see your routes. It's that simple.
20
+
21
+ ## About
22
+
23
+ PrettyRoutes is based on [Sextant v0.2.4](https://github.com/schneems/sextant).
24
+
25
+ PrettyRoutes gem is released under the MIT license. By [@irbrocks](https://twitter.com/irbrocks) ;)
data/Rakefile ADDED
@@ -0,0 +1,33 @@
1
+ # encoding: UTF-8
2
+ require 'rubygems'
3
+ require 'bundler'
4
+
5
+ begin
6
+ Bundler.setup(:default, :development, :test)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+
13
+ require 'rake'
14
+ require 'rdoc/task'
15
+
16
+ require 'rake/testtask'
17
+
18
+ Rake::TestTask.new(:test) do |t|
19
+ t.libs << 'lib'
20
+ t.libs << 'test'
21
+ t.pattern = 'test/**/*_test.rb'
22
+ t.verbose = false
23
+ end
24
+
25
+ task default: :test
26
+
27
+ Rake::RDocTask.new(:rdoc) do |rdoc|
28
+ rdoc.rdoc_dir = 'rdoc'
29
+ rdoc.title = 'PrettyRoutes'
30
+ rdoc.options << '--line-numbers' << '--inline-source'
31
+ rdoc.rdoc_files.include('README.rdoc')
32
+ rdoc.rdoc_files.include('lib/**/*.rb')
33
+ end
@@ -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,54 @@
1
+ /*
2
+ * $fg_color: #333;
3
+ * $bg_color: #FFF;
4
+ * $fg_color_hover: $bg_color;
5
+ * $bg_color_hover: $fg_color;
6
+ * $table_color: #999;
7
+ */
8
+
9
+ body {
10
+ background-color: #FFF;
11
+ color: #333;
12
+ }
13
+
14
+ body, p, ol, ul, td {
15
+ font-family: helvetica, verdana, arial, sans-serif;
16
+ font-size: 13px;
17
+ line-height: 18px;
18
+ }
19
+
20
+ a,
21
+ a:visited {
22
+ color: #333;
23
+ }
24
+ a:hover {
25
+ background-color: #333;
26
+ color: #FFF;
27
+ }
28
+
29
+ table.route_table {
30
+ border: 1px solid #999;
31
+ border-spacing: 0;
32
+ border-collapse: collapse;
33
+ }
34
+ table.route_table th {
35
+ border-bottom: 1px solid #999;
36
+ border: 1px solid #999;
37
+ }
38
+ table.route_table tbody tr:nth-child(even) {
39
+ background: #EEE
40
+ }
41
+ table.route_table tbody tr:nth-child(odd) {
42
+ background: #FFF
43
+ }
44
+ table.route_table tbody tr:hover {
45
+ background-color: #333;
46
+ color: #FFF;
47
+ }
48
+ table.route_table td {
49
+ padding: 3px 10px;
50
+ }
51
+ table.route_table td+td {
52
+ border-left: 1px solid #DDD;
53
+ }
54
+
@@ -0,0 +1,4 @@
1
+ module PrettyRoutes
2
+ class ApplicationController < ActionController::Base
3
+ end
4
+ end
@@ -0,0 +1,24 @@
1
+ module PrettyRoutes
2
+ class RoutesController < PrettyRoutes::ApplicationController
3
+ layout 'pretty_routes/application'
4
+
5
+ before_filter :require_local!
6
+
7
+ def index
8
+ @routes = PrettyRoutes.format_routes
9
+ end
10
+
11
+ private
12
+
13
+ def require_local!
14
+ return if local_request?
15
+ render text: '<p>For security purposes, this information is only' \
16
+ 'available to local requests.</p>',
17
+ status: :forbidden
18
+ end
19
+
20
+ def local_request?
21
+ Rails.application.config.consider_all_requests_local || request.local?
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,15 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="utf-8" />
5
+ <title>Routes</title>
6
+ <%= stylesheet_link_tag "pretty_routes/application" %>
7
+ <%= javascript_include_tag "pretty_routes/application" %>
8
+ <%= csrf_meta_tags %>
9
+ </head>
10
+ <body>
11
+
12
+ <%= yield %>
13
+
14
+ </body>
15
+ </html>
@@ -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,25 @@
1
+ <table id='route_table' class='route_table'>
2
+ <thead>
3
+ <tr>
4
+ <th>
5
+ Helper (
6
+ <%= link_to "Path", "#", 'data-route-helper' => '_path',
7
+ title: "Returns a relative path (without the http or domain)" %>
8
+ /
9
+ <%= link_to "Url", "#", 'data-route-helper' => '_url',
10
+ title: "Returns an absolute url (with the http and domain)" %>
11
+ )
12
+ </th>
13
+ <th>HTTP Verb</th>
14
+ <th>Path</th>
15
+ <th>Controller#Action</th>
16
+ </tr>
17
+ </thead>
18
+ <tbody>
19
+ <%= yield %>
20
+ </tbody>
21
+ </table>
22
+
23
+ <script type='text/javascript'>
24
+ setupRouteToggleHelperLinks();
25
+ </script>
@@ -0,0 +1,11 @@
1
+ <h2>
2
+ Routes by PrettyRoutes!
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 %>
@@ -0,0 +1,8 @@
1
+ module PrettyRoutes
2
+ #
3
+ # Create an isloated space for PrettyRoutes
4
+ #
5
+ class Engine < Rails::Engine
6
+ isolate_namespace PrettyRoutes
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ #
2
+ # Version of the Gem.
3
+ #
4
+ module PrettyRoutes
5
+ VERSION = '0.0.1'
6
+ end
@@ -0,0 +1,24 @@
1
+ require 'pretty_routes/engine'
2
+
3
+ #
4
+ # Base module of pretty routes
5
+ #
6
+ module PrettyRoutes
7
+ begin
8
+ require 'rails/application/route_inspector'
9
+ ROUTE_INSPECTOR = Rails::Application::RouteInspector.new
10
+ rescue LoadError
11
+ require 'action_dispatch/routing/inspector'
12
+ ROUTE_INSPECTOR = ActionDispatch::Routing::RoutesInspector.new([])
13
+ end
14
+
15
+ def self.format_routes(routes = all_routes)
16
+ # ActionDispatch::Routing::RoutesInspector.new.collect_routes(_routes.routes)
17
+ ROUTE_INSPECTOR.send :collect_routes, routes
18
+ end
19
+
20
+ def self.all_routes
21
+ Rails.application.reload_routes!
22
+ Rails.application.routes.routes
23
+ end
24
+ end
metadata ADDED
@@ -0,0 +1,145 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: pretty_routes
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Angel M de Miguel
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-10 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: rails
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '3.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '3.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: capybara
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 0.4.0
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 0.4.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: launchy
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 2.1.0
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 2.1.0
55
+ - !ruby/object:Gem::Dependency
56
+ name: poltergeist
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ">="
74
+ - !ruby/object:Gem::Version
75
+ version: '0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ">="
81
+ - !ruby/object:Gem::Version
82
+ version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: sqlite3
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
97
+ description: PrettyRoutes is a Rails engine to display and interact with routes of
98
+ your application
99
+ email:
100
+ - angel@laux.es
101
+ executables: []
102
+ extensions: []
103
+ extra_rdoc_files: []
104
+ files:
105
+ - LICENSE
106
+ - README.md
107
+ - Rakefile
108
+ - app/assets/javascripts/pretty_routes/application.js
109
+ - app/assets/javascripts/pretty_routes/pretty_routes.js
110
+ - app/assets/stylesheets/pretty_routes/application.css
111
+ - app/controllers/pretty_routes/application_controller.rb
112
+ - app/controllers/pretty_routes/routes_controller.rb
113
+ - app/views/layouts/pretty_routes/application.html.erb
114
+ - app/views/pretty_routes/routes/_route.html.erb
115
+ - app/views/pretty_routes/routes/_route_wrapper.html.erb
116
+ - app/views/pretty_routes/routes/index.html.erb
117
+ - lib/pretty_routes.rb
118
+ - lib/pretty_routes/engine.rb
119
+ - lib/pretty_routes/version.rb
120
+ homepage: http://irb.rocks
121
+ licenses:
122
+ - MIT
123
+ metadata: {}
124
+ post_install_message:
125
+ rdoc_options: []
126
+ require_paths:
127
+ - lib
128
+ required_ruby_version: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - ">="
131
+ - !ruby/object:Gem::Version
132
+ version: '0'
133
+ required_rubygems_version: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
138
+ requirements: []
139
+ rubyforge_project:
140
+ rubygems_version: 2.4.8
141
+ signing_key:
142
+ specification_version: 4
143
+ summary: PrettyRoutes is a Rails engine to display and interact with routes of your
144
+ application
145
+ test_files: []