47d313c90409f63ee6b06c65f2372bbf847c106b

Author
Marc Cornellà <hello@mcornella.com>
Committer
Marc Cornellà <hello@mcornella.com>
Date

Message

chore(rails): fix comments and docs

Diff

 1diff --git a/plugins/rails/README.md b/plugins/rails/README.md
 2index 0a6c68c75ace723a2fb68720353b7847b5e82f8a..3eee12fbdcdcf34b7729cc700e1417d84e0b57dd 100644
 3--- a/plugins/rails/README.md
 4+++ b/plugins/rails/README.md
 5@@ -1,6 +1,7 @@
 6 # Rails
 7 
 8-This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and [Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
 9+This plugin adds completion for [Ruby On Rails Framework](https://rubyonrails.org/) and
10+[Rake](https://ruby.github.io/rake/) commands, as well as some aliases for logs and environment variables.
11 
12 To use it, add `rails` to the plugins array in your zshrc file:
13 
14@@ -67,7 +68,9 @@ plugins=(... rails)
15 These are global aliases. Use in combination with a command or just run them
16 separately. For example: `REP rake db:migrate` will migrate the production db.
17 
18-### Legacy rake aliases
19+## Legacy
20+
21+### Rake aliases
22 
23 The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the
24 prefix `rk` for backwards compatibility.
25@@ -93,7 +96,7 @@ prefix `rk` for backwards compatibility.
26 | `rksts`  | `rake stats`                    | Print code statistics                                  |
27 | `rkt`    | `rake test`                     | Run Rails tests                                        |
28 
29-### Legacy stuff
30+### Other
31 
32 | Alias   | Command                            |
33 | ------- | ---------------------------------- |
34@@ -105,3 +108,5 @@ prefix `rk` for backwards compatibility.
35 | `sr`    | `ruby script/runner`               |
36 | `ssp`   | `ruby script/spec`                 |
37 | `sstat` | `thin --stats "/thin/stats" start` |
38+
39+- `remote_console <server> <directory>`: runs `ruby script/console production` on a remote server.
40diff --git a/plugins/rails/rails.plugin.zsh b/plugins/rails/rails.plugin.zsh
41index f2b0f8293d7db5cfcfd28ccdd11278db156d6c0d..e724bffc4091862ad087338f8e3c68568b51bd39 100644
42--- a/plugins/rails/rails.plugin.zsh
43+++ b/plugins/rails/rails.plugin.zsh
44@@ -1,3 +1,4 @@
45+# rails command wrapper
46 function _rails_command () {
47   if [ -e "bin/stubs/rails" ]; then
48     bin/stubs/rails $@
49@@ -12,28 +13,31 @@ function _rails_command () {
50   fi
51 }
52 
53+alias rails='_rails_command'
54+compdef _rails_command=rails
55+
56+# rake command wrapper
57 function _rake_command () {
58   if [ -e "bin/stubs/rake" ]; then
59     bin/stubs/rake $@
60   elif [ -e "bin/rake" ]; then
61     bin/rake $@
62-  elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
63+  elif type bundle &> /dev/null && [[ -e "Gemfile" || -e "gems.rb" ]]; then
64     bundle exec rake $@
65   else
66     command rake $@
67   fi
68 }
69 
70-alias rails='_rails_command'
71-compdef _rails_command=rails
72-
73 alias rake='_rake_command'
74 compdef _rake_command=rake
75 
76+# Log aliases
77 alias devlog='tail -f log/development.log'
78 alias prodlog='tail -f log/production.log'
79 alias testlog='tail -f log/test.log'
80 
81+# Environment settings
82 alias -g RED='RAILS_ENV=development'
83 alias -g REP='RAILS_ENV=production'
84 alias -g RET='RAILS_ENV=test'