log-analyser 0.1.1.pre.addgemtagrelease.20201106201808

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: bd47a065d7c65ac5c61c132b8c8ef2c226f5937ed7b33ec180c73e347a966e50
4
+ data.tar.gz: 4187273a11d196f93982702ad4807ba75841af52f73a65642fc6eeafe256fb35
5
+ SHA512:
6
+ metadata.gz: 0b765240841a67f0f3a31332e5091025e8e2ba4e4bf7ceaf0f686995c1124ace844acad0d66069c2084d39544a2fe49ace0574bf530b1bc07531723d000cb08a
7
+ data.tar.gz: 8e2369c8b86517affc31abc6eb11f098d096079739f7bdc925ce6f6de02e104a9bc1b6f717733b2b867a40102843c93c0f21687f3a576bba16dbe9176efa84b8
@@ -0,0 +1 @@
1
+ v0.1.1. adding gemspec/echoe/
data/Gemfile ADDED
@@ -0,0 +1,24 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ gem 'bundler'
6
+ gem 'rake', '~> 12.0'
7
+ gem 'require_all'
8
+
9
+ group :development, :test do
10
+ gem 'coveralls_reborn', '~> 0.18.0', require: false
11
+ gem 'rspec', '~> 3.8'
12
+ gem 'rspec_junit_formatter'
13
+ gem 'rubocop', require: false
14
+ gem 'simplecov', require: false
15
+ gem 'simplecov-lcov'
16
+ end
17
+
18
+ group :development do
19
+ gem 'guard'
20
+ gem 'guard-rspec'
21
+ gem 'pry'
22
+ end
23
+
24
+ gemspec name: 'log-analyser'
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 DanMazzei
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,51 @@
1
+ [![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
+
4
+
5
+ ```
6
+ 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.
7
+
8
+ 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.
9
+ ```
10
+
11
+
12
+ # Log::Analyser
13
+
14
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/log/analyser`. To experiment with that code, run `bin/console` for an interactive prompt.
15
+
16
+ TODO: Delete this and the text above, and describe your gem
17
+
18
+ ## Installation
19
+
20
+ Add this line to your application's Gemfile:
21
+
22
+ ```ruby
23
+ gem 'log-analyser'
24
+ ```
25
+
26
+ And then execute:
27
+
28
+ $ bundle install
29
+
30
+ Or install it yourself as:
31
+
32
+ $ gem install log-analyser
33
+
34
+ ## Usage
35
+
36
+ TODO: Write usage instructions here
37
+
38
+ ## Development
39
+
40
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
41
+
42
+ 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).
43
+
44
+ ## Contributing
45
+
46
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/log-analyser.
47
+
48
+
49
+ ## License
50
+
51
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/setup'
4
+ require 'rubygems'
5
+ require 'rspec/core/rake_task'
6
+
7
+ Bundler::GemHelper.install_tasks
8
+
9
+ RSpec::Core::RakeTask.new(:spec)
10
+
11
+ task default: :spec
@@ -0,0 +1,19 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Pageviews
4
+ InvalidLogEntriesError = Class.new(StandardError)
5
+
6
+ def self.for(entries = {})
7
+ new.generate_view_count(entries)
8
+ rescue StandardError
9
+ raise InvalidLogEntriesError
10
+ end
11
+
12
+ def generate_view_count(entries)
13
+ entries
14
+ .transform_values(&:size)
15
+ .sort_by(&:last)
16
+ .reverse
17
+ .to_h
18
+ end
19
+ end
@@ -0,0 +1,27 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'parser'
4
+ require_relative 'pageviews'
5
+ require_relative 'unique_pageviews'
6
+
7
+ class PageviewsLogAggregator
8
+ def initialize(file_path)
9
+ @file_path = file_path
10
+ end
11
+
12
+ def all
13
+ Pageviews.for(entries)
14
+ end
15
+
16
+ def unique
17
+ UniquePageviews.for(entries)
18
+ end
19
+
20
+ private
21
+
22
+ attr_accessor :file_path
23
+
24
+ def entries
25
+ @entries ||= Parser.call(file_path)
26
+ end
27
+ end
@@ -0,0 +1,33 @@
1
+ # frozen_string_literal: true
2
+
3
+ class Parser
4
+ class FileNotFoundError < StandardError
5
+ def initialize(path)
6
+ super("File not found for path: [#{path}]")
7
+ end
8
+ end
9
+
10
+ def self.call(file_path)
11
+ new.call(file_path)
12
+ end
13
+
14
+ def call(file_path)
15
+ raise FileNotFoundError, file_path unless File.exist?(file_path)
16
+
17
+ data = File.open(file_path).map(&:strip)
18
+ data.reject!(&:empty?)
19
+ parse(data)
20
+ end
21
+
22
+ private
23
+
24
+ def parse(data)
25
+ entries = Hash.new { |h, k| h[k] = [] }
26
+ data.each do |entry|
27
+ key, value = *entry.split(/\s+/)
28
+ entries[key] << value
29
+ end
30
+
31
+ entries
32
+ end
33
+ end
@@ -0,0 +1,10 @@
1
+ # frozen_string_literal: true
2
+
3
+ class UniquePageviews < Pageviews
4
+ def generate_view_count(entries)
5
+ entries.transform_values { |value| value.uniq.size }
6
+ .sort_by(&:last)
7
+ .reverse
8
+ .to_h
9
+ end
10
+ end
@@ -0,0 +1,29 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'version'
4
+
5
+ Gem::Specification.new do |spec|
6
+ spec.name = 'log-analyser'
7
+ spec.version = VERSION
8
+ spec.authors = ['Dan Mazzei']
9
+ spec.email = ['danielmazzei@gmail.com']
10
+
11
+ spec.summary = 'Log reader and data aggregator for pageviews information.'
12
+ spec.description = 'Log reader and data aggregator for pageviews information.'
13
+ spec.homepage = 'https://github.com/DMazzei/log-analyser'
14
+ spec.license = 'MIT'
15
+ spec.required_ruby_version = Gem::Requirement.new('>= 2.7')
16
+
17
+ # spec.metadata['allowed_push_host'] = "'TODO: Set to 'http://mygemserver.com''"
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ # spec.metadata['source_code_uri'] = "'TODO: Put your gem's public repo URL here.'"
21
+ # spec.metadata['changelog_uri'] = "'TODO: Put your gem's CHANGELOG.md URL here.'"
22
+
23
+ # Specify which files should be added to the gem when it is released.
24
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
25
+ spec.files = %w(CHANGELOG Gemfile LICENSE.txt manifest README.md Rakefile lib/pageviews.rb lib/pageviews_log_aggregator.rb lib/parser.rb lib/unique_pageviews.rb log-analyser.gemspec version.rb)
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(/^exe\//) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+ end
@@ -0,0 +1,12 @@
1
+ CHANGELOG
2
+ Gemfile
3
+ LICENSE.txt
4
+ Manifest
5
+ README.md
6
+ Rakefile
7
+ lib/pageviews.rb
8
+ lib/pageviews_log_aggregator.rb
9
+ lib/parser.rb
10
+ lib/unique_pageviews.rb
11
+ log-analyser.gemspec
12
+ version.rb
@@ -0,0 +1,3 @@
1
+ # frozen_string_literal: true
2
+
3
+ VERSION = '0.1.1'
metadata ADDED
@@ -0,0 +1,56 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: log-analyser
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1.pre.addgemtagrelease.20201106201808
5
+ platform: ruby
6
+ authors:
7
+ - Dan Mazzei
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-06 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: Log reader and data aggregator for pageviews information.
14
+ email:
15
+ - danielmazzei@gmail.com
16
+ executables: []
17
+ extensions: []
18
+ extra_rdoc_files: []
19
+ files:
20
+ - CHANGELOG
21
+ - Gemfile
22
+ - LICENSE.txt
23
+ - README.md
24
+ - Rakefile
25
+ - lib/pageviews.rb
26
+ - lib/pageviews_log_aggregator.rb
27
+ - lib/parser.rb
28
+ - lib/unique_pageviews.rb
29
+ - log-analyser.gemspec
30
+ - manifest
31
+ - version.rb
32
+ homepage: https://github.com/DMazzei/log-analyser
33
+ licenses:
34
+ - MIT
35
+ metadata:
36
+ homepage_uri: https://github.com/DMazzei/log-analyser
37
+ post_install_message:
38
+ rdoc_options: []
39
+ require_paths:
40
+ - lib
41
+ required_ruby_version: !ruby/object:Gem::Requirement
42
+ requirements:
43
+ - - ">="
44
+ - !ruby/object:Gem::Version
45
+ version: '2.7'
46
+ required_rubygems_version: !ruby/object:Gem::Requirement
47
+ requirements:
48
+ - - ">"
49
+ - !ruby/object:Gem::Version
50
+ version: 1.3.1
51
+ requirements: []
52
+ rubygems_version: 3.1.4
53
+ signing_key:
54
+ specification_version: 4
55
+ summary: Log reader and data aggregator for pageviews information.
56
+ test_files: []