[![Coverage Status](https://coveralls.io/repos/github/DMazzei/log-analyser/badge.svg?branch=master)](https://coveralls.io/github/DMazzei/log-analyser?branch=master)
[![Gem Version](https://badge.fury.io/rb/log-analyser.svg)](https://badge.fury.io/rb/log-analyser)
[![Circle CI](https://circleci.com/gh/DMazzei/log-analyser.svg?style=shield)](https://app.circleci.com/pipelines/github/DMazzei/log-analyser)
![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/dmazzei/log-analyser)
![Gem](https://img.shields.io/gem/dv/log-analyser/stable)
# Log-Analyser
## About
Simple ruby library to read and parse web-server's log files and aggregate pageview data.
### TL;DR
check minimal instructions
Install *log-analyser* gem.
After instantiating *log-analyser's* `PageviewsLogAggregator` class with the path to the logfile:
- the method `all` will return the pageview count
- whilst method `unique` will return the unique pageview count.
### Table of Contents
click to expand the index
- [Installation](#installation)
- [Usage](#usage)
- [Logs and Pageviews](#logs-and-pageviews)
* [Definitions](#definitions)
* [Log Formatting](#log-formatting)
- [Development](#development)
- [Contributing](#contributing)
- [Next Steps](#next-steps)
- [License](#license)
## Installation
To use *log-analyser* in your application, add this line to your Gemfile:
```ruby
gem 'log-analyser'
```
Or install it yourself as:
$ gem install log-analyser
## Usage
```
...
...
...
...
...
```
## Logs and Pageviews
### Definitions
```
A pageview is defined as a view of a page on your site that is being tracked by the Analytics tracking code.
If a user clicks reload after reaching the page, this is counted as an additional pageview.
If a user navigates to a different page and then returns to the original page, a second pageview is recorded as well.
A unique pageview, as seen in the Content Overview report, aggregates pageviews that are generated by the same
user during the same session. A unique pageview represents the number of sessions during which that page was
viewed one or more times.
```
### Log Formatting
The library is prepared to parser text files, containing one entry per line, in the format: `\page_name identifier`.
A space must separate the page name (first column) from the user identifier (e.g. IP address):
```
/help_page/1 126.318.035.038
/contact 184.123.665.067
/home 184.123.665.067
```
## Development
#### Start with the project:
Install the Ruby version specified in `.ruby-version`
Clone the project and install Bundler
```
git clone git@github.com:DMazzei/log-analyser.git
cd log-analyser
gem install bundler
```
#### Setup:
Run the initial setup
$ bin/setup
> If you need to reinstall dependencies or something alike:
> ```
> $ bundle install
> ```
You can also run `Bundle exec console` for an interactive prompt that will allow you to experiment.
To install this gem onto your local machine, run `bundle exec rake install`.
To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
#### Linter (rubocop)
_*Rubocop*_ is used as code analyser and maintain code formatting (as well as some best practices).
Use `Bundle exec rake rubocop` to run the checks.
#### Test coverage
Use `Bundle exec rake rspec` to run the tests.
The test coverage is handled by `rspec`, `simplecov` and `coveralls`.
Status and coverage history can be checked [here](https://coveralls.io/github/DMazzei/log-analyser).
## Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/log-analyser.
## Next Steps
- Extend the logfile formatting;
## License
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).