sorted_routes 0.2.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -1
- data/lib/sorted_routes.rb +0 -1
- data/lib/sorted_routes/version.rb +1 -1
- data/lib/tasks/sorted_routes.rake +51 -30
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4cceabcebb2396aebca7629b76f658229dc8cdd8
|
4
|
+
data.tar.gz: d20bfbdfad9510c7e79b4b4e418c43fddc7cf20a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31c947742bcf363aa5a63b6cfe4278f79307fe5f3fc6904adbce031b902d74b52f6369108eede960cbf2ba6d328890f6e72332bb15a8dd5abdb1e44c55f3f607
|
7
|
+
data.tar.gz: 8972ed04cef702b24571c910f9236a71fe43f3ae9baa13050915ed751ef13b5fd61d90b4137f49ad1485fde30fb9b566d8065dd1b19eb452bd6b7322a9c1b180
|
data/README.md
CHANGED
@@ -1,3 +1,35 @@
|
|
1
|
-
#
|
1
|
+
# SortedRoutes
|
2
2
|
|
3
3
|
Rails routes in a searchable and sortable table in your browser.
|
4
|
+
|
5
|
+
![](sorted_routes-example.png)
|
6
|
+
|
7
|
+
### Installation
|
8
|
+
Add the gem to the `development:` group of a Rails Gemfile and run `bundle install`.
|
9
|
+
|
10
|
+
```
|
11
|
+
gem 'sorted_routes', '~> 1.0'
|
12
|
+
```
|
13
|
+
Link to RubyGems: [SortedRoutes](https://rubygems.org/gems/sorted_routes)
|
14
|
+
|
15
|
+
### Usage
|
16
|
+
|
17
|
+
```
|
18
|
+
rake sorted_routes
|
19
|
+
```
|
20
|
+
A rake task generates and opens the HTML file `tmp/sorted_routes.html` in your default browser.
|
21
|
+
|
22
|
+
### Features
|
23
|
+
|
24
|
+
**SortedRoutes** uses the DataTables jQuery plugin to create search and sort functionality.
|
25
|
+
+ Each column is sortable in ascending or descending order. (Click on arrows next to column header.)
|
26
|
+
+ Search box in the top-right corner allows user to select rows to view.
|
27
|
+
+ Routes table can be copied, printed, or saved as a pdf by clicking on buttons in the top-left corner.
|
28
|
+
|
29
|
+
### System Dependencies
|
30
|
+
+ Launchy (included in the gem) opens the HTML file
|
31
|
+
+ jQuery
|
32
|
+
+ DataTables jQuery plugin is used to generate the tables.
|
33
|
+
|
34
|
+
## Author
|
35
|
+
Created by [Scott Lenander](http://scottlenander.com/)
|
data/lib/sorted_routes.rb
CHANGED
@@ -7,36 +7,52 @@ task :sorted_routes => :environment do
|
|
7
7
|
output_file = File.join(Rails.root, 'tmp/sorted_routes.html')
|
8
8
|
|
9
9
|
File.open(output_file, 'w') do |f|
|
10
|
-
f.puts "<html
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
10
|
+
f.puts "<html>
|
11
|
+
<head>
|
12
|
+
<title>Rails Sorted Routes</title>
|
13
|
+
<meta name='viewport' content='width=device-width, initial-scale=1'>
|
14
|
+
<script src='https://code.jquery.com/jquery-1.12.4.js'></script>
|
15
|
+
<script type='text/javascript' charset='utf8' src='https://cdn.datatables.net/1.10.16/js/jquery.dataTables.js'></script>
|
16
|
+
<link rel='stylesheet' type='text/css' href='https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.10.16/b-1.5.1/b-html5-1.5.1/b-print-1.5.1/cr-1.4.1/datatables.min.css'/>
|
17
|
+
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/pdfmake.min.js'></script>
|
18
|
+
<script type='text/javascript' src='https://cdnjs.cloudflare.com/ajax/libs/pdfmake/0.1.32/vfs_fonts.js'></script>
|
19
|
+
<script type='text/javascript' src='https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.10.16/b-1.5.1/b-html5-1.5.1/b-print-1.5.1/cr-1.4.1/datatables.min.js'></script>
|
20
|
+
|
21
|
+
<script type='text/javascript'>
|
22
|
+
$(document).ready(function() {
|
23
|
+
$('#sorted-routes').DataTable({
|
24
|
+
'pageLength': 100,
|
25
|
+
'order': [ 3, 'asc' ],
|
26
|
+
'columnDefs': [
|
27
|
+
{ className: 'dt-right', 'targets': [ 0 ] }
|
28
|
+
],
|
29
|
+
dom: 'Bfrtip',
|
30
|
+
buttons: [
|
31
|
+
'copy', 'print', 'pdf'
|
32
|
+
]
|
33
|
+
});
|
31
34
|
});
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
35
|
+
</script>
|
36
|
+
<link rel='stylesheet' type='text/css' href='https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css'>
|
37
|
+
<style type='text/css'>
|
38
|
+
body {
|
39
|
+
font-family: 'Helvetica', 'Arial', sans-serif;
|
40
|
+
color: Navy;
|
41
|
+
}
|
42
|
+
</style>
|
43
|
+
</head>
|
44
|
+
<body>
|
45
|
+
<h1 style='text-align:center;'>SortedRoutes for #{Rails.application.class.parent.to_s}</h2>
|
46
|
+
<table id='sorted-routes' class='compact hover order-column row-border' width='100%'>
|
47
|
+
<thead>
|
48
|
+
<tr>
|
49
|
+
<th>Name</th>
|
50
|
+
<th>Verb</th>
|
51
|
+
<th>Path</th>
|
52
|
+
<th>Requirements</th>
|
53
|
+
</tr>
|
54
|
+
</thead>
|
55
|
+
<tbody>"
|
40
56
|
|
41
57
|
Rails.application.routes.routes.map do |route|
|
42
58
|
unless route.requirements.empty?
|
@@ -47,7 +63,12 @@ task :sorted_routes => :environment do
|
|
47
63
|
controller = route.defaults[:controller].to_s
|
48
64
|
action = route.defaults[:action].to_s
|
49
65
|
|
50
|
-
f.puts "<tr
|
66
|
+
f.puts "<tr>
|
67
|
+
<td style='color:Blue;'>#{name}</td>
|
68
|
+
<td style='color:SeaGreen;'>#{verb}</td>
|
69
|
+
<td style='color:Red;'>#{path}</td>
|
70
|
+
<td><span style='color:Red;'>#{controller}</span><span style='color:DarkTurquoise;'>##{action}</span></td>
|
71
|
+
</tr>"
|
51
72
|
end
|
52
73
|
end
|
53
74
|
|