Simple erlang application, implemented as escript, that given two star wars characters, returns a list of movies both have in common.
Data sources is The Star Wars Api.
This exercise was done trying to follow as much as possible the following guidelines:
- Design and coding standards for LambdaClass
- Inaka's Erlang Coding Guidelines
You should have the following installed in your system in order to run this application
Jiffy 1.0.1 is used as json parser.
- First, clone the repo and compile jiffy
$> git clone https://github.com/guernik/swapi.git
$> rebar3 compile
- Now, compile the source files and give execution permissions to main erl file
swapi $> erlc src/http_reqs.erl src/utils.erl src/sw_data.erl
swapi $> chmod a+x swapi.erl
- The erlang script is now ready to run
To run unit tests:
swapi $> rebar3 eunit
swapi $> ...
swapi $> Finished in 4.677 seconds
swapi $> 3 tests, 0 failures
- Sample usage:
swapi $> ./swapi.erl luke c-3po
swapi $> A New Hope
swapi $> The Empire Strikes Back
swapi $> Return of the Jedi
swapi $> Revenge of the Sith
- If you want to pass a character with whitespaces, use quotes:
swapi $> ./swapi.erl "Luke Sky" "Owen Lars"
swapi $> A New Hope
swapi $> Revenge of the Sith
The program performs the following validations:
- Correct number of parameters
swapi $> ./swapi.erl luke
swapi $> usage: swapi Character AnotherCharacter
swapi $> ie: swapi luke leia
swapi $> swapi "luke sky" leia
- Valid Star Wars Characters
swapi $> ./swapi.erl "Harry Potter" "Spock"
swapi $> No Star Wars character found for "Harry Potter"
swapi $> No Star Wars character found for "Spock"
- Non ambiguous input
swapi $> ./swapi.erl lu da
swapi $> More than one posible character for the input "lu"
swapi $> More than one posible character for the input "da"
- Make http requests async
- Implement meck or a similar mock framework for unit tests
- Implement build process with a Makefile, or change project nature to a rebar3 escript app