html_routes 0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/README.md +32 -0
- data/lib/html_routes/railtie.rb +8 -0
- data/lib/html_routes/version.rb +3 -0
- data/lib/html_routes.rb +1 -0
- data/lib/tasks/html_routes.rake +53 -0
- metadata +91 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 42f34fa173097a672aa41056fbb9636fb0996dc5
|
4
|
+
data.tar.gz: 7e6ccc36c7e56f984fee80100096efdfa014f173
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 2c96a4bab11a1b6fa7eb06712a58c509995ff2242e6ffb6843c165f84bd59e39eaf93e7044ec302270505ba53a0bd56dd23266bb443dd7f932a5ee69dab541a4
|
7
|
+
data.tar.gz: c313bb9e1911f85aeae602e38a630349e3f004fe86fdef92f26c58b255d2df53b413dc114dfe4d61862fee1affdd1bfa5316baa52fd27a731bd2ae3b46c80bb2
|
data/README.md
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
Rails HtmlRoutes
|
2
|
+
================
|
3
|
+
|
4
|
+
Output your Rails routes to html:
|
5
|
+
|
6
|
+

|
7
|
+
|
8
|
+
## Installation
|
9
|
+
|
10
|
+
Add it to your Gemfile and run bundle install:
|
11
|
+
|
12
|
+
```ruby
|
13
|
+
gem 'html_routes'
|
14
|
+
```
|
15
|
+
|
16
|
+
## Usage
|
17
|
+
|
18
|
+
```bash
|
19
|
+
rake html_routes
|
20
|
+
```
|
21
|
+
|
22
|
+
To specify a custom output file:
|
23
|
+
|
24
|
+
```bash
|
25
|
+
rake html_routes out=tmp/custom_file.html
|
26
|
+
```
|
27
|
+
|
28
|
+
If you don't want the output file to open in your browser automatically:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
rake html_routes background=true
|
32
|
+
```
|
data/lib/html_routes.rb
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require 'html_routes/railtie'
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'syntax/convertors/html'
|
2
|
+
require 'launchy'
|
3
|
+
|
4
|
+
# Custom HTML output of rake routes.
|
5
|
+
task html_routes: :environment do
|
6
|
+
out_file = ENV['out'] || File.join(Rails.root, 'tmp/routes.html')
|
7
|
+
convertor = Syntax::Convertors::HTML.for_syntax 'ruby'
|
8
|
+
|
9
|
+
File.open(out_file, 'w') do |f|
|
10
|
+
f.puts '<html><head><title>Rails routes</title>
|
11
|
+
<style type="text/css">
|
12
|
+
body { background-color: #333; color: #FFF; }
|
13
|
+
table { border: 1px solid #777; background-color: #111; }
|
14
|
+
td, th { font-size: 11pt; text-align: left; padding-right: 10px; }
|
15
|
+
th { font-size: 12pt; }
|
16
|
+
pre { maring: 0; padding: 0; }
|
17
|
+
.contrl_head { font-size: 14pt; padding: 15px 0 5px 0; }
|
18
|
+
.contrl_name { color: #ACE; }
|
19
|
+
.punct { color: #99F; font-weight: bold; }
|
20
|
+
.symbol { color: #7DD; }
|
21
|
+
.regex { color: #F66; }
|
22
|
+
.string { color: #F99; }4
|
23
|
+
</style></head>
|
24
|
+
<body>'
|
25
|
+
|
26
|
+
last_contrl = nil
|
27
|
+
|
28
|
+
Rails.application.routes.routes.map do |route|
|
29
|
+
unless route.requirements.empty?
|
30
|
+
if route.requirements[:controller] != last_contrl
|
31
|
+
f.puts '</table>' if last_contrl
|
32
|
+
last_contrl = route.requirements[:controller]
|
33
|
+
f.puts "<div class='contrl_head'><b>Controller: <span class='contrl_name'>#{last_contrl}</span></b></div>" +
|
34
|
+
"<table width='100%' border='0'><tr><th>Name</th><th>Verb</th><th>Path</th><th>Requirements</th></tr>"
|
35
|
+
end
|
36
|
+
|
37
|
+
reqs = route.requirements.inspect
|
38
|
+
verb = route.verb.source
|
39
|
+
verb = verb[1..(verb.length - 2)] if verb
|
40
|
+
r = { name: route.name, verb: verb, path: route.path, reqs: reqs }
|
41
|
+
f.puts "<tr><td width='12%'><b>#{r[:name]}</b></td><td width='5%'><b>#{r[:verb]}</b></td>" +
|
42
|
+
"<td width='3%'>#{r[:path]}</td><td width='80%'>#{convertor.convert(r[:reqs])}</td></tr>"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
f.puts '</table></body></html>'
|
47
|
+
|
48
|
+
puts "Generated routes to file://#{out_file}."
|
49
|
+
unless ENV['background'] == 'true'
|
50
|
+
Launchy.open("file://#{out_file}")
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
metadata
ADDED
@@ -0,0 +1,91 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: html_routes
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: '0.9'
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Pierre Pretorius
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2014-03-01 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: '2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: syntax
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1'
|
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'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '2'
|
55
|
+
description: Generate a syntax highligthed HTML file from your Rails routes.
|
56
|
+
email:
|
57
|
+
- pierre@labs.epiuse.com
|
58
|
+
executables: []
|
59
|
+
extensions: []
|
60
|
+
extra_rdoc_files: []
|
61
|
+
files:
|
62
|
+
- README.md
|
63
|
+
- lib/html_routes.rb
|
64
|
+
- lib/html_routes/railtie.rb
|
65
|
+
- lib/html_routes/version.rb
|
66
|
+
- lib/tasks/html_routes.rake
|
67
|
+
homepage: https://github.com/pierre-pretorius/html_routes
|
68
|
+
licenses:
|
69
|
+
- MIT
|
70
|
+
metadata: {}
|
71
|
+
post_install_message:
|
72
|
+
rdoc_options: []
|
73
|
+
require_paths:
|
74
|
+
- lib
|
75
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
76
|
+
requirements:
|
77
|
+
- - ">="
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: '0'
|
80
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
81
|
+
requirements:
|
82
|
+
- - ">="
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 2.2.0
|
88
|
+
signing_key:
|
89
|
+
specification_version: 4
|
90
|
+
summary: Output your Rails routes to html.
|
91
|
+
test_files: []
|