The Log Parser takes a log file as input and returns a list of webpages, ordered by visits and by unique views.
Clone the repository and run the following command to install all the dependencies:
$ bundle install
You may need to change the permissions on parser.rb
as follows:
chmod +x parser.rb
To run RSpec (with coverage) followed by Rubocop run script:
$ ./scripts/tdd.test
As the exact output of the supplied webserver.log
file is not known, the feature test runs using a smaller known set of data provided in ./data/feature_test.log
.
(All input data is stored in the ./data
directory.)
The feature test can be run using:
rspec spec/features/parser_spec.rb
Based on the test data:
/about 061.945.150.735
/about/2 184.123.665.067
/about/2 184.123.665.067
/about/2 444.701.448.104
/about/2 444.701.448.104
/about/2 444.701.448.104
/contact 184.123.665.067
/contact 316.433.849.805
/contact 444.701.448.104
/contact 543.910.244.929
/contact 555.576.836.194
/home 184.123.665.067
/home 184.123.665.067
/home 316.433.849.805
/home 336.284.013.698
/home 336.284.013.698
/home 444.701.448.104
/home 444.701.448.104
/home 543.910.244.929
/home 555.576.836.194
The feature test expects the following output:
./parser.rb ./data/feature_test.log
/home 9 visits
/about/2 5 visits
/contact 5 visits
/about 1 visit
/home 6 unique views
/contact 5 unique views
/about/2 2 unique views
/about 1 unique view
- The script prints visits followed by unique views
- Sub-directories are considered separate entries
- If two entries have the same count, they're listed in alphabetical order
- IP addresses have leading zeros
- Validate log entries are correct
- Provide option to specify path depth to be counted
- Allow for IP addresses without leading zeros
- Allow user to specify visits or unique views
- Allow multiple log files as input