Class: Traceroute
- Inherits:
-
Object
- Object
- Traceroute
- Defined in:
- lib/traceroute.rb
Defined Under Namespace
Classes: Railtie
Constant Summary collapse
- VERSION =
Gem.loaded_specs['traceroute'].version.to_s
- WILDCARD_ROUTES =
%r[^/?:controller\(?/:action].freeze
Instance Method Summary collapse
- #defined_action_methods ⇒ Object
-
#initialize(app) ⇒ Traceroute
constructor
A new instance of Traceroute.
- #load_everything! ⇒ Object
- #routed_actions ⇒ Object
Constructor Details
#initialize(app) ⇒ Traceroute
Returns a new instance of Traceroute.
15 16 17 18 |
# File 'lib/traceroute.rb', line 15 def initialize(app) @app = app load_ignored_regex! end |
Instance Method Details
#defined_action_methods ⇒ Object
30 31 32 33 34 35 36 37 38 |
# File 'lib/traceroute.rb', line 30 def defined_action_methods [ActionController::Base, ActionController::API].map do |klass| klass.descendants.map do |controller| controller.action_methods.reject {|a| (a =~ /\A(_conditional)?_callback_/) || (a == '_layout_from_proc')}.map do |action| "#{controller.controller_path}##{action}" end end.flatten end.flatten.reject {|r| @ignored_unreachable_actions.any? { |m| r.match(m) } } end |
#load_everything! ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/traceroute.rb', line 20 def load_everything! @app.eager_load! ::Rails::InfoController rescue NameError ::Rails::WelcomeController rescue NameError ::Rails::MailersController rescue NameError @app.reload_routes! Rails::Engine.subclasses.each(&:eager_load!) end |
#routed_actions ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 |
# File 'lib/traceroute.rb', line 40 def routed_actions routes.map do |r| if r.requirements[:controller].present? && r.requirements[:action].present? "#{r.requirements[:controller]}##{r.requirements[:action]}" elsif (String === r.path) && (WILDCARD_ROUTES =~ r.path) %Q["#{r.path}" ⚠️ This is a legacy wild controller route that's not recommended for RESTful applications.] elsif WILDCARD_ROUTES =~ r.path.spec.to_s %Q["#{r.path.spec}" ⚠️ This is a legacy wild controller route that's not recommended for RESTful applications.] else ((String === r.path) && r.path.to_s) || r.path.spec.to_s # unknown routes end end.compact.flatten.reject {|r| @ignored_unused_routes.any? { |m| r.match(m) } } end |