File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,7 @@ compatible with any image.
4646* [ ` asdf ` ] ( features/src/asdf ) : the tool version manager
4747 * [ ` asdf-plugin-nodejs ` ] ( features/src/asdf-plugin-nodejs ) : plugin to support
4848 Node.js
49+ * [ ` asdf-plugin-ruby ` ] ( features/src/asdf-plugin-ruby ) : plugin to support Ruby
4950
5051## Building, Testing and Publishing
5152
Original file line number Diff line number Diff line change 1+ {
2+ "id" : " asdf-plugin-ruby" ,
3+ "version" : " 1.0.0" ,
4+ "name" : " Ruby plugin for asdf" ,
5+ "documentationURL" : " https://github.com/thoughtbot/devcontainers/tree/main/features/src/asdf-plugin-ruby" ,
6+ "description" : " Installs the Ruby plugin for the asdf version manager" ,
7+ "options" : {
8+ "versions" : {
9+ "type" : " string" ,
10+ "default" : " " ,
11+ "description" : " Ruby version to install (comma seperated list)"
12+ }
13+ },
14+ "dependsOn" : {
15+ "ghcr.io/thoughtbot/devcontainers/features/asdf:1" : {}
16+ }
17+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -eu
4+
5+ VERSIONS=" ${VERSIONS:- } "
6+ USERNAME=" ${USERNAME:- " ${_REMOTE_USER:- " automatic" } " } "
7+
8+ case " $USERNAME " in
9+ auto* )
10+ USERNAME=
11+ uid_1000=" $( awk -v val=1000 -F " :" ' $3==val{print $1}' /etc/passwd) "
12+ possible_users=" vscode node codespace $uid_1000 "
13+
14+ while read -r user; do
15+ if id -u " $user " > /dev/null 2>&1 ; then
16+ USERNAME=" $user "
17+ break
18+ fi
19+ done << -EOT
20+ $( echo " $possible_users " | tr ' ' ' \n' )
21+ EOT
22+
23+ if [ " $USERNAME " = " " ]; then
24+ USERNAME=root
25+ fi
26+ ;;
27+ " none" )
28+ USERNAME=" root"
29+ ;;
30+ esac
31+
32+ run_as () {
33+ runuser -u " $USERNAME " -- " $@ "
34+ }
35+
36+ apt-get -q update
37+ apt-get -qy install build-essential autoconf libssl-dev libyaml-dev \
38+ zlib1g-dev libffi-dev libgmp-dev rustc
39+
40+ if ! run_as asdf plugin list 2>&1 | grep ruby > /dev/null; then
41+ run_as asdf plugin add ruby https://github.com/asdf-vm/asdf-ruby.git
42+ fi
43+
44+ echo " $VERSIONS " | tr ' ,' ' \n' | while read -r version; do
45+ if [ " $version " = " " ]; then
46+ continue
47+ fi
48+
49+ run_as asdf install ruby " $version "
50+ done
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -eu
4+
5+ cwd=$( readlink -f " ${0%/* } " )
6+
7+ . " $cwd /test-utils.sh"
8+
9+ echo " Checking Ruby 3.3.6 is installed..."
10+ assert_command " asdf list ruby 2>&1 | grep 3.3.6"
11+
12+ echo " Checking Ruby 4.0.7 is installed..."
13+ assert_command " asdf list ruby 2>&1 | grep 4.0.7"
Original file line number Diff line number Diff line change 1+ {
2+ "multiple-versions" : {
3+ "image" : " ghcr.io/thoughtbot/devcontainers/images/debian" ,
4+ "features" : {
5+ "asdf-plugin-ruby" : {
6+ "versions" : " 3.3.6,4.0.7"
7+ }
8+ }
9+ }
10+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ VERBOSE=" ${VERBOSE:- 0} "
4+ LAST_COMMAND_OUTPUT=
5+
6+ # assert_command command [expected status code]
7+ #
8+ # Run a command and assert it's exit code is 0 or one given
9+ assert_command () {
10+ cmd=" $1 "
11+ expected_return_status=" ${2:- 0} "
12+
13+ LAST_COMMAND_OUTPUT=
14+
15+ # Always capture stdout and stderr, and don't let a failing command
16+ # cause this function to fail
17+ if LAST_COMMAND_OUTPUT=" $( printf ' %s' " $cmd " | sh -a 2>&1 ) " ; then
18+ status=" $? " # ok
19+ else
20+ status=" $? " # also ok
21+ fi
22+
23+ if [ ! " $VERBOSE " -eq 0 ]; then
24+ echo " Command: $cmd "
25+ echo " Command output: $LAST_COMMAND_OUTPUT "
26+ echo " Status code: $status "
27+ fi
28+
29+ if [ " $status " -ne " $expected_return_status " ]; then
30+ echo " $cmd exited with: $status "
31+ exit 1
32+ fi
33+ }
34+
35+ # assert_package package
36+ #
37+ # Query OS packages and assert one is installed
38+ assert_package () {
39+ package=$1
40+
41+ assert_command " dpkg-query --show -f='\$ {Package}: \$ {Version}' $package "
42+ }
Original file line number Diff line number Diff line change 1+ #! /bin/sh
2+
3+ set -eu
4+
5+ cwd=$( readlink -f " ${0%/* } " )
6+
7+ . " $cwd /test-utils.sh"
8+
9+ echo " Checking the Ruby plugin is installed..."
10+ assert_command " asdf plugin list 2>&1 | grep ruby"
11+
12+ echo " Checking expected dependency packages are installed..."
13+ packages=" build-essential autoconf libssl-dev libyaml-dev zlib1g-dev \
14+ libffi-dev libgmp-dev rustc"
15+ echo " $packages " | tr ' ' ' \n' | while read -r package; do
16+ assert_package " $package "
17+ done
You can’t perform that action at this time.
0 commit comments