Code Monkey home page Code Monkey logo

swapi's Introduction

SWAPI

Build Status

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.

Guidelines

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

Prerequsites

You should have the following installed in your system in order to run this application

Dependencies

Jiffy 1.0.1 is used as json parser.

How to build

  • 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

Unit tests

To run unit tests:

swapi $> rebar3 eunit
swapi $> ...
swapi $> Finished in 4.677 seconds
swapi $> 3 tests, 0 failures

Usage

  • 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

Validations

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"  

TODO

  • 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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.