This ruby app is implemented to parse the log and summarize the visits as per the requirement stated, total or all visits and unique visits for a url.
The app structure is simple with only two classes,
-
Parser
- Responsible to parse and generate a hash out of the log file, with the url and respective visitor information which includes IP list total visit count and unique count
- Input : file_path
- Output: log entries hash
-
LogAnalyzer
- Responsible to process the log entries generated by the parser, i.e sorting and printing the results
- Input : file_path
- Output: prints and returns the processed log visits
The specs are implemented using RSpec Run:
bundle exec rspec
Code Coverage
- As per the report genrated,
Coverage report generated for RSpec to /sp-log-parser/coverage. 97 / 97 LOC (100.0%) covered.
Step 1:
cd sp-log-parser
Step 2:
bundle install
Step 3:
ruby bin/parser.rb webserver.log