log-analyser 0.1.3.pre.documentation.20201108192110 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +53 -18
  3. data/lib/parser.rb +8 -3
  4. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c2b9b98f46b7ffd52716e53e4b069bfa6d1a01186bfe24bd5e6d9136fc9b79af
4
- data.tar.gz: 67c01dedd6e66dc077d6e852f64c5270573cdd6c579aeda09326f881845dc61f
3
+ metadata.gz: e674497a874db3f4d4606f02ff122b150c0b38c67b7a60c2d174ad2d48044f8b
4
+ data.tar.gz: 132633ec26b7f212b16c336b9853be71ea66c8a7e86536bcee5afed093cd6726
5
5
  SHA512:
6
- metadata.gz: a60d02c6be8493405b7bcd36c7b1bdcffb8a3f24f5432411fbacb707ccc4d0c59f44797d64fa1f553ab48b13ee9c3f750d8ec4c1a06b3a910db65c7ad71638ee
7
- data.tar.gz: b56ec12bf9e52a256498c9573bfceb0eefe40404131536a5ce37514f92ef2840a269df5aad120230aa9a9539c14239419d07a8cba6b35dcdf26621a319bf4f5f
6
+ metadata.gz: 5aa790f2797dbc77c0fa98ea840dbf64dd7ecd70a103bda5dcdd9a90e52ea4bc6ce9101a1ec80087ece3f898f5a52ae7f3d09b6135ee269ded29fa88c91c6824
7
+ data.tar.gz: 0b2d40188550b7fe78404cb5888383e912921d12d3cde8822ea93e46f9df86a2754c17806c72e60a3d67aee7e8c7e7ceb412448974e77266c5813ef69a382ee1
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
+ [![Circle CI](https://circleci.com/gh/DMazzei/log-analyser.svg?style=shield)](https://app.circleci.com/pipelines/github/DMazzei/log-analyser)
1
2
  [![Coverage Status](https://coveralls.io/repos/github/DMazzei/log-analyser/badge.svg?branch=master)](https://coveralls.io/github/DMazzei/log-analyser?branch=master)
2
3
  [![Gem Version](https://badge.fury.io/rb/log-analyser.svg)](https://badge.fury.io/rb/log-analyser)
3
- [![Circle CI](https://circleci.com/gh/DMazzei/log-analyser.svg?style=shield)](https://app.circleci.com/pipelines/github/DMazzei/log-analyser)
4
4
  ![GitHub code size in bytes](https://img.shields.io/github/languages/code-size/dmazzei/log-analyser)
5
5
  ![Gem](https://img.shields.io/gem/dv/log-analyser/stable)
6
6
 
@@ -56,14 +56,27 @@ Or install it yourself as:
56
56
 
57
57
  #### Gem Usage
58
58
 
59
- ```
60
- ...
61
- ...
62
- ...
63
- ...
64
- ...
59
+ ```ruby
60
+ #!/usr/bin/env ruby
61
+
62
+ require 'pageviews_log_aggregator'
63
+
64
+ file_path = '/Users/dmazzei/projects/personal/ruby/sp_test/log-analyser/resources/webserver.log'
65
+ log_aggregator = LogAnalyser::PageviewsLogAggregator.new(file_path)
66
+
67
+ puts "\nAll pageviews"
68
+ log_aggregator.all.each do |key, value|
69
+ puts "#{key&.to_s&.ljust(28, '.')} | #{value}"
70
+ end
71
+
72
+ puts "\nUnique pageviews"
73
+ log_aggregator.unique.each do |key, value|
74
+ puts "#{key&.to_s&.ljust(28, '.')} | #{value}"
75
+ end
65
76
  ```
66
77
 
78
+ ![image](https://user-images.githubusercontent.com/3502642/98482375-dbe8b880-21f8-11eb-853a-ea67acf643ae.png)
79
+
67
80
  ### Project
68
81
 
69
82
  Install the Ruby version specified in `.ruby-version` </br>
@@ -88,12 +101,12 @@ Run the initial setup
88
101
 
89
102
  #### Usage
90
103
 
91
- Call `./bin/parse_pageview_file.rb` passing a logfile path as argument, will return the pageview count ordered from most to less viewed.</br>
92
- Check the script with `--help` argument for more options
104
+ Call `./bin/parse_pageview_file.rb` passing a logfile path as argument, it will return the pageview count ordered from most to less viewed.</br>
105
+ Check `--help` for more options
93
106
 
94
107
  ![image](https://user-images.githubusercontent.com/3502642/98471556-0c265c00-21e5-11eb-8fc3-c029e09e41fa.png)
95
108
 
96
- An example log can be found in `resources` folder:
109
+ An example log can be found in :file_folder:`resources` folder:
97
110
 
98
111
  $ ./bin/parse_pageview_file.rb --file 'resources/webserver.log'
99
112
  |--------------------------------------------------|
@@ -147,22 +160,39 @@ A space must separate the page name (first column) from the user identifier (e.g
147
160
 
148
161
  #### Start with the project:
149
162
 
163
+ ```
164
+ $ git clone git@github.com:DMazzei/log-analyser.git
165
+ $ cd log-analyser
166
+ $ gem install bundler
167
+ $ bundle install
168
+ ```
150
169
 
170
+ And the world is your oyster...
151
171
 
152
- You can also run `Bundle exec console` for an interactive prompt that will allow you to experiment.
172
+ You can also run `$ bundle exec console` for an interactive prompt that will allow you to experiment.
153
173
 
154
- To install this gem onto your local machine, run `bundle exec rake install`.
155
- 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).
174
+ To install this gem onto your local machine, run `$ bundle exec rake install`.
175
+ 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).
156
176
 
157
177
  #### Linter (rubocop)
158
178
 
159
179
  _*Rubocop*_ is used as code analyser and maintain code formatting (as well as some best practices).
160
180
 
161
- Use `Bundle exec rake rubocop` to run the checks.
181
+ Use `$ bundle exec rake rubocop` to run the checks.
162
182
 
163
183
  #### Test coverage
164
184
 
165
- Use `Bundle exec rake rspec` to run the tests.
185
+ [![Coverage Status](https://coveralls.io/repos/github/DMazzei/log-analyser/badge.svg?branch=master)](https://coveralls.io/github/DMazzei/log-analyser?branch=master)
186
+
187
+ Use `$ bundle exec rspec` or `$ bundle exec rake spec:all` to run all the tests.
188
+
189
+ :white_check_mark: To run only unit-tests
190
+
191
+ $ bundle exec rake spec:unit
192
+
193
+ :white_check_mark: To run only integration tests
194
+
195
+ $ bundle exec rake spec:integration
166
196
 
167
197
  The test coverage is handled by `rspec`, `simplecov` and `coveralls`.
168
198
  Status and coverage history can be checked [here](https://coveralls.io/github/DMazzei/log-analyser).
@@ -177,7 +207,7 @@ The _*master branch*_ merge process will trigger the deployment process on Circl
177
207
 
178
208
  The whole deployment process will finish by building and tagging a new gem version and pushing it to [rubygems.org](https://rubygems.org/gems/log-analyser).
179
209
 
180
- > :warning: In order to merge changes into _*master branch*_, the version must be bumped up, otherwise the deployment will fail.</br>
210
+ > :warning: To merge changes into _*master*_, the version must be bumped up, otherwise the deployment will fail!</br>
181
211
  > The version must be updated in `version.rb`.
182
212
 
183
213
  ## Contributing
@@ -185,8 +215,13 @@ The whole deployment process will finish by building and tagging a new gem versi
185
215
  Bug reports and pull requests are welcome on GitHub at https://github.com/DMazzeig/log-analyser.
186
216
 
187
217
  ## Next Steps
188
-
189
- - Extend the logfile formatting;
218
+
219
+ - One conundrum faced that can be reviewed, deciding between:
220
+ * reading the file whilst aggregation data, preserving memory - e.g. using `Set`;
221
+ * loading data into memory and leaving aggregation and count to be dealt later, gaining flexibility and performance;
222
+ - Extend the accepted logfile format;
223
+ - Add more options for sorting and filtering;
224
+ - Automate library version bump up;
190
225
 
191
226
  ## License
192
227
 
@@ -12,24 +12,29 @@ module LogAnalyser
12
12
  new.call(file_path)
13
13
  end
14
14
 
15
+ def initialize
16
+ @entries = Hash.new { |h, k| h[k] = [] }
17
+ end
18
+
15
19
  def call(file_path)
16
20
  raise FileNotFoundError, file_path unless File.exist?(file_path)
17
21
 
18
22
  data = File.open(file_path).map(&:strip)
19
23
  data.reject!(&:empty?)
20
24
  parse(data)
25
+
26
+ entries
21
27
  end
22
28
 
23
29
  private
24
30
 
31
+ attr_reader :entries
32
+
25
33
  def parse(data)
26
- entries = Hash.new { |h, k| h[k] = [] }
27
34
  data.each do |entry|
28
35
  key, value = *entry.split(/\s+/)
29
36
  entries[key] << value
30
37
  end
31
-
32
- entries
33
38
  end
34
39
  end
35
40
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: log-analyser
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3.pre.documentation.20201108192110
4
+ version: 0.1.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan Mazzei
@@ -54,9 +54,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
54
54
  version: '2.7'
55
55
  required_rubygems_version: !ruby/object:Gem::Requirement
56
56
  requirements:
57
- - - ">"
57
+ - - ">="
58
58
  - !ruby/object:Gem::Version
59
- version: 1.3.1
59
+ version: '0'
60
60
  requirements: []
61
61
  rubygems_version: 3.1.4
62
62
  signing_key: