Module: RailsRoutesAnalyzer
- Defined in:
- lib/rails_routes_analyzer/railtie.rb,
lib/rails_routes_analyzer/version.rb,
lib/rails_routes_analyzer/route_call.rb,
lib/rails_routes_analyzer/route_line.rb,
lib/rails_routes_analyzer/gem_manager.rb,
lib/rails_routes_analyzer/route_analysis.rb,
lib/rails_routes_analyzer/action_analysis.rb,
lib/rails_routes_analyzer/route_issue/base.rb,
lib/rails_routes_analyzer/parameter_handler.rb,
lib/rails_routes_analyzer/route_interceptor.rb,
lib/rails_routes_analyzer/route_file_annotator.rb,
lib/rails_routes_analyzer/rails_routes_analyzer.rb,
lib/rails_routes_analyzer/route_issue/no_action.rb,
lib/rails_routes_analyzer/route_issue/resources.rb,
lib/rails_routes_analyzer/route_issue/no_controller.rb
Defined Under Namespace
Modules: GemManager, ParameterHandler, RouteInterceptor, RouteIssue
Classes: ActionAnalysis, ActionMethod, Railtie, RouteAnalysis, RouteCall, RouteFileAnnotator, RouteLine
Constant Summary
collapse
- VERSION =
"2.0.1".freeze
- RESOURCE_ACTIONS =
[:index, :create, :new, :show, :update, :destroy, :edit].freeze
- MAX_ACTION_LENGTH =
Don’t align action names longer than this
30
- MULTI_METHODS =
%w(resource resources).freeze
- SINGLE_METHODS =
%w(match get head post patch put delete options root).freeze
- ROUTE_METHODS =
(MULTI_METHODS + SINGLE_METHODS).freeze
Class Method Summary
collapse
Class Method Details
.get_full_filename(filename) ⇒ Object
Converts Rails.root-relative filenames to be absolute.
11
12
13
14
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 11
def get_full_filename(filename)
return filename.to_s if filename.to_s.starts_with?('/')
Rails.root.join(filename).to_s
end
|
.routes_actions_list_all(env, extras) ⇒ Object
55
56
57
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 55
def routes_actions_list_all(env, )
routes_actions_common(env, , report_routed: true)
end
|
.routes_actions_missing_route(env, extras) ⇒ Object
51
52
53
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 51
def routes_actions_missing_route(env, )
routes_actions_common(env, , report_routed: false)
end
|
.routes_dead(env) ⇒ Object
28
29
30
31
32
33
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 28
def routes_dead(env)
params = RailsRoutesAnalyzer::ParameterHandler.params_for_route_analysis(env)
analysis = RailsRoutesAnalyzer::RouteAnalysis.new(params)
analysis.print_report
end
|
.routes_dead_annotate(env) ⇒ Object
35
36
37
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 35
def routes_dead_annotate(env)
routes_dead_annotate_common(env)
end
|
.routes_dead_annotate_inplace(env, extras) ⇒ Object
39
40
41
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 39
def routes_dead_annotate_inplace(env, )
routes_dead_annotate_common(env, , inplace: true)
end
|
.routes_dead_fix(env) ⇒ Object
43
44
45
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 43
def routes_dead_fix(env)
routes_dead_fix_common(env)
end
|
.routes_dead_fix_inplace(env, extras) ⇒ Object
47
48
49
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 47
def routes_dead_fix_inplace(env, )
routes_dead_fix_common(env, , inplace: true)
end
|
.sanitize_source_location(source_location, full_path: false) ⇒ Object
Shortens full file path, replacing Rails.root and gem path with appropriate short prefixes to make the file names look good.
18
19
20
21
22
23
24
25
26
|
# File 'lib/rails_routes_analyzer/rails_routes_analyzer.rb', line 18
def sanitize_source_location(source_location, full_path: false)
source_location.dup.tap do |clean_location|
unless full_path
clean_location.gsub! "#{Rails.root}/", './'
clean_location.replace GemManager.clean_gem_path(clean_location)
end
end
end
|