Giter VIP home page Giter VIP logo

log-parser's Introduction

Build Status

Log Parser

The Log Parser takes a log file as input and returns a list of webpages, ordered by visits and by unique views.

Setup

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

Testing

To run RSpec (with coverage) followed by Rubocop run script:

$ ./scripts/tdd.test

Feature 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

Assumptions

  • 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

Improvements

  • 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

log-parser's People

Contributors

will-head avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.