rails-route-checker 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rails-route-checker/app_interface.rb +18 -13
- data/lib/rails-route-checker/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c2ee3366805e8dbc68755df5f5ce5e1342f5be11
|
4
|
+
data.tar.gz: 9ce06f8c42d7f2940ee45ab82ad491afce95f2fa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da784f02dd0cb29e448fb698e89196709a2b7be7b080b4d7e9c8770bf11bc66ec158907da3f51e9ff81fc3ebdf355dad4d047aebdb80675b4953038a0355ee3f
|
7
|
+
data.tar.gz: 87d43f4feca31e8f58820570439fddbe97be9499ea5828a8111b9439e9e75df068c2d0bf5ae085c91b43dc1d3a452e548b996daeefd7b314489e5710233b311d
|
@@ -42,13 +42,14 @@ module RailsRouteChecker
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def generate_undef_view_path_calls_erb
|
45
|
-
files =
|
45
|
+
files = Dir['app/**/*.erb']
|
46
46
|
return [] if files.none?
|
47
47
|
|
48
48
|
RailsRouteChecker::Parsers::Loader.load_parser(:erb)
|
49
49
|
|
50
50
|
files.map do |filename|
|
51
51
|
controller = controller_from_view_file(filename)
|
52
|
+
next unless controller # controller will be nil if it's an ignored controller
|
52
53
|
|
53
54
|
filter = lambda do |path_or_url|
|
54
55
|
return false if match_in_whitelist?(filename, path_or_url)
|
@@ -61,7 +62,7 @@ module RailsRouteChecker
|
|
61
62
|
end
|
62
63
|
|
63
64
|
def generate_undef_view_path_calls_haml
|
64
|
-
files =
|
65
|
+
files = Dir['app/**/*.haml']
|
65
66
|
return [] if files.none?
|
66
67
|
|
67
68
|
unless RailsRouteChecker::Parsers::Loader.haml_available?
|
@@ -74,6 +75,7 @@ module RailsRouteChecker
|
|
74
75
|
|
75
76
|
files.map do |filename|
|
76
77
|
controller = controller_from_view_file(filename)
|
78
|
+
next unless controller # controller will be nil if it's an ignored controller
|
77
79
|
|
78
80
|
filter = lambda do |path_or_url|
|
79
81
|
return false if match_in_whitelist?(filename, path_or_url)
|
@@ -86,7 +88,7 @@ module RailsRouteChecker
|
|
86
88
|
end
|
87
89
|
|
88
90
|
def generate_undef_controller_path_calls
|
89
|
-
files =
|
91
|
+
files = Dir['app/controllers/**/*.rb']
|
90
92
|
return [] if files.none?
|
91
93
|
|
92
94
|
RailsRouteChecker::Parsers::Loader.load_parser(:ruby)
|
@@ -127,20 +129,23 @@ module RailsRouteChecker
|
|
127
129
|
split_path = filename.split('/')
|
128
130
|
possible_controller_path = split_path[(split_path.index('app') + 2)..-2]
|
129
131
|
|
130
|
-
|
131
|
-
|
132
|
-
if
|
133
|
-
|
134
|
-
else
|
135
|
-
possible_controller_path = possible_controller_path[0..-2]
|
136
|
-
end
|
132
|
+
while possible_controller_path.any?
|
133
|
+
controller_name = possible_controller_path.join('/')
|
134
|
+
return controller_information[controller_name] if controller_exists?(controller_name)
|
135
|
+
possible_controller_path = possible_controller_path[0..-2]
|
137
136
|
end
|
138
|
-
|
137
|
+
controller_information['application']
|
139
138
|
end
|
140
139
|
|
141
140
|
def controller_from_ruby_file(filename)
|
142
|
-
controller_name = (filename.match(%r{app/controllers/(.*)_controller.rb}) || [])[1]
|
143
|
-
controller_information[controller_name]
|
141
|
+
controller_name = (filename.match(%r{app/controllers/(.*)_controller.rb}) || [])[1]
|
142
|
+
return controller_information[controller_name] if controller_exists?(controller_name)
|
143
|
+
controller_information['application']
|
144
|
+
end
|
145
|
+
|
146
|
+
def controller_exists?(controller_name)
|
147
|
+
return false unless controller_name
|
148
|
+
File.exists?("app/controllers/#{controller_name}_controller.rb")
|
144
149
|
end
|
145
150
|
end
|
146
151
|
end
|