[from now] 2013/10/28 18:14:17

diff --git a/travis.sh b/travis.sh
index 1f32053..2e7eb66 100755
--- a/travis.sh
+++ b/travis.sh
@@ -1,8 +1,7 @@
 #!/bin/bash

-# TODO 関数の切り分けがちゃんとできていない(依存が関数内に閉じていない)
-# TODO 関数ごとの引数チェック
-
+ROOT_DIR=`pwd`
+VERTX_DIR="$ROOT_DIR/travis/vertx"
 VERTX_VERSION=2.0.2-final
 VERTX_NAME="vert.x-$VERTX_VERSION"

@@ -22,34 +21,28 @@ setup_directory() {
   fi
 }

-decompression() {
-  compression_file=$1
-  if [[ ! -e $compression_file ]]; then
-    throw_error "file not found $compression_file"
+install_vertx() {
+  if [[ ! -e $VERTX_DIR ]]; then
+    throw_error "$VERTX_DIR is not found"
+  elif [[ ! -d $VERTX_DIR ]]; then
+    throw_error "$VERTX_DIR already exists but is not a directory"
   fi
-  # TODO 親ディレクトリ？
-  tar xvzf $compression_file -C travis/vertx
-}
+  wget http://dl.bintray.com/vertx/downloads/$VERTX_NAME.tar.gz -P $VERTX_DIR

-download_vertx() {
-  download_dir=$1
-  # TODO ディレクトリチェック
-  if [[ ! -e $download_dir ]]; then
-    throw_error "$download_dir is not found"
+  compression_file=$VERTX_DIR/$VERTX_NAME.tar.gz
+  if [[ ! -e $compression_file ]]; then
+    throw_error "file not found $compression_file"
   fi
-  wget http://dl.bintray.com/vertx/downloads/$VERTX_NAME.tar.gz -P $download_dir
+  tar xvzf $compression_file -C $VERTX_DIR
 }

 run_spec() {
-  ./travis/vertx/$VERTX_NAME/bin/vertx run spec/spec_runner.js
+  $VERTX_DIR/$VERTX_NAME/bin/vertx run spec/spec_runner.js
 }

 main() {
-  root_dir=`pwd`
-  vertx_dir="$root_dir/travis/vertx"
-  setup_directory $vertx_dir
-  download_vertx $vertx_dir
-  decompression "$vertx_dir/$VERTX_NAME.tar.gz"
+  setup_directory $VERTX_DIR
+  install_vertx
   run_spec
 }