traceroute 0.8.0 → 0.8.1
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 +4 -4
- data/README.rdoc +2 -2
- data/lib/tasks/traceroute.rake +2 -6
- data/lib/traceroute.rb +11 -3
- data/test/traceroute_test.rb +2 -0
- data/traceroute.gemspec +1 -1
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6846d384263474eece3eb673268a34b514b0ec7b9f096073e2b45f3af8817bc6
|
4
|
+
data.tar.gz: 2776ad5760ade33db8534647b0dfdb2ca7df609bd3feeeb13c10fedbd6a8e755
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2088865d44a331d44da1033107db6aac13c8c0b782d715cb0661be0f0966b6addc35782b6d6c140e24ffa594e904007a43017d5b92e712bc8d8ac43b8a7e86e5
|
7
|
+
data.tar.gz: 46354a4b08c79d8d9af15bf40f7297141f00d4af438b06712cbc73e2190a1fd55d3ceb56ab2c66368e19781c4b559e819d7bef49feb6a647c80b8eb91c789adb
|
data/README.rdoc
CHANGED
@@ -10,9 +10,9 @@ This Rake task investigates your Rails application's routes definition, then sho
|
|
10
10
|
|
11
11
|
== Supported versions
|
12
12
|
|
13
|
-
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6 (trunk)
|
13
|
+
* Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8 (trunk)
|
14
14
|
|
15
|
-
* Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1.x, 5.0.x, 5.1.x
|
15
|
+
* Rails 3.0.x, 3.1.x, 3.2.x, 4.0.x, 4.1.x, 5.0.x, 5.1.x, 5.2.x, 6.0, 6.1 (master)
|
16
16
|
|
17
17
|
|
18
18
|
== Install
|
data/lib/tasks/traceroute.rake
CHANGED
@@ -5,12 +5,8 @@ task :traceroute => :environment do
|
|
5
5
|
traceroute = Traceroute.new Rails.application
|
6
6
|
traceroute.load_everything!
|
7
7
|
|
8
|
-
defined_action_methods = traceroute.defined_action_methods
|
9
|
-
|
10
|
-
routed_actions = traceroute.routed_actions
|
11
|
-
|
12
8
|
unless ENV['UNREACHABLE_ACTION_METHODS_ONLY']
|
13
|
-
unused_routes =
|
9
|
+
unused_routes = traceroute.unused_routes
|
14
10
|
puts "Unused routes (#{unused_routes.count}):"
|
15
11
|
unused_routes.each {|route| puts " #{route}"}
|
16
12
|
end
|
@@ -18,7 +14,7 @@ task :traceroute => :environment do
|
|
18
14
|
puts unless (ENV['UNREACHABLE_ACTION_METHODS_ONLY'] || ENV['UNUSED_ROUTES_ONLY'])
|
19
15
|
|
20
16
|
unless ENV['UNUSED_ROUTES_ONLY']
|
21
|
-
unreachable_action_methods =
|
17
|
+
unreachable_action_methods = traceroute.unreachable_action_methods
|
22
18
|
puts "Unreachable action methods (#{unreachable_action_methods.count}):"
|
23
19
|
unreachable_action_methods.each {|action| puts " #{action}"}
|
24
20
|
end
|
data/lib/traceroute.rb
CHANGED
@@ -42,8 +42,16 @@ class Traceroute
|
|
42
42
|
Rails::Engine.subclasses.each(&:eager_load!)
|
43
43
|
end
|
44
44
|
|
45
|
+
def unused_routes
|
46
|
+
routed_actions - defined_action_methods
|
47
|
+
end
|
48
|
+
|
49
|
+
def unreachable_action_methods
|
50
|
+
defined_action_methods - routed_actions
|
51
|
+
end
|
52
|
+
|
45
53
|
def defined_action_methods
|
46
|
-
[ActionController::Base, (ActionController::API if defined?(ActionController::API))].compact.map do |klass|
|
54
|
+
@defined_action_methods ||= [ActionController::Base, (ActionController::API if defined?(ActionController::API))].compact.map do |klass|
|
47
55
|
klass.descendants.map do |controller|
|
48
56
|
controller.action_methods.reject {|a| (a =~ /\A(_conditional)?_callback_/) || (a == '_layout_from_proc')}.map do |action|
|
49
57
|
"#{controller.controller_path}##{action}"
|
@@ -53,7 +61,7 @@ class Traceroute
|
|
53
61
|
end
|
54
62
|
|
55
63
|
def routed_actions
|
56
|
-
routes.map do |r|
|
64
|
+
@routed_actions ||= routes.map do |r|
|
57
65
|
if r.requirements[:controller].present? && r.requirements[:action].present?
|
58
66
|
"#{r.requirements[:controller]}##{r.requirements[:action]}"
|
59
67
|
elsif (String === r.path) && (WILDCARD_ROUTES =~ r.path)
|
@@ -72,7 +80,7 @@ class Traceroute
|
|
72
80
|
|
73
81
|
def collect_routes(routes)
|
74
82
|
routes = routes.each_with_object([]) do |r, tmp_routes|
|
75
|
-
next if (ActionDispatch::Routing::Mapper::Constraints === r.app) && (ActionDispatch::Routing::PathRedirect
|
83
|
+
next if (ActionDispatch::Routing::Mapper::Constraints === r.app) && (%w[ActionDispatch::Routing::PathRedirect ActionDispatch::Routing::Redirect].include?(r.app.app.class.name))
|
76
84
|
|
77
85
|
if r.app.is_a?(ActionDispatch::Routing::Mapper::Constraints) && r.app.app.respond_to?(:routes)
|
78
86
|
engine_routes = r.app.app.routes
|
data/test/traceroute_test.rb
CHANGED
@@ -22,6 +22,8 @@ module TracerouteTest
|
|
22
22
|
DummyApp::Application.routes.draw do
|
23
23
|
resources :users, :only => [:index, :show, :new, :create]
|
24
24
|
|
25
|
+
get '/', to: redirect('/users'), constraints: lambda { true }
|
26
|
+
|
25
27
|
namespace :admin do
|
26
28
|
resources :shops, :only => :index
|
27
29
|
end
|
data/traceroute.gemspec
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: traceroute
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Akira Matsuda
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-04-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -66,8 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
66
66
|
- !ruby/object:Gem::Version
|
67
67
|
version: '0'
|
68
68
|
requirements: []
|
69
|
-
|
70
|
-
rubygems_version: 2.7.6
|
69
|
+
rubygems_version: 3.1.2
|
71
70
|
signing_key:
|
72
71
|
specification_version: 4
|
73
72
|
summary: A Rake task that helps you find the dead routes and actions for your Rails
|