[RUBY] Monitor source code changes with guard-shell and make & execute automatically

Overview

When developing in C language, if you make a Makefile, you want to make it automatically and execute it.

There seem to be various ways to monitor file changes, but if you have a Ruby environment, you can use guard-shell to make it so easy.

I have put a set of sample files in here.

Premise

--It is assumed that the environment where Ruby and Rubygems can be installed and executed is in place. --Please prepare the source code and Makefile for making. If you just want to move it, please download the above sample.

guard-shell environment construction procedure

1. Install gem

$ gem install guard
$ gem install guard-shell

2. Creating a Guardfile

Move to the directory where you want to monitor the file, and then execute the following command to generate a file with a sample named Guardfile.

$ guard init

Edit the Guardfile as follows. Change the part surrounded by `` to your favorite command.

Guardfile


guard :shell do
  watch(/(.*)\.c/) {|m| `make && ./#{File.basename(m[0], ".c")}` }
end

3. Start monitoring

Just hit the following command.

$ guard

When you want to modify the monitoring target or the execution command, you can modify the Guardfile and it will be reloaded automatically, so it is convenient that you do not have to end the guard command in the middle.

reference

-I tried using Guard-Kuroneko Diary

Recommended Posts

Monitor source code changes with guard-shell and make & execute automatically
Microservices with DevOps Make Changes
Writing code with classes and instances
Execute packaged Java code with commands
Monitor Java applications with jolokia and hawtio
Link Java and C ++ code with SWIG
Download JDK with Gradle and make JRE
Execute Java code from cpp with cocos2dx
[Azure] Build automatically with ACR task triggered by base image / source code update