smpl_prflr 0.0.9 → 0.1.0
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/lib/smpl_prflr/constants.rb +0 -6
- data/lib/smpl_prflr/errors.rb +37 -0
- data/lib/smpl_prflr/initializers/base.rb +17 -0
- data/lib/smpl_prflr/version.rb +1 -1
- data/lib/smpl_prflr.rb +10 -31
- data/test/test_ping.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3f10e567765ca0ed3ef844f4ff52441884183d3e4a6cf4bc6dde5464be58c256
|
4
|
+
data.tar.gz: b37c061d5f817171a1a08e925bf87ed07234986ae5cb992ff51559621981a3ed
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 727f102810b6f6152909571b1c529c9041eac6ea739b051b4089355c25330c8c3688d4537dcd8c22c0eb6e96452f20cbcf871a684a859e40a2dd50d509ea332b
|
7
|
+
data.tar.gz: e13236737185a7cf704b445b4062e85647768fd214e316030cefe9ec4c3aa1d1aed2f0afafee2fb7cbebfd88bf9406e98a9364756e878f4d745da3959f4dbc28
|
data/lib/smpl_prflr/constants.rb
CHANGED
@@ -0,0 +1,37 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Copyright (c) 2019-2022 Kondratev Ilya
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included
|
15
|
+
# in all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
|
+
# SOFTWARE.
|
24
|
+
|
25
|
+
module SmplPrflr
|
26
|
+
# main error
|
27
|
+
class Error < StandardError; end
|
28
|
+
|
29
|
+
# raise when profiler error
|
30
|
+
class ProfilerError < Error; end
|
31
|
+
|
32
|
+
# raise when load resources error
|
33
|
+
class LoadResourcesError < Error; end
|
34
|
+
|
35
|
+
# raise in main class
|
36
|
+
class ClassProfilerError < Error; end
|
37
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
require 'redis'
|
2
|
+
|
3
|
+
module SmplPrflr
|
4
|
+
module Initializers
|
5
|
+
module Base
|
6
|
+
def initialize_base!
|
7
|
+
host = ENV['HOST'] || SmplPrflr::Constants::HOST
|
8
|
+
port = ENV['PORT'] || SmplPrflr::Constants::PORT
|
9
|
+
db = ENV['DB'] || SmplPrflr::Constants::DB
|
10
|
+
|
11
|
+
@redis = Redis.new(host: host, port: port, db: db)
|
12
|
+
rescue StandardError => e
|
13
|
+
raise SmplPrflr::LoadResourcesError.new, e.message
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
data/lib/smpl_prflr/version.rb
CHANGED
data/lib/smpl_prflr.rb
CHANGED
@@ -22,54 +22,33 @@
|
|
22
22
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
23
23
|
# SOFTWARE.
|
24
24
|
|
25
|
-
require 'logger'
|
26
|
-
require "figaro"
|
27
25
|
require 'ruby-prof'
|
28
|
-
require '
|
26
|
+
require 'smpl_prflr/initializers/base'
|
29
27
|
require 'smpl_prflr/constants'
|
28
|
+
require 'smpl_prflr/errors'
|
30
29
|
|
31
30
|
module SmplPrflr
|
32
|
-
|
31
|
+
include SmplPrflr::Initializers::Base
|
33
32
|
|
34
|
-
# @author KILYA
|
35
|
-
# Init logger
|
36
|
-
#
|
37
33
|
# Init Profiler
|
38
34
|
#
|
39
|
-
# Load env
|
40
|
-
#
|
41
35
|
# Init Redis
|
42
36
|
# @raise [ProfilerError]
|
43
|
-
def initialize_profiler!
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
Figaro.application = Figaro::Application.new(
|
48
|
-
environment: mod.to_sym,
|
49
|
-
path: path
|
50
|
-
)
|
51
|
-
Figaro.load
|
52
|
-
|
53
|
-
@logger = Logger.new($stdout)
|
54
|
-
@redis = Redis.new(
|
55
|
-
host: Figaro.env.host || SmplPrflr::Constants::HOST,
|
56
|
-
port: Figaro.env.port || SmplPrflr::Constants::PORT,
|
57
|
-
db: Figaro.env.db || SmplPrflr::Constants::DB
|
58
|
-
)
|
59
|
-
rescue StandardError => e
|
60
|
-
raise ProfilerError.new e.message
|
37
|
+
def initialize_profiler!
|
38
|
+
initialize_base!
|
39
|
+
rescue SmplPrflr::Error => e
|
40
|
+
raise SmplPrflr::ClassProfilerErrore, e.message
|
61
41
|
end
|
62
42
|
|
63
|
-
# @author KILYA
|
64
43
|
# @example PONG
|
65
44
|
# @return [String] PONG
|
66
45
|
def ping
|
67
46
|
"PONG"
|
68
47
|
end
|
69
48
|
|
70
|
-
# @author KILYA
|
71
49
|
# Profile block of your code
|
72
50
|
# @return [nil]
|
51
|
+
# @raise ProfilerError
|
73
52
|
def p
|
74
53
|
result = RubyProf.profile do
|
75
54
|
yield
|
@@ -81,7 +60,7 @@ module SmplPrflr
|
|
81
60
|
@redis.set(:profile, output)
|
82
61
|
|
83
62
|
nil
|
84
|
-
rescue
|
85
|
-
|
63
|
+
rescue SmplPrflr::Error => e
|
64
|
+
raise SmplPrflr::ClassProfilerErrore.new, e.message
|
86
65
|
end
|
87
66
|
end
|
data/test/test_ping.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: smpl_prflr
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilya Kondratev
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-05-
|
11
|
+
date: 2022-05-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rubocop
|
@@ -117,6 +117,8 @@ files:
|
|
117
117
|
- bin/smpl_prflr
|
118
118
|
- lib/smpl_prflr.rb
|
119
119
|
- lib/smpl_prflr/constants.rb
|
120
|
+
- lib/smpl_prflr/errors.rb
|
121
|
+
- lib/smpl_prflr/initializers/base.rb
|
120
122
|
- lib/smpl_prflr/version.rb
|
121
123
|
- smpl_prflr.gemspec
|
122
124
|
- test/test_ping.rb
|