Putting It All Together

Put all the modules of the previous lessons together to have a complete runnable and testable application.

We'll cover the following

The main function

It’s now time to take these well-tested bits and integrate them. Fortunately for us, we care about unit tests, so we can just throw everything together quickly and consider our job done. Let’s take a look at the main functions and see how that could be done.

The email client is not implemented since it is also out of our scope for now. We’ll stick with a simple io:format/2 call to stand in for the actual email client handling. We just need to package the program to be run.

Code

The main function is defined in the src/bday.erl file in the following code. Take a look at it there.

To package the program we run the command rebar3 escriptize.

The script is generated in the _build/default/bin directory. The program can now be run, as long as the sample CSV file has full CRLF line terminations.

Remember: Ensure one of the employees in the sample database in priv/db.csv has their birthday today (whatever day it is when you are reading this) for the program to output anything. To run the packaged program, run the command: _build/default/bin/bday priv/db.csv.
The format of the date is YYYY/MM/DD.

Get hands-on with 1400+ tech skills courses.