Last active
December 15, 2015 11:29
-
-
Save holysugar/5253450 to your computer and use it in GitHub Desktop.
適当に1ファイルスクリプトを listen で autotest するためのスクリプト(終わると適当に blink1 が光る). ここでは spec はスクリプト内に if defined?(RSpec) の if 節の中に書いてある.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env ruby | |
| require 'listen' | |
| require 'blink1' | |
| class Blink1Signal | |
| def initialize | |
| @blink1 = Blink1.new | |
| end | |
| def succeeded | |
| @blink1.open | |
| @blink1.blink(0, 255, 255, 2) | |
| @blink1.close | |
| end | |
| def failed | |
| @blink1.open | |
| @blink1.blink(255, 0, 0, 5) | |
| @blink1.close | |
| end | |
| end | |
| class RspecAllListener | |
| def initialize | |
| @b1 = Blink1Signal.new | |
| end | |
| def callback(modified, added, removed) | |
| paths = (modified + added).join(" ") | |
| result = system "rspec #{paths}" | |
| result ? @b1.succeeded : @b1.failed | |
| end | |
| end | |
| listener = Listen.to(File.dirname(__FILE__), :filter => /\.rb\z/, :ignore => /\Aautotest.rb\z/) | |
| listener.change(&RspecAllListener.new.method(:callback)) | |
| listener.start |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment