|
|
@ -7,56 +7,30 @@ |
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com> |
|
|
|
# Sorin Ionescu <sorin.ionescu@gmail.com> |
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# Load dependencies. |
|
|
|
|
|
|
|
pmodload 'ruby' |
|
|
|
|
|
|
|
|
|
|
|
# Return if requirements are not found. |
|
|
|
# Return if requirements are not found. |
|
|
|
if (( ! $+commands[rails] )); then |
|
|
|
if (( ! $+commands[bundle] )); then |
|
|
|
return 1 |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
# |
|
|
|
# |
|
|
|
# Aliases (Compatible with Rails 2) |
|
|
|
# Aliases |
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
alias ror='rails' |
|
|
|
|
|
|
|
alias rorc='_rails-command console' |
|
|
|
|
|
|
|
alias rordc='_rails-command dbconsole' |
|
|
|
|
|
|
|
alias rordm='rake db:migrate' |
|
|
|
|
|
|
|
alias rordM='rake db:migrate db:test:clone' |
|
|
|
|
|
|
|
alias rordr='rake db:rollback' |
|
|
|
|
|
|
|
alias rorg='_rails-command generate' |
|
|
|
|
|
|
|
alias rorl='tail -f log/development.log' |
|
|
|
|
|
|
|
alias rorlc='rake log:clear' |
|
|
|
|
|
|
|
alias rorp='_rails-command plugin' |
|
|
|
|
|
|
|
alias rorr='_rails-command runner' |
|
|
|
|
|
|
|
alias rors='_rails-command server' |
|
|
|
|
|
|
|
alias rorsd='_rails-command server --debugger' |
|
|
|
|
|
|
|
alias rorx='_rails-command destroy' |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# |
|
|
|
|
|
|
|
# Functions |
|
|
|
|
|
|
|
# |
|
|
|
# |
|
|
|
|
|
|
|
|
|
|
|
function _rails-command { |
|
|
|
alias ror='bundle exec rails' |
|
|
|
local root_dir="$PWD" |
|
|
|
alias rorc='bundle exec rails console' |
|
|
|
local rails_cmd |
|
|
|
alias rordc='bundle exec rails dbconsole' |
|
|
|
|
|
|
|
alias rordm='bundle exec rake db:migrate' |
|
|
|
while [[ "$root_dir" != '/' ]]; do |
|
|
|
alias rordM='bundle exec rake db:migrate db:test:clone' |
|
|
|
if [[ -d "$root_dir/.bundle" ]]; then |
|
|
|
alias rordr='bundle exec rake db:rollback' |
|
|
|
break |
|
|
|
alias rorg='bundle exec rails generate' |
|
|
|
fi |
|
|
|
alias rorl='tail -f "$(ruby-app-root)/log/development.log"' |
|
|
|
root_dir="$root_dir:h" |
|
|
|
alias rorlc='bundle exec rake log:clear' |
|
|
|
done |
|
|
|
alias rorp='bundle exec rails plugin' |
|
|
|
|
|
|
|
alias rorr='bundle exec rails runner' |
|
|
|
if [[ -e "$root_dir/bin/rails" ]]; then |
|
|
|
alias rors='bundle exec rails server' |
|
|
|
rails_cmd='bin/rails' |
|
|
|
alias rorsd='bundle exec rails server --debugger' |
|
|
|
elif [[ -e "$root_dir/script/rails" ]]; then |
|
|
|
alias rorx='bundle exec rails destroy' |
|
|
|
rails_cmd='script/rails' |
|
|
|
|
|
|
|
elif [[ -e "$root_dir/script/server" ]]; then |
|
|
|
|
|
|
|
rails_cmd='script/' |
|
|
|
|
|
|
|
else |
|
|
|
|
|
|
|
print "$0: not inside of a Rails application: $PWD" >&2 |
|
|
|
|
|
|
|
return 1 |
|
|
|
|
|
|
|
fi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
(cd "$root_dir" && ruby "$rails_cmd" "$@") |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|