betterroutes 0.1.8 → 0.2.0
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.
- data/lib/betterroutes.rb +3 -0
- data/lib/railtie.rb +11 -0
- data/lib/tasks/betterroutes.rake +51 -56
- metadata +6 -5
data/lib/betterroutes.rb
ADDED
data/lib/railtie.rb
ADDED
data/lib/tasks/betterroutes.rake
CHANGED
@@ -1,61 +1,56 @@
|
|
1
1
|
desc 'Better Routes -- A colorized version of Rake Routes'
|
2
2
|
require 'colorize'
|
3
3
|
|
4
|
-
|
5
|
-
desc "Better Routes"
|
6
|
-
task :broutes => :environment do
|
7
|
-
|
8
|
-
puts "Task called successfully!"
|
9
|
-
|
10
|
-
#path_length = 0
|
11
|
-
#verb_length = 0
|
12
|
-
#name_length = 0
|
13
|
-
#ca_length = 0
|
14
|
-
#exclude = ['/assets', '/rails/info/properties']
|
15
|
-
#
|
16
|
-
## Determine column widths
|
17
|
-
#Twotp::Application.routes.routes.each do |route|
|
18
|
-
# path_length = route.path.gsub('(.:format)', '').length if route.path.gsub('(.:format)', '').length > path_length
|
19
|
-
# verb_length = route.verb.length if route.verb.length > verb_length
|
20
|
-
# name_length = route.name.to_s.length if route.name.to_s.length > name_length
|
21
|
-
#
|
22
|
-
# if route.defaults != nil
|
23
|
-
# controller_width = route.defaults[:controller].to_s.length
|
24
|
-
# action_width = route.defaults[:action].to_s.length
|
25
|
-
# ca_length = controller_width + action_width if (controller_width + action_width) > ca_length
|
26
|
-
# end
|
27
|
-
#end
|
28
|
-
#
|
29
|
-
## Header
|
30
|
-
#output = "--PATH" << ("-" * (path_length - 5))
|
31
|
-
#output << "|-METHOD" << ("-" * (verb_length - 5))
|
32
|
-
#output << "|-NAME" << ("-" * (name_length - 3))
|
33
|
-
#output << "|-CONTROLLER / ACTION" << ("-" * (ca_length - 4))
|
34
|
-
#header = output.blue
|
35
|
-
#puts header
|
36
|
-
#
|
37
|
-
## Routes
|
38
|
-
#Twotp::Application.routes.routes.each do |route|
|
39
|
-
#
|
40
|
-
# # Exclusion list
|
41
|
-
# unless exclude.include? route.path.gsub('(.:format)', '')
|
42
|
-
# output = "#{route.path.gsub('(.:format)', '')}".yellow
|
43
|
-
# output << " " * (path_length - route.path.gsub('(.:format)', '').length)
|
44
|
-
# output << " |".blue
|
45
|
-
# output << " #{route.verb}".magenta
|
46
|
-
# output << " " * (verb_length - route.verb.length)
|
47
|
-
# output << " | ".blue
|
48
|
-
# output << "#{route.name}".white
|
49
|
-
# output << " " * (name_length - route.name.to_s.length)
|
50
|
-
# output << " | ".blue
|
51
|
-
# output << "C: ".red
|
52
|
-
# output << route.defaults[:controller].to_s.green
|
53
|
-
# output << ", A: ".red
|
54
|
-
# output << route.defaults[:action].to_s.green
|
55
|
-
# puts output
|
56
|
-
# end
|
57
|
-
#end
|
58
|
-
#puts header
|
4
|
+
task :broutes => :environment do
|
59
5
|
|
6
|
+
path_length = 0
|
7
|
+
verb_length = 0
|
8
|
+
name_length = 0
|
9
|
+
ca_length = 0
|
10
|
+
exclude = ['/assets', '/rails/info/properties']
|
11
|
+
|
12
|
+
# Determine column widths
|
13
|
+
Rails.application.routes.routes.each do |route|
|
14
|
+
path_length = route.path.gsub('(.:format)', '').length if route.path.gsub('(.:format)', '').length > path_length
|
15
|
+
verb_length = route.verb.length if route.verb.length > verb_length
|
16
|
+
name_length = route.name.to_s.length if route.name.to_s.length > name_length
|
17
|
+
|
18
|
+
if route.defaults != nil
|
19
|
+
controller_width = route.defaults[:controller].to_s.length
|
20
|
+
action_width = route.defaults[:action].to_s.length
|
21
|
+
ca_length = controller_width + action_width if (controller_width + action_width) > ca_length
|
22
|
+
end
|
60
23
|
end
|
61
|
-
|
24
|
+
|
25
|
+
# Header
|
26
|
+
output = "--PATH" << ("-" * (path_length - 5))
|
27
|
+
output << "|-METHOD" << ("-" * (verb_length - 5))
|
28
|
+
output << "|-NAME" << ("-" * (name_length - 3))
|
29
|
+
output << "|-CONTROLLER / ACTION" << ("-" * (ca_length - 4))
|
30
|
+
header = output.blue
|
31
|
+
puts header
|
32
|
+
|
33
|
+
# Routes
|
34
|
+
Rails.application.routes.routes.each do |route|
|
35
|
+
|
36
|
+
# Exclusion list
|
37
|
+
unless exclude.include? route.path.gsub('(.:format)', '')
|
38
|
+
output = "#{route.path.gsub('(.:format)', '')}".yellow
|
39
|
+
output << " " * (path_length - route.path.gsub('(.:format)', '').length)
|
40
|
+
output << " |".blue
|
41
|
+
output << " #{route.verb}".magenta
|
42
|
+
output << " " * (verb_length - route.verb.length)
|
43
|
+
output << " | ".blue
|
44
|
+
output << "#{route.name}".white
|
45
|
+
output << " " * (name_length - route.name.to_s.length)
|
46
|
+
output << " | ".blue
|
47
|
+
output << "C: ".red
|
48
|
+
output << route.defaults[:controller].to_s.green
|
49
|
+
output << ", A: ".red
|
50
|
+
output << route.defaults[:action].to_s.green
|
51
|
+
puts output
|
52
|
+
end
|
53
|
+
end
|
54
|
+
puts header
|
55
|
+
|
56
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: betterroutes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-01-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: colorize
|
@@ -27,13 +27,14 @@ dependencies:
|
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
29
|
version: '0'
|
30
|
-
description:
|
31
|
-
of the Rake routes listing.
|
30
|
+
description: A better colorized, formatted visualization of the Rake routes listing.
|
32
31
|
email: caedmon@statebuilt.com
|
33
32
|
executables: []
|
34
33
|
extensions: []
|
35
34
|
extra_rdoc_files: []
|
36
35
|
files:
|
36
|
+
- lib/betterroutes.rb
|
37
|
+
- lib/railtie.rb
|
37
38
|
- lib/tasks/betterroutes.rake
|
38
39
|
homepage:
|
39
40
|
licenses: []
|
@@ -58,5 +59,5 @@ rubyforge_project:
|
|
58
59
|
rubygems_version: 1.8.24
|
59
60
|
signing_key:
|
60
61
|
specification_version: 3
|
61
|
-
summary:
|
62
|
+
summary: Better Rake routes listing in full color
|
62
63
|
test_files: []
|