log-analyser 0.1.3.pre.documentation.20201108193310 → 0.1.3.pre.littleimprovements.20201109103434
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.
- checksums.yaml +4 -4
- data/CHANGELOG +3 -3
- data/README.md +31 -14
- data/lib/parser.rb +8 -3
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 3b62538506c3829402a9e9a867bf26d6576937c69614a4f530ef20cd64699d25
|
|
4
|
+
data.tar.gz: 5c77973bbe06797d4a95726439485ff254474ef3f11417787d972372e5d83d53
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc3f9e866820219b709fc2b5fab185afd51698e975cfb8bb528bc11c92132e99650431ce46af7b7d5ef722b02e915a3534876ece19d37fc5d4c6c7497dd6a677
|
|
7
|
+
data.tar.gz: f55d687636405327c1863950ae14c2720af6313407be1cbffc20239690a18ea88b8a92f54fbaf9f3187cd9c589d2e64d0ad244110e3f1ef798b11797028153fe
|
data/CHANGELOG
CHANGED
data/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
+
[](https://app.circleci.com/pipelines/github/DMazzei/log-analyser)
|
|
1
2
|
[](https://coveralls.io/github/DMazzei/log-analyser?branch=master)
|
|
2
3
|
[](https://badge.fury.io/rb/log-analyser)
|
|
3
|
-
[](https://app.circleci.com/pipelines/github/DMazzei/log-analyser)
|
|
4
4
|

|
|
5
5
|

|
|
6
6
|
|
|
@@ -101,12 +101,12 @@ Run the initial setup
|
|
|
101
101
|
|
|
102
102
|
#### Usage
|
|
103
103
|
|
|
104
|
-
Call `./bin/parse_pageview_file.rb` passing a logfile path as argument, will return the pageview count ordered from most to less viewed.</br>
|
|
105
|
-
Check
|
|
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
|
|
106
106
|
|
|
107
107
|

|
|
108
108
|
|
|
109
|
-
An example log can be found in
|
|
109
|
+
An example log can be found in :file_folder:`resources` folder:
|
|
110
110
|
|
|
111
111
|
$ ./bin/parse_pageview_file.rb --file 'resources/webserver.log'
|
|
112
112
|
|--------------------------------------------------|
|
|
@@ -169,23 +169,35 @@ $ bundle install
|
|
|
169
169
|
|
|
170
170
|
And the world is your oyster...
|
|
171
171
|
|
|
172
|
-
You can also run
|
|
172
|
+
You can also run `$ bundle exec console` for an interactive prompt that will allow you to experiment.
|
|
173
173
|
|
|
174
|
-
To install this gem onto your local machine, run
|
|
175
|
-
To release a new version, update the version number in `version.rb`, and then run
|
|
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).
|
|
176
176
|
|
|
177
177
|
#### Linter (rubocop)
|
|
178
178
|
|
|
179
179
|
_*Rubocop*_ is used as code analyser and maintain code formatting (as well as some best practices).
|
|
180
180
|
|
|
181
|
-
Use
|
|
181
|
+
Use `$ bundle exec rake rubocop` to run the checks.
|
|
182
182
|
|
|
183
183
|
#### Test coverage
|
|
184
184
|
|
|
185
|
-
|
|
185
|
+
[](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
|
|
186
192
|
|
|
187
|
-
|
|
188
|
-
|
|
193
|
+
:white_check_mark: To run only integration tests
|
|
194
|
+
|
|
195
|
+
$ bundle exec rake spec:integration
|
|
196
|
+
|
|
197
|
+
The test coverage is handled by `rspec`, `simplecov` and `coveralls`.</br>
|
|
198
|
+
After running the tests, a local version of the test coverage report is available [here](http://localhost:63342/log-analyser/coverage/index.html).
|
|
199
|
+
|
|
200
|
+
Full status and coverage history can be checked online on [coveralls](https://coveralls.io/github/DMazzei/log-analyser).
|
|
189
201
|
|
|
190
202
|
#### Deployment
|
|
191
203
|
|
|
@@ -197,7 +209,7 @@ The _*master branch*_ merge process will trigger the deployment process on Circl
|
|
|
197
209
|
|
|
198
210
|
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).
|
|
199
211
|
|
|
200
|
-
> :warning:
|
|
212
|
+
> :warning: To merge changes into _*master*_, the version must be bumped up, otherwise the deployment will fail!</br>
|
|
201
213
|
> The version must be updated in `version.rb`.
|
|
202
214
|
|
|
203
215
|
## Contributing
|
|
@@ -205,8 +217,13 @@ The whole deployment process will finish by building and tagging a new gem versi
|
|
|
205
217
|
Bug reports and pull requests are welcome on GitHub at https://github.com/DMazzeig/log-analyser.
|
|
206
218
|
|
|
207
219
|
## Next Steps
|
|
208
|
-
|
|
209
|
-
-
|
|
220
|
+
|
|
221
|
+
- One conundrum faced that can be reviewed, deciding between:
|
|
222
|
+
* reading the file whilst aggregation data, preserving memory - e.g. using `Set`;
|
|
223
|
+
* loading data into memory and leaving aggregation and count to be dealt later, gaining flexibility and performance;
|
|
224
|
+
- Extend the accepted logfile format;
|
|
225
|
+
- Add more options for sorting and filtering;
|
|
226
|
+
- Automate library version bump up;
|
|
210
227
|
|
|
211
228
|
## License
|
|
212
229
|
|
data/lib/parser.rb
CHANGED
|
@@ -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,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: log-analyser
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.3.pre.
|
|
4
|
+
version: 0.1.3.pre.littleimprovements.20201109103434
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Dan Mazzei
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2020-11-
|
|
11
|
+
date: 2020-11-09 00:00:00.000000000 Z
|
|
12
12
|
dependencies: []
|
|
13
13
|
description: Log reader and data aggregator for pageviews information.
|
|
14
14
|
email:
|