stat_trackr 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 18ea645406531aecb0e9ec8e64c3a35179dd1a9762deb3c13eeb6c9759854c7e
4
+ data.tar.gz: 3b581cbfff3754f49949b34ccdb310d057a73c8cb66af6a67aea357fcb28b0b8
5
+ SHA512:
6
+ metadata.gz: debf3ad569edf95b728ff978e2075bed431da6e47b020bb41343ec8f8fdb752cd143858c4c05cb910b507311c3d5a59bc6acf37c4c2a01760198e0cb39593d3b
7
+ data.tar.gz: 987c2086be9659fa916dd19ff079cf60c58375aa143bc26ca627aae27efd498063fee617d36d1e21f3f962b3421f4b33a7ef269842146e79a2cee2fb3f2b1671
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.rubocop.yml ADDED
@@ -0,0 +1,13 @@
1
+ AllCops:
2
+ TargetRubyVersion: 2.6
3
+
4
+ Style/StringLiterals:
5
+ Enabled: true
6
+ EnforcedStyle: double_quotes
7
+
8
+ Style/StringLiteralsInInterpolation:
9
+ Enabled: true
10
+ EnforcedStyle: double_quotes
11
+
12
+ Layout/LineLength:
13
+ Max: 120
data/CHANGELOG.md ADDED
@@ -0,0 +1,5 @@
1
+ ## [Unreleased]
2
+
3
+ ## [0.1.0] - 2023-10-09
4
+
5
+ - Initial release
data/Gemfile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ source "https://rubygems.org"
4
+
5
+ # Specify your gem's dependencies in stat_trackr.gemspec
6
+ gemspec
7
+
8
+ gem "rake", "~> 13.0"
9
+
10
+ gem "rspec", "~> 3.0"
11
+
12
+ gem "rubocop", "~> 1.21"
data/Gemfile.lock ADDED
@@ -0,0 +1,73 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ stat_trackr (0.1.0)
5
+ httpx (~> 1.0.1)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ ast (2.4.2)
11
+ base64 (0.1.1)
12
+ coderay (1.1.3)
13
+ diff-lcs (1.5.0)
14
+ http-2-next (1.0.0)
15
+ httpx (1.0.1)
16
+ http-2-next (>= 1.0.0)
17
+ json (2.6.3)
18
+ language_server-protocol (3.17.0.3)
19
+ method_source (1.0.0)
20
+ parallel (1.23.0)
21
+ parser (3.2.2.4)
22
+ ast (~> 2.4.1)
23
+ racc
24
+ pry (0.14.2)
25
+ coderay (~> 1.1)
26
+ method_source (~> 1.0)
27
+ racc (1.7.1)
28
+ rainbow (3.1.1)
29
+ rake (13.0.6)
30
+ regexp_parser (2.8.1)
31
+ rexml (3.2.6)
32
+ rspec (3.12.0)
33
+ rspec-core (~> 3.12.0)
34
+ rspec-expectations (~> 3.12.0)
35
+ rspec-mocks (~> 3.12.0)
36
+ rspec-core (3.12.2)
37
+ rspec-support (~> 3.12.0)
38
+ rspec-expectations (3.12.3)
39
+ diff-lcs (>= 1.2.0, < 2.0)
40
+ rspec-support (~> 3.12.0)
41
+ rspec-mocks (3.12.6)
42
+ diff-lcs (>= 1.2.0, < 2.0)
43
+ rspec-support (~> 3.12.0)
44
+ rspec-support (3.12.1)
45
+ rubocop (1.56.4)
46
+ base64 (~> 0.1.1)
47
+ json (~> 2.3)
48
+ language_server-protocol (>= 3.17.0)
49
+ parallel (~> 1.10)
50
+ parser (>= 3.2.2.3)
51
+ rainbow (>= 2.2.2, < 4.0)
52
+ regexp_parser (>= 1.8, < 3.0)
53
+ rexml (>= 3.2.5, < 4.0)
54
+ rubocop-ast (>= 1.28.1, < 2.0)
55
+ ruby-progressbar (~> 1.7)
56
+ unicode-display_width (>= 2.4.0, < 3.0)
57
+ rubocop-ast (1.29.0)
58
+ parser (>= 3.2.1.0)
59
+ ruby-progressbar (1.13.0)
60
+ unicode-display_width (2.5.0)
61
+
62
+ PLATFORMS
63
+ x86_64-darwin-20
64
+
65
+ DEPENDENCIES
66
+ pry
67
+ rake (~> 13.0)
68
+ rspec (~> 3.0)
69
+ rubocop (~> 1.21)
70
+ stat_trackr!
71
+
72
+ BUNDLED WITH
73
+ 2.4.13
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2023 hongda
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.
data/README.md ADDED
@@ -0,0 +1,14 @@
1
+ # StatTrackr
2
+
3
+ ## Config
4
+ ```rb
5
+ StatTrackr.configure do |config|
6
+ config.url = 'foo.bar.com'
7
+ end
8
+ ```
9
+
10
+ ## Report
11
+ ```rb
12
+ reporter = StatTrackr::Reporter.new('12814926-a346-4871-a65b-706bbee01531')
13
+ reporter.ping('2023-10-09', 9912)
14
+ ```
data/Rakefile ADDED
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require "rubocop/rake_task"
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]
13
+
14
+ task :console do
15
+ exec "pry -r stat_trackr -I ./lib"
16
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module StatTrackr
4
+ VERSION = "0.1.0"
5
+ end
@@ -0,0 +1,48 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'httpx'
4
+ require_relative "stat_trackr/version"
5
+
6
+ begin
7
+ require "pry"
8
+ rescue LoadError
9
+ end
10
+
11
+ module StatTrackr
12
+ class Error < StandardError; end
13
+
14
+ class Configuration
15
+ attr_accessor :api_key, :url
16
+
17
+ def initialize
18
+ @api_key = nil
19
+ @url = nil
20
+ end
21
+ end
22
+
23
+ class << self
24
+ attr_accessor :config
25
+
26
+ def configure
27
+ self.config ||= Configuration.new
28
+ yield(config)
29
+ end
30
+ end
31
+
32
+ class Reporter
33
+ def initialize(metric_id)
34
+ @metric_id = metric_id
35
+ end
36
+
37
+ def ping(date, value)
38
+ raise Error if StatTrackr.config.url.nil?
39
+ data = {
40
+ "event_date" => date,
41
+ "event_value" => value,
42
+ "metric_id" => @metric_id,
43
+ }
44
+ response = HTTPX.post(StatTrackr.config.url, json: data, ssl: {verify_mode: OpenSSL::SSL::VERIFY_NONE})
45
+ response.status == 200
46
+ end
47
+ end
48
+ end
@@ -0,0 +1,4 @@
1
+ module StatTrackr
2
+ VERSION: String
3
+ # See the writing guide of rbs: https://github.com/ruby/rbs#guides
4
+ end
metadata ADDED
@@ -0,0 +1,85 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stat_trackr
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - foobar
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2023-10-09 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: httpx
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 1.0.1
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 1.0.1
27
+ - !ruby/object:Gem::Dependency
28
+ name: pry
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ description: Write a longer description or delete this line.
42
+ email:
43
+ - foobar@v2up.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".rspec"
49
+ - ".rubocop.yml"
50
+ - CHANGELOG.md
51
+ - Gemfile
52
+ - Gemfile.lock
53
+ - LICENSE.txt
54
+ - README.md
55
+ - Rakefile
56
+ - lib/stat_trackr.rb
57
+ - lib/stat_trackr/version.rb
58
+ - sig/stat_trackr.rbs
59
+ homepage: https://github.com/42up/stat_trackr
60
+ licenses:
61
+ - MIT
62
+ metadata:
63
+ homepage_uri: https://github.com/42up/stat_trackr
64
+ source_code_uri: https://github.com/42up/stat_trackr
65
+ changelog_uri: https://github.com/42up/stat_trackr
66
+ post_install_message:
67
+ rdoc_options: []
68
+ require_paths:
69
+ - lib
70
+ required_ruby_version: !ruby/object:Gem::Requirement
71
+ requirements:
72
+ - - ">="
73
+ - !ruby/object:Gem::Version
74
+ version: 2.6.0
75
+ required_rubygems_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ requirements: []
81
+ rubygems_version: 3.2.22
82
+ signing_key:
83
+ specification_version: 4
84
+ summary: Write a short summary, because RubyGems requires one.
85
+ test_files: []