1
0
mirror of https://github.com/dcarrillo/prezto.git synced 2024-11-20 08:31:13 +00:00
prezto/modules/ruby/functions/ruby-info

39 lines
897 B
Plaintext
Raw Normal View History

2012-09-07 03:06:50 +00:00
#
2012-09-07 03:17:38 +00:00
# Exposes information about the Ruby environment via the $ruby_info associative
# array.
2012-09-07 03:06:50 +00:00
#
# Authors:
# Sorin Ionescu <sorin.ionescu@gmail.com>
#
# function ruby-info {
2012-09-07 03:06:50 +00:00
local version
local version_format
local version_formatted
# Clean up previous $ruby_info.
unset ruby_info
typeset -gA ruby_info
# Grab formatting for anything we might have to do
zstyle -s ':prezto:module:ruby:info:version' format 'version_format'
if [[ -n "$version_format" ]]; then
if (( $+commands[rvm-prompt] )); then
version="$(rvm-prompt)"
elif (( $+commands[rbenv] )); then
version="$(rbenv version-name)"
elif (( $+commands[ruby] )); then
version="${${$(ruby --version)[(w)1,(w)2]}/ /-}"
fi
2012-09-07 03:06:50 +00:00
# Format version.
if [[ -n "$version" && "$version" != "system" ]]; then
zformat -f version_formatted "$version_format" "v:$version"
ruby_info[version]="$version_formatted"
fi
2012-09-07 03:06:50 +00:00
fi
# }