こんにちは、tahara です。
アクトインディ Advent Calendar 2015 の4日目の記事です。
ふだんいこーよを開発しているとき bundle exec guard ってやってます。 むかしは script/autospec でしたよね。
その当時は autotest-stumpwm でした。
このたび Gurad に対応した guard-notifier-stumpwm をリリースしましたー
Gemfile に gem 'guard-notifier-stumpwm' を書いて bundle します。
Guardfile に require 'guard/notifier/stumpwm' を書いて Gurad を実行します。
これでテストが実行されるたびに結果を表示してれます。
コードはこれだけです。
require 'guard/notifier' module Guard module Notifier class Stumpwm < Base VERSION = '0.0.2' def self.available?(opts={}) !!`stumpish version` end def notify(message, opts={}) super color = case opts[:type] when :success 2 # green when :failed 1 # red else 3 end # yellow form = <<EOT (let ((*executing-stumpwm-command* nil)) (message "^#{color}#{opts[:title]}~%~%#{message}")) EOT `stumpish eval '#{form}'` end end end end Guard::Notifier::NOTIFIERS << { stumpwm: ::Guard::Notifier::Stumpwm }
いちおう self.available?
で stumpish コマンドが動くか確認。
notify
で stumpish を使ってメセッージを表示するだけ。
たった2行ですがコードの中に S 式あると落ち着きますね。