Skip to content

Commit 1c1ad33

Browse files
committed
Lowercase all non-global variables.
1 parent 6819649 commit 1c1ad33

File tree

9 files changed

+129
-128
lines changed

9 files changed

+129
-128
lines changed

CONTRIBUTING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Tab indent code.
66
* Keep code within 80 columns.
7+
* Global variables must be UPPERCASE. Temporary variables should be lowercase.
78
* Use the `function` keyword for functions.
89
* Quote all String variables.
910
* Use `(( ))` for arithmetic expressions and `[[ ]]` otherwise.

scripts/setup.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,14 @@ cd "$SRC_DIR"
5757
#
5858
# Install ruby-install (https://github.com/postmodern/ruby-install#readme)
5959
#
60-
RUBY_INSTALL_VERSION="0.2.1"
60+
ruby_install_version="0.2.1"
6161

6262
log "Downloading ruby-install ..."
63-
wget -O "ruby-install-$RUBY_INSTALL_VERSION.tar.gz" "https://github.com/postmodern/ruby-install/archive/v$RUBY_INSTALL_VERSION.tar.gz"
63+
wget -O "ruby-install-$ruby_install_version.tar.gz" "https://github.com/postmodern/ruby-install/archive/v$ruby_install_version.tar.gz"
6464

65-
log "Extracting ruby-install $RUBY_INSTALL_VERSION ..."
66-
tar -xzvf "ruby-install-$RUBY_INSTALL_VERSION.tar.gz"
67-
cd "ruby-install-$RUBY_INSTALL_VERSION/"
65+
log "Extracting ruby-install $ruby_install_version ..."
66+
tar -xzvf "ruby-install-$ruby_install_version.tar.gz"
67+
cd "ruby-install-$ruby_install_version/"
6868

6969
log "Installing ruby-install and Rubies ..."
7070
./setup.sh
@@ -74,18 +74,18 @@ log "Installing ruby-install and Rubies ..."
7474
#
7575
log "Configuring chruby ..."
7676

77-
CHRUBY_CONFIG="[ -n \"\$BASH_VERSION\" ] || [ -n \"\$ZSH_VERSION\" ] || return
77+
config="[ -n \"\$BASH_VERSION\" ] || [ -n \"\$ZSH_VERSION\" ] || return
7878
7979
source $PREFIX/share/chruby/chruby.sh"
8080

8181
if [[ -d /etc/profile.d/ ]]; then
8282
# Bash/Zsh
83-
echo "$CHRUBY_CONFIG" > /etc/profile.d/chruby.sh
83+
echo "$config" > /etc/profile.d/chruby.sh
8484
log "Setup complete! Please restart the shell"
8585
else
8686
warning "Could not determine where to add chruby configuration."
8787
warning "Please add the following configuration where appropriate:"
8888
echo
89-
echo "$CHRUBY_CONFIG"
89+
echo "$config"
9090
echo
9191
fi

test/chruby_auto_test.sh

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,32 +50,32 @@ function test_chruby_auto_loaded_twice()
5050

5151
function test_chruby_auto_enter_project_dir()
5252
{
53-
cd "$TEST_PROJECT_DIR" && chruby_auto
53+
cd "$test_project_dir" && chruby_auto
5454

5555
assertEquals "did not switch Ruby when entering a versioned directory" \
56-
"$TEST_RUBY_ROOT" "$RUBY_ROOT"
56+
"$test_ruby_root" "$RUBY_ROOT"
5757
}
5858

5959
function test_chruby_auto_enter_subdir_directly()
6060
{
61-
cd "$TEST_PROJECT_DIR/sub_dir" && chruby_auto
61+
cd "$test_project_dir/sub_dir" && chruby_auto
6262

6363
assertEquals "did not switch Ruby when directly entering a sub-directory of a versioned directory" \
64-
"$TEST_RUBY_ROOT" "$RUBY_ROOT"
64+
"$test_ruby_root" "$RUBY_ROOT"
6565
}
6666

6767
function test_chruby_auto_enter_subdir()
6868
{
69-
cd "$TEST_PROJECT_DIR" && chruby_auto
69+
cd "$test_project_dir" && chruby_auto
7070
cd sub_dir && chruby_auto
7171

7272
assertEquals "did not keep the current Ruby when entering a sub-dir" \
73-
"$TEST_RUBY_ROOT" "$RUBY_ROOT"
73+
"$test_ruby_root" "$RUBY_ROOT"
7474
}
7575

7676
function test_chruby_auto_enter_subdir_with_ruby_version()
7777
{
78-
cd "$TEST_PROJECT_DIR" && chruby_auto
78+
cd "$test_project_dir" && chruby_auto
7979
cd sub_versioned/ && chruby_auto
8080

8181
assertNull "did not switch the Ruby when leaving a sub-versioned directory" \
@@ -84,39 +84,39 @@ function test_chruby_auto_enter_subdir_with_ruby_version()
8484

8585
function test_chruby_auto_modified_ruby_version()
8686
{
87-
cd "$TEST_PROJECT_DIR/modified_version" && chruby_auto
87+
cd "$test_project_dir/modified_version" && chruby_auto
8888
echo "1.9.3" > .ruby-version && chruby_auto
8989

9090
assertEquals "did not detect the modified .ruby-version file" \
91-
"$TEST_RUBY_ROOT" "$RUBY_ROOT"
91+
"$test_ruby_root" "$RUBY_ROOT"
9292
}
9393

9494
function test_chruby_auto_overriding_ruby_version()
9595
{
96-
cd "$TEST_PROJECT_DIR" && chruby_auto
96+
cd "$test_project_dir" && chruby_auto
9797
chruby system && chruby_auto
9898

9999
assertNull "did not override the Ruby set in .ruby-version" "$RUBY_ROOT"
100100
}
101101

102102
function test_chruby_auto_leave_project_dir()
103103
{
104-
cd "$TEST_PROJECT_DIR" && chruby_auto
105-
cd "$TEST_PROJECT_DIR/.." && chruby_auto
104+
cd "$test_project_dir" && chruby_auto
105+
cd "$test_project_dir/.." && chruby_auto
106106

107107
assertNull "did not reset the Ruby when leaving a versioned directory" \
108108
"$RUBY_ROOT"
109109
}
110110

111111
function test_chruby_auto_invalid_ruby_version()
112112
{
113-
local expected_auto_version="$(cat $TEST_PROJECT_DIR/bad/.ruby-version)"
113+
local expected_auto_version="$(cat $test_project_dir/bad/.ruby-version)"
114114

115-
cd "$TEST_PROJECT_DIR" && chruby_auto
115+
cd "$test_project_dir" && chruby_auto
116116
cd bad/ && chruby_auto 2>/dev/null
117117

118118
assertEquals "did not keep the current Ruby when loading an unknown version" \
119-
"$TEST_RUBY_ROOT" "$RUBY_ROOT"
119+
"$test_ruby_root" "$RUBY_ROOT"
120120
assertEquals "did not set RUBY_AUTO_VERSION" \
121121
"$expected_auto_version" "$RUBY_AUTO_VERSION"
122122
}

test/chruby_exec_test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ function test_chruby_exec_no_arguments()
99

1010
function test_chruby_exec_no_command()
1111
{
12-
chruby-exec "$TEST_RUBY_VERSION" 2>/dev/null
12+
chruby-exec "$test_ruby_version" 2>/dev/null
1313

1414
assertEquals "did not exit with 1" 1 $?
1515
}
1616

1717
function test_chruby_exec()
1818
{
1919
local command="ruby -e 'print RUBY_VERSION'"
20-
local ruby_version=$(chruby-exec "$TEST_RUBY_VERSION" -- $command)
20+
local ruby_version=$(chruby-exec "$test_ruby_version" -- $command)
2121

22-
assertEquals "did change the ruby" "$TEST_RUBY_VERSION" "$ruby_version"
22+
assertEquals "did change the ruby" "$test_ruby_version" "$ruby_version"
2323
}
2424

2525
SHUNIT_PARENT=$0 . $SHUNIT2

test/chruby_reset_test.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
function setUp()
44
{
5-
chruby_use "$TEST_RUBY_ROOT" >/dev/null
5+
chruby_use "$test_ruby_root" >/dev/null
66

7-
export PATH="$GEM_HOME/bin:$GEM_ROOT/bin:$RUBY_ROOT/bin:$TEST_PATH"
7+
export PATH="$GEM_HOME/bin:$GEM_ROOT/bin:$RUBY_ROOT/bin:$test_path"
88
}
99

1010
function test_chruby_reset()
@@ -18,7 +18,7 @@ function test_chruby_reset()
1818
assertNull "GEM_HOME was not unset" "$GEM_HOME"
1919
assertNull "GEM_PATH was not unset" "$GEM_PATH"
2020

21-
assertEquals "PATH was not sanitized" "$TEST_PATH" "$PATH"
21+
assertEquals "PATH was not sanitized" "$test_path" "$PATH"
2222
}
2323

2424
function test_chruby_reset_duplicate_path()
@@ -27,7 +27,7 @@ function test_chruby_reset_duplicate_path()
2727

2828
chruby_reset
2929

30-
assertEquals "PATH was not sanitized" "$TEST_PATH" "$PATH"
30+
assertEquals "PATH was not sanitized" "$test_path" "$PATH"
3131
}
3232

3333
function test_chruby_reset_modified_gem_path()
@@ -45,11 +45,11 @@ function test_chruby_reset_no_gem_root_or_gem_home()
4545
{
4646
export GEM_HOME=""
4747
export GEM_ROOT=""
48-
export PATH="$TEST_PATH:/bin"
48+
export PATH="$test_path:/bin"
4949

5050
chruby_reset
5151

52-
assertEquals "PATH was messed up" "$TEST_PATH:/bin" "$PATH"
52+
assertEquals "PATH was messed up" "$test_path:/bin" "$PATH"
5353
}
5454

5555
SHUNIT_PARENT=$0 . $SHUNIT2

test/chruby_test.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@ function test_chruby_1_9()
99
{
1010
chruby "1.9" >/dev/null
1111

12-
assertEquals "did not match 1.9" "$TEST_RUBY_ROOT" "$RUBY_ROOT"
12+
assertEquals "did not match 1.9" "$test_ruby_root" "$RUBY_ROOT"
1313
}
1414

1515
function test_chruby_multiple_matches()
1616
{
17-
RUBIES=(/path/to/ruby-1.9.0 "$TEST_RUBY_ROOT")
17+
RUBIES=(/path/to/ruby-1.9.0 "$test_ruby_root")
1818

1919
chruby "1.9" >/dev/null
2020

21-
assertEquals "did not use the last match" "$TEST_RUBY_ROOT" "$RUBY_ROOT"
21+
assertEquals "did not use the last match" "$test_ruby_root" "$RUBY_ROOT"
2222
}
2323

2424
function test_chruby_system()
2525
{
26-
chruby "$TEST_RUBY_VERSION" >/dev/null
26+
chruby "$test_ruby_version" >/dev/null
2727
chruby system
2828

2929
assertNull "did not reset the Ruby" "$RUBY_ROOT"

test/chruby_use_test.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,21 @@
22

33
function setUp()
44
{
5-
chruby_use $TEST_RUBY_ROOT >/dev/null
5+
chruby_use $test_ruby_root >/dev/null
66
}
77

88
function test_chruby_use()
99
{
10-
assertEquals "invalid RUBY_ROOT" "$TEST_RUBY_ROOT" "$RUBY_ROOT"
11-
assertEquals "invalid RUBY_ENGINE" "$TEST_RUBY_ENGINE" "$RUBY_ENGINE"
12-
assertEquals "invalid RUBY_VERSION" "$TEST_RUBY_VERSION" "$RUBY_VERSION"
13-
assertEquals "invalid GEM_ROOT" "$TEST_RUBY_ROOT/lib/ruby/gems/$TEST_RUBY_API" "$GEM_ROOT"
14-
assertEquals "invalid GEM_HOME" "$TEST_GEM_HOME" "$GEM_HOME"
10+
assertEquals "invalid RUBY_ROOT" "$test_ruby_root" "$RUBY_ROOT"
11+
assertEquals "invalid RUBY_ENGINE" "$test_ruby_engine" "$RUBY_ENGINE"
12+
assertEquals "invalid RUBY_VERSION" "$test_ruby_version" "$RUBY_VERSION"
13+
assertEquals "invalid GEM_ROOT" "$test_ruby_root/lib/ruby/gems/$test_ruby_api" "$GEM_ROOT"
14+
assertEquals "invalid GEM_HOME" "$test_gem_home" "$GEM_HOME"
1515
assertEquals "invalid GEM_PATH" "$GEM_HOME:$GEM_ROOT" "$GEM_PATH"
16-
assertEquals "invalid PATH" "$TEST_GEM_HOME/bin:$TEST_GEM_ROOT/bin:$TEST_RUBY_ROOT/bin:$__shunit_tmpDir:$TEST_PATH" "$PATH"
16+
assertEquals "invalid PATH" "$test_gem_home/bin:$test_gem_root/bin:$test_ruby_root/bin:$__shunit_tmpDir:$test_path" "$PATH"
1717

1818
assertEquals "could not find ruby in $PATH" \
19-
"$TEST_RUBY_ROOT/bin/ruby" \
19+
"$test_ruby_root/bin/ruby" \
2020
"$(command -v ruby)"
2121
}
2222

test/helper.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,19 @@ export HOME="$PWD/test/home"
77
. ./share/chruby/chruby.sh
88
chruby_reset
99

10-
TEST_RUBY_ENGINE="ruby"
11-
TEST_RUBY_VERSION="1.9.3"
12-
TEST_RUBY_PATCHLEVEL="429"
13-
TEST_RUBY_API="1.9.1"
14-
TEST_RUBY_ROOT="$PWD/test/rubies/$TEST_RUBY_ENGINE-$TEST_RUBY_VERSION-p$TEST_RUBY_PATCHLEVEL"
10+
test_ruby_engine="ruby"
11+
test_ruby_version="1.9.3"
12+
test_ruby_patchlevel="429"
13+
test_ruby_api="1.9.1"
14+
test_ruby_root="$PWD/test/rubies/$test_ruby_engine-$test_ruby_version-p$test_ruby_patchlevel"
1515

16-
TEST_PATH="$PATH"
17-
TEST_GEM_HOME="$HOME/.gem/$TEST_RUBY_ENGINE/$TEST_RUBY_VERSION"
18-
TEST_GEM_ROOT="$TEST_RUBY_ROOT/lib/ruby/gems/$TEST_RUBY_API"
16+
test_path="$PATH"
17+
test_gem_home="$HOME/.gem/$test_ruby_engine/$test_ruby_version"
18+
test_gem_root="$test_ruby_root/lib/ruby/gems/$test_ruby_api"
1919

20-
TEST_PROJECT_DIR="$PWD/test/project"
20+
test_project_dir="$PWD/test/project"
2121

22-
RUBIES=($TEST_RUBY_ROOT)
22+
RUBIES=($test_ruby_root)
2323

2424
setUp() { return; }
2525
tearDown() { return; }

0 commit comments

Comments
 (0)