[from now] 2013/10/28 18:01:07

diff --git a/travis.sh b/travis.sh
index 296cf78..1f32053 100755
--- a/travis.sh
+++ b/travis.sh
@@ -1 +1,56 @@
-java -version
+#!/bin/bash
+
+# TODO 関数の切り分けがちゃんとできていない(依存が関数内に閉じていない)
+# TODO 関数ごとの引数チェック
+
+VERTX_VERSION=2.0.2-final
+VERTX_NAME="vert.x-$VERTX_VERSION"
+
+throw_error() {
+  msg=$1
+  echo "[ERROR] $msg" 1>&2
+  exit 0
+}
+
+setup_directory() {
+  dir=$1
+  if [[ ! -e $dir ]]; then
+    echo "mkdir $dir"
+    mkdir -p $dir
+  elif [[ ! -d $dir ]]; then
+    throw_error "$dir already exists but is not a directory"
+  fi
+}
+
+decompression() {
+  compression_file=$1
+  if [[ ! -e $compression_file ]]; then
+    throw_error "file not found $compression_file"
+  fi
+  # TODO 親ディレクトリ？
+  tar xvzf $compression_file -C travis/vertx
+}
+
+download_vertx() {
+  download_dir=$1
+  # TODO ディレクトリチェック
+  if [[ ! -e $download_dir ]]; then
+    throw_error "$download_dir is not found"
+  fi
+  wget http://dl.bintray.com/vertx/downloads/$VERTX_NAME.tar.gz -P $download_dir
+}
+
+run_spec() {
+  ./travis/vertx/$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"
+  run_spec
+}
+
+main