smpl_prflr 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e831f2e767a19c097213f666ba1d2b4cc84b3af52e89b63fe6dafae66f96570d
4
- data.tar.gz: 0c344feef44fe4104b7079dd97472263daff3e64fec9cd197b99ec5bf34a1f95
3
+ metadata.gz: 4512a90321b13ef139c866db48da2d2d470db633f1a61338ef429d0d0d12bb0b
4
+ data.tar.gz: 68ba88dc28766ccdd6d5f901e705dc27df67918e1da35fd208e41e14aa364a36
5
5
  SHA512:
6
- metadata.gz: 30ac0c5de973a642f055f399ecb1cc2880345c8d5bd99b382f1ce94ab888a966958e2bc8150dc5bba97effbf5c157f14d54d06238759b54198bdcb7750a934dd
7
- data.tar.gz: 56f70de2928425215e4697c7a84255d5f323eef520362e9c9a55f4e3747f06f966aabc4c6894b0bf07345aa3721d54e0e869a0a035c2d7d20e3ea6773f39f161
6
+ metadata.gz: d3e79a2500b151477282f1098af5df11cf584f66f4de11db81bb0faaf6b48076578e73e89a47c0df52f8cf3103f7b70cd2acb4df58800f92752b0cf4cbee1512
7
+ data.tar.gz: 58ace1f5a79d7d6a6cc83cac4abe7fe6aaac89cd141f91dad5a770bb0d672bc0d80644c76cdf2c1d00741d9c03c3bb48245b4009656c7fa406f6d4e03f4ffcd5
data/.rubocop.yml CHANGED
@@ -61,4 +61,7 @@ Style/IdenticalConditionalBranches:
61
61
  Enabled: false
62
62
 
63
63
  Style/ExplicitBlockArgument:
64
+ Enabled: false
65
+
66
+ Style/RedundantFreeze:
64
67
  Enabled: false
data/README.md CHANGED
@@ -23,7 +23,7 @@ requre 'smpl_prflr'
23
23
 
24
24
  include SmplPrflr
25
25
 
26
- initialize_profiler!(mod: "production")
26
+ initialize_profiler! :production
27
27
 
28
28
  p { block_of_your_own_code }
29
29
  ```
data/bin/smpl_prflr CHANGED
@@ -9,7 +9,11 @@ require 'redis'
9
9
  # url: 127.0.0.1
10
10
  # method GET
11
11
  def my_method env
12
- redis = Redis.new host: "127.0.0.1", port: 6379, db: 15
12
+ redis = Redis.new(
13
+ host: "127.0.0.1" || env[:HOST],
14
+ port: 6379 || env[:PORT],
15
+ db: 15 || env[:DB]
16
+ )
13
17
  result = redis.get(:profile) || "Nothing to profile"
14
18
  [200, {}, [result]]
15
19
  rescue StandardError
@@ -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
+ module Constants
27
+ MODES = {
28
+ production: "config/production.yml",
29
+ development: "config/development.yml",
30
+ test: "config/test.yml"
31
+ }.freeze
32
+
33
+ HOST = "127.0.0.1".freeze
34
+ PORT = "6379"
35
+ DB = "15"
36
+ end
37
+ end
@@ -0,0 +1,27 @@
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
+ VERSION = "0.0.9".freeze
27
+ end
data/lib/smpl_prflr.rb CHANGED
@@ -23,35 +23,41 @@
23
23
  # SOFTWARE.
24
24
 
25
25
  require 'logger'
26
- require "config"
26
+ require "figaro"
27
27
  require 'ruby-prof'
28
28
  require 'redis'
29
- require 'profiler/constants'
30
- require 'active_support/all'
29
+ require 'smpl_prflr/constants'
31
30
 
32
31
  module SmplPrflr
32
+ class ProfilerError < StandardError; end
33
+
33
34
  # @author KILYA
34
35
  # Init logger
36
+ #
35
37
  # Init Profiler
38
+ #
36
39
  # Load env
40
+ #
37
41
  # Init Redis
42
+ # @raise [ProfilerError]
38
43
  def initialize_profiler!(mod = :development)
39
- Config.setup do |config|
40
- config.const_name = "Settings"
41
- config.use_env = false
42
- end
43
-
44
- env = mod.to_sym
45
- path = Dir.pwd << ("/config")
46
- Config.load_and_set_settings(Config.setting_files(path, env))
47
- Settings.env = env
44
+ path = File.expand_path(
45
+ Constants::MODES[mod.to_sym]
46
+ )
47
+ Figaro.application = Figaro::Application.new(
48
+ environment: mod.to_sym,
49
+ path: path
50
+ )
51
+ Figaro.load
48
52
 
49
53
  @logger = Logger.new($stdout)
50
54
  @redis = Redis.new(
51
- host: Settings.HOST || Profiler::Constants::DEFAULT_HOST,
52
- port: Settings.PORT || Profiler::Constants::DEFAULT_PORT,
53
- db: Settings.DB || Profiler::Constants::DEFAULT_DB
55
+ host: Figaro.env.host || SmplPrflr::Constants::HOST,
56
+ port: Figaro.env.port || SmplPrflr::Constants::PORT,
57
+ db: Figaro.env.db || SmplPrflr::Constants::DB
54
58
  )
59
+ rescue StandardError => e
60
+ raise ProfilerError.new e.message
55
61
  end
56
62
 
57
63
  # @author KILYA
@@ -65,11 +71,11 @@ module SmplPrflr
65
71
  # Profile block of your code
66
72
  # @return [nil]
67
73
  def p
68
- output = String.new
69
74
  result = RubyProf.profile do
70
75
  yield
71
76
  end
72
77
 
78
+ output = String.new
73
79
  printer = RubyProf::FlatPrinter.new(result)
74
80
  printer.print(output, min_percent: 0)
75
81
  @redis.set(:profile, output)
data/smpl_prflr.gemspec CHANGED
@@ -1,4 +1,9 @@
1
+ lib = File.expand_path("lib", __dir__)
2
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
+
1
4
  require 'English'
5
+ require 'smpl_prflr/version'
6
+
2
7
  Gem::Specification.new do |s|
3
8
  s.specification_version = 2 if s.respond_to? :specification_version=
4
9
  if s.respond_to? :required_rubygems_version=
@@ -7,7 +12,7 @@ Gem::Specification.new do |s|
7
12
  s.rubygems_version = '2.7'
8
13
  s.required_ruby_version = '>=2.2'
9
14
  s.name = 'smpl_prflr'
10
- s.version = '0.0.8'
15
+ s.version = SmplPrflr::VERSION
11
16
  s.executables << 'smpl_prflr'
12
17
  s.license = 'MIT'
13
18
  s.summary = 'Profiler'
@@ -21,5 +26,5 @@ Gem::Specification.new do |s|
21
26
  s.add_dependency 'ruby-prof', '~> 1.4', '>= 1.4.3'
22
27
  s.add_dependency 'redis', '~> 4.6'
23
28
  s.add_dependency 'rack', '~> 2.2'
24
- s.add_dependency 'config', '~> 4.0'
29
+ s.add_dependency 'figaro', '~> 1.2'
25
30
  end
data/test/test_ping.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'minitest/autorun'
2
2
  require 'smpl_prflr'
3
+ require 'smpl_prflr/version'
3
4
 
4
5
  class TestPing < Minitest::Test
5
6
  include SmplPrflr
@@ -7,4 +8,8 @@ class TestPing < Minitest::Test
7
8
  def test_reverse_string
8
9
  assert_equal("PONG", ping)
9
10
  end
11
+
12
+ def test_version
13
+ assert_equal("0.0.8", SmplPrflr::VERSION)
14
+ end
10
15
  end
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.8
4
+ version: 0.0.9
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-04-10 00:00:00.000000000 Z
11
+ date: 2022-05-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rubocop
@@ -87,19 +87,19 @@ dependencies:
87
87
  - !ruby/object:Gem::Version
88
88
  version: '2.2'
89
89
  - !ruby/object:Gem::Dependency
90
- name: config
90
+ name: figaro
91
91
  requirement: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - "~>"
94
94
  - !ruby/object:Gem::Version
95
- version: '4.0'
95
+ version: '1.2'
96
96
  type: :runtime
97
97
  prerelease: false
98
98
  version_requirements: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - "~>"
101
101
  - !ruby/object:Gem::Version
102
- version: '4.0'
102
+ version: '1.2'
103
103
  description: SmplPrflr for profiler own code.
104
104
  email: ilyafulleveline@gmail.com
105
105
  executables:
@@ -115,8 +115,9 @@ files:
115
115
  - README.md
116
116
  - Rakefile
117
117
  - bin/smpl_prflr
118
- - lib/profiler/constants.rb
119
118
  - lib/smpl_prflr.rb
119
+ - lib/smpl_prflr/constants.rb
120
+ - lib/smpl_prflr/version.rb
120
121
  - smpl_prflr.gemspec
121
122
  - test/test_ping.rb
122
123
  homepage: https://github.com/ikondratev/smpl_prflr
@@ -1,7 +0,0 @@
1
- module Profiler
2
- module Constants
3
- DEFAULT_HOST = "127.0.0.1".freeze
4
- DEFAULT_PORT = 6379
5
- DEFAULT_DB = 15
6
- end
7
- end