Two packages are provided, the first one is game
, which provides domain entities and abstract classes,
and the second one is parser
which is the concrete implementation of the game's log parser.
The parser.LogParser
is responsible for reading the log file and to interpret the type of event
by applying a regex expression to each line in the log file.
When an event type is matched then the log parser will notify all event handlers registered to the games.events.EventObservable
(which is a very simple implementation of the Observer Pattern) instance, which are
instested in that event type notified. We have event handlers like:
parser.handlers.InitGameEventHandler
: responsible for handlingInitGame
events;parser.handlers.ShutdownGameEventHandler
: responsible for handlingShutdownGame
events, and;parser.handlers.KillEventHandler
: responsible for handlingKill
events.
For providing persistency for entities it's been choosen the Repository
Pattern.
We have a concrete implementation of game.games.GameRepository
in parser.repositories.MemoryGameRepository
whose role is to persist information in memory by making use of a dictionary.
- Python 3.7.1.
- An activated python virtualenv.
Clone the repository and install it:
git clone https://github.com/michaeltcoelho/game-log-parser.git
Go to /game-log-parser
directory:
Run the following command for installing dependencies:
make install
Running tests:
make test
Running server:
make server
Get all games
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:5000/games
Get game by uid
curl -X GET -H "Content-Type: application/json" http://127.0.0.1:5000/games/<replace by a game's uid>
Access http://127.0.0.1:5000/
on your favorite browser.