log-analyser 0.1.3.pre.documentation.20201108193310 → 0.1.3.pre.documentation.20201108212148
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/README.md +21 -9
- data/lib/parser.rb +8 -3
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 03efda757aa22b9f9ea0f423141e06e6511652d96413e8cb17126fc683534a52
|
|
4
|
+
data.tar.gz: b48a0a4c69058d611a3195297c2df0a81a5057d5b7f32119a8cb40ac05b26c31
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 300cddabf1f0b4ebd49f45aebc8a248086801184a8a2c01efae5d1f316d96beb0fd26dd3310234799dd95b070b7cd5b3197d139b80a70a59f27a03339f0c09a9
|
|
7
|
+
data.tar.gz: c45d4fd9cb2f49b7a0da8f93a74e6180d24bcd245e7f48d576d34c9d1ae1fd036240f685154cb123ddd5432a0e179c3e26ce2cf670d9988929d2443b2831e59d
|
data/README.md
CHANGED
|
@@ -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,20 +169,30 @@ $ 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 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
|
|
186
196
|
|
|
187
197
|
The test coverage is handled by `rspec`, `simplecov` and `coveralls`.
|
|
188
198
|
Status and coverage history can be checked [here](https://coveralls.io/github/DMazzei/log-analyser).
|
|
@@ -197,7 +207,7 @@ The _*master branch*_ merge process will trigger the deployment process on Circl
|
|
|
197
207
|
|
|
198
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).
|
|
199
209
|
|
|
200
|
-
> :warning:
|
|
210
|
+
> :warning: To merge changes into _*master*_, the version must be bumped up, otherwise the deployment will fail!</br>
|
|
201
211
|
> The version must be updated in `version.rb`.
|
|
202
212
|
|
|
203
213
|
## Contributing
|
|
@@ -207,6 +217,8 @@ Bug reports and pull requests are welcome on GitHub at https://github.com/DMazze
|
|
|
207
217
|
## Next Steps
|
|
208
218
|
|
|
209
219
|
- Extend the logfile formatting;
|
|
220
|
+
- Add more options for sorting and filtering;
|
|
221
|
+
- Automate library version bump up;
|
|
210
222
|
|
|
211
223
|
## License
|
|
212
224
|
|
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
|