浏览代码

chore(rails): fix comments and docs

Marc Cornellà 2 年之前
父节点
当前提交
47d313c904
共有 2 个文件被更改,包括 16 次插入7 次删除
  1. 8 3
      plugins/rails/README.md
  2. 8 4
      plugins/rails/rails.plugin.zsh

+ 8 - 3
plugins/rails/README.md

@@ -1,6 +1,7 @@
 # Rails
 
-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.
+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.
 
 To use it, add `rails` to the plugins array in your zshrc file:
 
@@ -67,7 +68,9 @@ plugins=(... rails)
 These are global aliases. Use in combination with a command or just run them
 separately. For example: `REP rake db:migrate` will migrate the production db.
 
-### Legacy rake aliases
+## Legacy
+
+### Rake aliases
 
 The following commands are run [using `rails` instead of `rake` since Rails v5][1], but are preserved under the
 prefix `rk` for backwards compatibility.
@@ -93,7 +96,7 @@ prefix `rk` for backwards compatibility.
 | `rksts`  | `rake stats`                    | Print code statistics                                  |
 | `rkt`    | `rake test`                     | Run Rails tests                                        |
 
-### Legacy stuff
+### Other
 
 | Alias   | Command                            |
 | ------- | ---------------------------------- |
@@ -105,3 +108,5 @@ prefix `rk` for backwards compatibility.
 | `sr`    | `ruby script/runner`               |
 | `ssp`   | `ruby script/spec`                 |
 | `sstat` | `thin --stats "/thin/stats" start` |
+
+- `remote_console <server> <directory>`: runs `ruby script/console production` on a remote server.

+ 8 - 4
plugins/rails/rails.plugin.zsh

@@ -1,3 +1,4 @@
+# rails command wrapper
 function _rails_command () {
   if [ -e "bin/stubs/rails" ]; then
     bin/stubs/rails $@
@@ -12,28 +13,31 @@ function _rails_command () {
   fi
 }
 
+alias rails='_rails_command'
+compdef _rails_command=rails
+
+# rake command wrapper
 function _rake_command () {
   if [ -e "bin/stubs/rake" ]; then
     bin/stubs/rake $@
   elif [ -e "bin/rake" ]; then
     bin/rake $@
-  elif type bundle &> /dev/null && ([ -e "Gemfile" ] || [ -e "gems.rb" ]); then
+  elif type bundle &> /dev/null && [[ -e "Gemfile" || -e "gems.rb" ]]; then
     bundle exec rake $@
   else
     command rake $@
   fi
 }
 
-alias rails='_rails_command'
-compdef _rails_command=rails
-
 alias rake='_rake_command'
 compdef _rake_command=rake
 
+# Log aliases
 alias devlog='tail -f log/development.log'
 alias prodlog='tail -f log/production.log'
 alias testlog='tail -f log/test.log'
 
+# Environment settings
 alias -g RED='RAILS_ENV=development'
 alias -g REP='RAILS_ENV=production'
 alias -g RET='RAILS_ENV=test'