Skip to content

Commit

Permalink
feat(core): implement function for install rvm (#57)
Browse files Browse the repository at this point in the history
  • Loading branch information
luismayta committed Nov 10, 2024
1 parent d97297e commit aac4e4c
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 46 deletions.
4 changes: 2 additions & 2 deletions config/base.zsh
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#!/usr/bin/env ksh
# -*- coding: utf-8 -*-

export RVM_MESSAGE_BREW="Please install brew or use antibody bundle luismayta/zsh-brew branch:develop"
export RVM_MESSAGE_BREW="Please install brew or use antibody bundle hadenlabs/zsh-brew"
export RVM_PACKAGE_NAME=rvm
export RVM_ROOT="${HOME}"/.rvm
export RVM_CACHE_DIR="${HOME}/.cache/rvm"
Expand All @@ -15,4 +15,4 @@ export RVM_PACKAGES=(
terminal-notifier
solargraph
bundler
)
)
93 changes: 49 additions & 44 deletions internal/base.zsh
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,73 @@
# -*- coding: utf-8 -*-

function rvm::internal::rvm::install {
message_info "Installing ${RVM_PACKAGE_NAME}"
rvm::internal::install::gpg
message_info "Installing ${RVM_PACKAGE_NAME}"
rvm::internal::install::gpg

curl -sSL https://get.rvm.io | bash -s stable
rvm get stable
rvm::internal::rvm::load
message_success "Installed ${RVM_PACKAGE_NAME}"
curl -sSL https://get.rvm.io | bash -s stable
rvm get stable
rvm::internal::rvm::load
message_success "Installed ${RVM_PACKAGE_NAME}"
}

function rvm::internal::install::gpg {
if core::exists gpg; then
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
fi
if core::exists gpg; then
gpg --keyserver hkp://keys.gnupg.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3
fi

if core::exists gpg2; then
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
fi
if core::exists gpg2; then
gpg2 --keyserver hkp://pool.sks-keyservers.net --recv-keys 409B6B1796C275462A1703113804BB82D39DC0E3 7D2BAF1CF37B13E2069D6956105BD0E739499BDB
fi

command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
command curl -sSL https://rvm.io/mpapis.asc | gpg --import -
command curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
}

function rvm::internal::rvm::load {
# Add RVM to PATH for scripting
[ -e "${RVM_ROOT}/bin" ] && export PATH="${PATH}:${RVM_ROOT}/bin"
[ -e "/usr/local/rvm/bin" ] && export PATH="${PATH}:/usr/local/rvm/bin"
# Add RVM to PATH for scripting
[ -e "${RVM_ROOT}/bin" ] && export PATH="${PATH}:${RVM_ROOT}/bin"
[[ -s "${RVM_ROOT}/scripts/rvm" ]] && . "${RVM_ROOT}/scripts/rvm"
}

function rvm::internal::packages::install {
if ! core::exists gem; then
message_warning "it's neccesary have gem"
return
fi
if ! core::exists gem; then
message_warning "it's neccesary have gem"
return
fi

message_info "Installing required gem packages"
gem install "${RVM_PACKAGES[@]}"
message_success "Installed required gem packages"
message_info "Installing required gem packages"
gem install "${RVM_PACKAGES[@]}"
message_success "Installed required gem packages"
}

function rvm::internal::version::install {
local version=${1}
rvm install ${version}
}

function rvm::internal::version::all::install {
if ! core::exists rvm; then
message_warning "not found rvm"
return
fi
if ! core::exists rvm; then
message_warning "not found rvm"
return
fi

for version in "${RVM_VERSIONS[@]}"; do
message_info "Install version of rvm ${version}"
rvm install "${version}"
message_success "Installed version of rvm ${version}"
done
rvm use "${RVM_VERSION_GLOBAL}" --default
message_success "Installed versions of rvm"
for version in "${RVM_VERSIONS[@]}"; do
message_info "Install version of rvm ${version}"
rvm::internal::version::install "${version}"
message_success "Installed version of rvm ${version}"
done
rvm use "${RVM_VERSION_GLOBAL}" --default
message_success "Installed versions of rvm"

}

function rvm::internal::version::global::install {
if ! core::exists rvm; then
message_warning "not found rvm"
return
fi
message_info "Installing version global of rvm ${RVM_VERSION_GLOBAL}"
rvm install "${RVM_VERSION_GLOBAL}"
rvm use "${RVM_VERSION_GLOBAL}" --default
message_success "Installed version global of rvm ${RVM_VERSION_GLOBAL}"
}
if ! core::exists rvm; then
message_warning "not found rvm"
return
fi
message_info "Installing version global of rvm ${RVM_VERSION_GLOBAL}"
rvm::internal::version::install "${RVM_VERSION_GLOBAL}"
rvm use "${RVM_VERSION_GLOBAL}" --default
message_success "Installed version global of rvm ${RVM_VERSION_GLOBAL}"
}

0 comments on commit aac4e4c

Please sign in to comment.