Tbpgr Blog

Employee Experience Engineer tbpgr(てぃーびー) のブログ

TTMビルドをRakeで自動化

TTMのビルドの自動化

Rakeを利用してビルドを自動化します。

ビルド内容

自動化といっても現時点ではたいした内容はなく、
テストの実行とRDocの作成ぐらいですね。

ビルドファイルの作成

ファイルの作成

Rakefileがデフォルトのビルドファイル名。
プロジェクトルートにRakefileを作成する。

Ruby1.9を使用している場合、エンコードの指定を行わないと
日本語の扱いでエラーが発生するためマジックコメントに以下を追加します。

# encoding: utf-8
RDOC = "rdoc.bat"

task :default => "deploy"

desc "プロジェクトをデプロイする"
task :deploy => ["unit_test","rdoc"]

desc "RDocの出力"
task "rdoc" do
  sh "#{RDOC}"
end

desc "ユニットテストの実施"
task :unit_test  do
	require "rake/runtest"
	Rake.run_tests './test/test_todo_2_json.rb'
end
ビルド実行

コマンドプロンプトから以下を実行

rake -t
ビルド結果
Run options: 

# Running tests:

.....

Finished tests in 0.001000s, 5000.0000 tests/s, 7000.0000 assertions/s.

5 tests, 7 assertions, 0 failures, 0 errors, 0 skips
RDocが作成されていることを確認
C:.
│  Rakefile
│
├─conf
├─doc
│  │  created.rid
│  │  index.html
│  │  rdoc.css
│  │  TestTodo2Json.html
│  │  Todo2Json.html
│  │
│  ├─images
│  │      (略)
│  │
│  ├─js
│  │      (略)
│  │
│  ├─test
│  │      test_todo_2_json_rb.html
│  │
│  └─ttm
│          todo_2_json_rb.html
│
├─test
│      test_todo_2_json.rb
│
└─ttm
        todo_2_json.rb

RDocハードコピー


rakeオプション

  • t = 実行トレースを有効にする
  • T = タスクの一覧表示