tshm
1/31/2014 - 8:22 AM

build.thor

class Thor
        module BuildActions
                include Thor::Actions
                @@CC = ''
                @@CC_PRM = ''
                @@THOR_LOC = ''

                def run_watchr(file_pattern)
                        require 'watchr'
                        script = Watchr::Script.new
                        script.watch(file_pattern) {|f| yield(f)}
                        Watchr::Controller.new(script, Watchr.handler.new).run
                end

                def in_src_root
                        inside(@@THOR_LOC) { yield }
                end

                def build_proj(prj)
                        say "build and run", :green
                        retval = run %(#{@@CC} #{prj} #{@@CC_PRM})
                        if retval
                                say "================ passed ================", :green
                        else
                                say "================ failure ================", :red
                        end
                end
        end
end

# vim: ft=ruby