Skip to content

MSaami/log_parser

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

15 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Log Parser Challenge

Ruby Style Guide

About

Project which is analyses webserver's logs to list page's visits in total mode and unique mode.

Ruby Version

3.0.0

Install

  • clone the project
  • If you don't have the compatible version of ruby use the command to install this using rbenv
rbenv install 3.0.0

Note: You can find installed ruby version in your system with the below command:

ruby -v
  • install dependencies using Bundler
bundle install

Usage

Now you can run the project with below command:

./parser.rb log/webserver.log

Note: If you face with an permission denied error you can fix this with the below command:

chmod +x parser.rb

Test

This project written in TDD by rspec gem. The project has unit and integration test. If you want you can run Rspec and generate code coverage with below command:

bundle exec rspec

For the generate test coverate we use SimpleCov gem which reports 193 relevant lines, 192 lines covered and 1 lines missed. ( 99.48% )

image

Architecture

  • The entry point of the project is parser.rb which get a file to parse it.
  • At the first we have a service named ArgsReader which checks the given arguments and returns path as a main file path which must be parsed.
  • Then there is a service named FileLoader which in charge of loads the given file and then will pass the file to FileReader.
  • FileReader reads given file line by line and will extract path and ip from each line.
  • Repository service which in charge of store path and ip. The service implements two methods for return count visits and uniuqe count visits.
  • Our main service is Analyser which depneds on two services FileReader and Repository. The service sends message to FileReader to read given file line by line then will send message to Repository to store given data.
  • Finally as we have to display the result, we have a service named Presenter which will display the output.

image

TODO

  • Better exception handling.
  • To improve performance we can use cache mechanism.
  • Implement a bin file to interactive more efficient and clear with client
  • Better implementation of Presenter service.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages