rails_routes_analyzer 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +14 -13
- data/lib/rails_routes_analyzer/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: 4c8a7dce5c066dd869e7c0e2eb41a6854488b4c5
|
4
|
+
data.tar.gz: c4e6e2618c9eb9432714f8cabc452afd79cc4adf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9ecfdbf9246be70585e5b53212363d86c4b904e3fa4f4ff1389b6cc472fae4fc95418b1b33a1f91c5f9eea4de9f0c8bc72a5728672001a38dcd505d37ded07d8
|
7
|
+
data.tar.gz: 826640b5a98222e68083c6a9af348b7d4820b8a2557f54a0060de26a15bd922bcbd80254c3b025d454d65361b32ade88ed98a98716726cf3b88b810326753154
|
data/README.md
CHANGED
@@ -18,27 +18,24 @@ And then execute:
|
|
18
18
|
|
19
19
|
## Usage
|
20
20
|
|
21
|
+
### Finding and fixing dead routes
|
22
|
+
|
21
23
|
``` sh
|
22
24
|
rake routes:dead
|
23
25
|
```
|
24
26
|
|
25
|
-
Without any additional options this will scan all the routes and check for a matching action for each. For single routes created with methods such as
|
27
|
+
Without any additional options this will scan all the routes and check for a matching action for each. For single routes created with methods such as _get_ or _post_ it will tell you when that line could be removed.
|
26
28
|
|
27
|
-
For multi-route calls like
|
29
|
+
For multi-route calls like _resource_ and _resources_ it can also let you know if and how to set the _:except_ or _:only_ parameter to better match the actions a controller actually provides. When suggesting _:only_/_:except_ by default the one that provides a shorter list will be used.
|
28
30
|
|
29
|
-
For complex cases where for example
|
31
|
+
For complex cases where for example routes are created in a loop for multiple controllers a suggestion will be provided for each iteration but only if that specific iteration created a dead route. Every such suggestion will identify the exact controller to which it applies.
|
30
32
|
|
31
33
|
``` sh
|
32
34
|
rake routes:dead:annotate [ROUTES_FILE=path/to/routes.rb]
|
33
35
|
rake routes:dead:fix [ROUTES_FILE=path/to/routes.rb]
|
34
|
-
|
35
|
-
# Best used like this:
|
36
|
-
rake routes:dead:annotate > config/routest.rb.new
|
37
|
-
mv config/routes.rb.new config/routes.rb
|
38
|
-
# And then update the file as requested in any SUGGESTION comments
|
39
36
|
```
|
40
37
|
|
41
|
-
_routes:dead:annotate_ generates a commented version of a routes file. _routes:dead:fix_ generates a partly automatically fixed and partly commented version of a routes file. Without specifying a file in ROUTES_FILE parameter
|
38
|
+
_routes:dead:annotate_ generates a commented version of a routes file. _routes:dead:fix_ generates a partly automatically fixed and partly commented version of a routes file. Without specifying a file in ROUTES_FILE parameter a file is automatically picked provided that it is the only one that has problems, if there are more they will all be listed and a single name will have to be provided in the ROUTES_FILE parameter to proceed.
|
42
39
|
|
43
40
|
#### Additional options:
|
44
41
|
|
@@ -56,24 +53,28 @@ rake routes:dead:annotate:inplace[force] [ROUTES_FILE=path/to/routes.rb]
|
|
56
53
|
rake routes:dead:fix:inplace[force] [ROUTES_FILE=path/to/routes.rb]
|
57
54
|
```
|
58
55
|
|
59
|
-
Same as above but these commands change existing routes file content instead of printing it to standard output. By default they'll refuse to change a file if it's outside Rails root or has uncommited changes. To get around this protection set the ROUTES_FORCE=1 parameter.
|
56
|
+
Same as above but these commands change existing routes file content instead of printing it to standard output. By default they'll refuse to change a file if it's outside Rails root, not under git control or has uncommited changes. To get around this protection set the ROUTES_FORCE=1 parameter or include _[force]_ rake parameter.
|
60
57
|
|
58
|
+
### Listing actions that lack a route
|
61
59
|
|
62
60
|
```sh
|
63
61
|
rake actions:missing_route
|
64
62
|
rake actions:missing_route[gems,modules,duplicates,full,metadata] # parameters can be combined in all ways
|
65
63
|
```
|
66
64
|
|
67
|
-
Lists all action methods for all controllers which have no route pointing to them. By default ignores methods coming from gems, included modules or inherited from a parent controller. Uses the ActionController#Base.action\_methods method which usually returns a list of all public methods of the controller class excluding any special Rails provided methods.
|
65
|
+
Lists all action methods for all controllers which have no route pointing to them. By default ignores methods coming from gems, from included modules or which are inherited from a parent controller. Uses the ActionController#Base.action\_methods method which usually returns a list of all public methods of the controller class excluding any special Rails provided methods.
|
66
|
+
|
67
|
+
Generally it's not a problem to have ActionController#Base.action\_methods list non-actions given Rails no longer uses default routes that would benefit from proper limits on what is and what isn't an action. However there is also no obvious reason to be unable to correct it and possibly be able to use the resulting more accurate action metadata somewhere else (such as this tool).
|
68
68
|
|
69
|
-
|
69
|
+
The easiest way to remove non-actions from ActionController#Base.action\_methods is to make them protected or private. If that's not possible the other alternative is to override the action\_methods method itself on a controller and remove the relevant methods from the returned action list (this is more complicated and much more effort to keep updated.)
|
70
70
|
|
71
|
-
|
71
|
+
### Listing all actions that the app implements regardless of routes
|
72
72
|
|
73
73
|
```sh
|
74
74
|
rake actions:list_all
|
75
75
|
rake actions:list_all[gems,modules,duplicates,full,metadata] # parameters can be combined in all ways
|
76
76
|
```
|
77
|
+
This just provides a convenient way to list all actions in a controller class tree including the source file location for each one even if it comes from a gem (include the _[full]_ rake parameter to get full file path without shortening.)
|
77
78
|
|
78
79
|
#### Additional options:
|
79
80
|
_(applies to both actions:missing\_route and actions:list\_all)_
|