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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6438d7f464a7b4bfe625d5d7b0c046bb7dec19b6
4
- data.tar.gz: e85d81221ecd342ec9b4a8ca995b9e9c4955586e
3
+ metadata.gz: 4c8a7dce5c066dd869e7c0e2eb41a6854488b4c5
4
+ data.tar.gz: c4e6e2618c9eb9432714f8cabc452afd79cc4adf
5
5
  SHA512:
6
- metadata.gz: d0a0f433be53c34ca4b61fc3167b0913807b1a967096c76dc903c52cb796b91ddb11c5088f27e6f201c81bc27115e972e5b58016304f15e5a36839fbbdf16e35
7
- data.tar.gz: 8a6d61768c8ee3c80e513e7d05f8b98fed8ee70b3ba3b93ddba5268424bd32fb16f6126ac632db321cbfe664272d2dfb75c82aae619b64dd90de7920fdf10008
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 `get' or `post' it will tell you when that line could be removed.
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 `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.
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 a 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.
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 one 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.
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
- 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 more accurate metadata somewhere else (such as this tool).
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
- 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 and remove the relevant methods from the returned action list (this is more complicated and much more effort to keep updated.)
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)_
@@ -1,3 +1,3 @@
1
1
  module RailsRoutesAnalyzer
2
- VERSION = "2.0.0".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_routes_analyzer
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Bear Metal OÜ