LoginSignup
44
43

More than 5 years have passed since last update.

watson-ruby をプロジェクトに導入して、みんなが積極的に TODO を消化するようにする!!

Last updated at Posted at 2013-11-29

参画しているプロジェクトで TODO が消化されないという問題があり、それを解決する為に watson-ruby という Inline Issue Manager を教えてもらい、プロジェクトに導入しようということになりました。

watson-ruby とは

GitHub/Bitbucket の Issue Tracking System に プロジェクトの対象となるファイルにインラインで書いた Issue を同期させる Tool です。

実行した環境

% ruby -v
ruby 2.0.0p247 (2013-06-27 revision 41674) [x86_64-darwin12.4.0]

インストール

watson は gem で簡単にインストールすることができます。

% gem install watson-ruby

または Gemfile に以下のように記述しても問題はありません。

gem 'watson-ruby

実行したら watson がインストールができたことを確認します。

% watson -v
watson v1.2.0
Copyright (c) 2012-2013 goosecode labs
Licensed under MIT, see LICENSE for details

Written by nhmood, see <http://goosecode.com/projects/watson>

実行してみる

インストールが完了したら、対象となるプロジェクトのルートへ移動してコマンドを実行してみましょう。

% cd path/to/root
% watson

これでプロジェクトのルートディレクトリに .watsonrc というファイルが作成されていることが確認できるはずです。

% ls .watsonrc
.watsonrc

この .watsonrc に watson を利用する為のルールが色々と書かれているので、このファイルを編集していくことになります。
現在のプロジェクトでは以下のようにしてみました。

# watson rc
# watson - inline issue manager
# [goosecode] labs


# Directories 
# watson の管理対象とするディレクトリ
[dirs]
./lib
./app/controllers
./app/models
./app/views
./app/workers
./spec/controllers
./spec/models
./spec/requests

# Tags
# 対象とするタグ
[tags]
FIXME
TODO
XXXX

# Ignores
# watson の管理対象としないファイル
[ignore]
.git
*.swp
*.png
*.log
*.pdf
*.xlsx
*.txt
*.html
*.haml
*.csv
*.xls

今回はサンプルとして、以下のファイルを使います。

# watson rc
# watson - inline issue manager
# [goosecode] labs


# Directories
[dirs]
./


# Tags
[tags]
FIXME
TODO
XXXX

# Ignores
[ignore]
.git
*.swp

それでは、以下のファイルを watson の管理対象に含めて watson を実行してみましょう。

class WatsonSample
  # [TODO] - method 名を変更
  def self.helloworld
    puts 'hello world'
  end
end

# [FIXME] - メッセージを変更
puts "Hello watson"

# [XXXX] - 困っている
if true
  puts "true"
else
  puts "false"
end

WatsonSample.helloworld

すると、対象としたタグを含む一行が出力されます。

% watson
------------------------------
watson - inline issue manager

Run in: path/to/root
Run @ Fri Nov 29 17:15:10 2013
------------------------------

[ o ] sample.rb

[ x ] watson_sample.rb
[ FIXME ]
  line 8 - メッセージを変更

[ TODO ]
  line 2 - method 名を変更

[ XXXX ]
  line 11 - 困っている

github との連携

github と連携するには

% watson -r github

とコマンドを実行すると、色々と聞かれるので対話的に回答しましょう。

------------------------------
watson - inline issue manager
------------------------------

Existing Remotes:
[ ! ] No remotes currently exist

[ + ] Obtaining OAuth Token for GitHub...


[ ! ] Access to your GitHub account required to make/update issues
      See help or README for more details on GitHub/Bitbucket access

[ ! ] Is this a GitHub Enterprise account?
      (Y)es/(N)o: N

Username: iori-o
Password:

[ o ] Obtained OAuth Token

[ ! ] Repo information required
      Please provide owner that repo is under followed by repo name
      e.g. owner: nhmood, repo: watson (case sensitive)
      See help or README for more details on GitHub access

Owner: iori-o
Repo: watson_sample

[ o ] Repo successfully accessed

[ + ] Creating label for watson on GitHub...
[ + ] Label successfully created

[ o ] GitHub successfully setup
      Issues will now automatically be retrieved from GitHub by default
      Use -u, --update to post issues to GitHub
      See help or README for more details on GitHub/Bitbucket access

すると、先ほど作成された .watsonrc に repositry や API キー などが追記されます。

github とイシューを連携したい時は

% watson -u

を実行します。

github の Issue ページ

すると、 github の Issue のページに対象としたタグのイシューが登録されていることを確認できると思います。

44
43
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
44
43