Project which is analyses webserver's logs to list page's visits in total mode and unique mode.
3.0.0
- 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
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
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% )
- 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 returnspath
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 toFileReader
. FileReader
reads given file line by line and will extractpath
andip
from each line.Repository
service which in charge of storepath
andip
. The service implements two methods for return count visits and uniuqe count visits.- Our main service is
Analyser
which depneds on two servicesFileReader
andRepository
. The service sends message toFileReader
to read given file line by line then will send message toRepository
to store given data. - Finally as we have to display the result, we have a service named
Presenter
which will display the output.
- 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.