dry-monitor 0.3.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,4 +1,6 @@
1
- require 'dry/monitor/notifications'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/monitor/notifications"
2
4
 
3
5
  module Dry
4
6
  module Monitor
@@ -12,15 +14,13 @@ module Dry
12
14
  Notifications.register_event(REQUEST_STOP)
13
15
  Notifications.register_event(REQUEST_ERROR)
14
16
 
15
- attr_reader :app
16
-
17
- attr_reader :notifications
17
+ attr_reader :app, :notifications
18
18
 
19
19
  def initialize(*args)
20
20
  @notifications, @app = *args
21
21
  end
22
22
 
23
- def new(app)
23
+ def new(app, *_args, &_block)
24
24
  self.class.new(notifications, app)
25
25
  end
26
26
 
@@ -1,10 +1,11 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Monitor
3
5
  module SQL
4
6
  module Colorizers
5
7
  class Default
6
- def initialize(_theme)
7
- end
8
+ def initialize(_theme); end
8
9
 
9
10
  def call(string)
10
11
  string
@@ -1,20 +1,21 @@
1
- require 'rouge/util'
2
- require 'rouge/token'
3
- require 'rouge/theme'
4
- require 'rouge/themes/gruvbox'
5
- require 'rouge/formatter'
6
- require 'rouge/formatters/terminal256'
7
- require 'rouge/lexer'
8
- require 'rouge/regex_lexer'
9
- require 'rouge/lexers/sql'
1
+ # frozen_string_literal: true
2
+
3
+ require "rouge/util"
4
+ require "rouge/token"
5
+ require "rouge/theme"
6
+ require "rouge/themes/gruvbox"
7
+ require "rouge/formatter"
8
+ require "rouge/formatters/terminal256"
9
+ require "rouge/lexer"
10
+ require "rouge/regex_lexer"
11
+ require "rouge/lexers/sql"
10
12
 
11
13
  module Dry
12
14
  module Monitor
13
15
  module SQL
14
16
  module Colorizers
15
17
  class Rouge
16
- attr_reader :formatter
17
- attr_reader :lexer
18
+ attr_reader :formatter, :lexer
18
19
 
19
20
  def initialize(theme)
20
21
  @formatter = ::Rouge::Formatters::Terminal256.new(theme || ::Rouge::Themes::Gruvbox.new)
@@ -1,6 +1,8 @@
1
- require 'dry-configurable'
2
- require 'dry/core/extensions'
3
- require 'dry/monitor/notifications'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry-configurable"
4
+ require "dry/core/extensions"
5
+ require "dry/monitor/notifications"
4
6
 
5
7
  module Dry
6
8
  module Monitor
@@ -12,27 +14,33 @@ module Dry
12
14
  extend Dry::Configurable
13
15
 
14
16
  register_extension(:default_colorizer) do
15
- require_relative './colorizers/default'
17
+ require_relative "./colorizers/default"
16
18
 
17
- def colorizer
18
- @colorizer ||= Colorizers::Default.new(config.theme)
19
+ module DefaultColorizer
20
+ def colorizer
21
+ @colorizer ||= Colorizers::Default.new(config.theme)
22
+ end
19
23
  end
24
+
25
+ Logger.include(DefaultColorizer)
20
26
  end
21
27
 
22
28
  register_extension(:rouge_colorizer) do
23
- require_relative './colorizers/rouge'
29
+ require_relative "./colorizers/rouge"
24
30
 
25
- def colorizer
26
- @colorizer ||= Colorizers::Rouge.new(config.theme)
31
+ module RougeColorizer
32
+ def colorizer
33
+ @colorizer ||= Colorizers::Rouge.new(config.theme)
34
+ end
27
35
  end
36
+
37
+ Logger.include(RougeColorizer)
28
38
  end
29
39
 
30
- setting :theme, nil
31
- setting :message_template, %( Loaded %s in %sms %s).freeze
40
+ setting :theme
41
+ setting :message_template, default: %( Loaded %s in %sms %s)
32
42
 
33
- attr_reader :config
34
- attr_reader :logger
35
- attr_reader :template
43
+ attr_reader :config, :logger, :template
36
44
 
37
45
  load_extensions(:default_colorizer)
38
46
 
@@ -43,12 +51,10 @@ module Dry
43
51
  end
44
52
 
45
53
  def subscribe(notifications)
46
- notifications.subscribe(:sql) do |time:, name:, query:|
47
- log_query(time, name, query)
48
- end
54
+ notifications.subscribe(:sql) { |params| log_query(**params) }
49
55
  end
50
56
 
51
- def log_query(time, name, query)
57
+ def log_query(time:, name:, query:)
52
58
  logger.info template % [name.inspect, time, colorizer.call(query)]
53
59
  end
54
60
  end
@@ -1,5 +1,7 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Dry
2
4
  module Monitor
3
- VERSION = '0.3.0'.freeze
5
+ VERSION = "0.5.0"
4
6
  end
5
7
  end
data/lib/dry/monitor.rb CHANGED
@@ -1,18 +1,20 @@
1
- require 'dry/monitor/logger'
2
- require 'dry/monitor/notifications'
3
- require 'dry/core/extensions'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/monitor/logger"
4
+ require "dry/monitor/notifications"
5
+ require "dry/core/extensions"
4
6
 
5
7
  module Dry
6
8
  module Monitor
7
9
  extend Dry::Core::Extensions
8
10
 
9
11
  register_extension(:rack) do
10
- require 'rack/utils'
11
- require 'dry/monitor/rack/logger'
12
+ require "rack/utils"
13
+ require "dry/monitor/rack/logger"
12
14
  end
13
15
 
14
16
  register_extension(:sql) do
15
- require 'dry/monitor/sql/logger'
17
+ require "dry/monitor/sql/logger"
16
18
  end
17
19
  end
18
20
  end
data/lib/dry-monitor.rb CHANGED
@@ -1 +1,3 @@
1
- require 'dry/monitor'
1
+ # frozen_string_literal: true
2
+
3
+ require "dry/monitor"
metadata CHANGED
@@ -1,93 +1,85 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dry-monitor
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Piotr Solnica
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-01-29 00:00:00.000000000 Z
11
+ date: 2021-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: dry-equalizer
14
+ name: dry-configurable
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: '0.2'
19
+ version: '0.13'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 0.13.0
20
23
  type: :runtime
21
24
  prerelease: false
22
25
  version_requirements: !ruby/object:Gem::Requirement
23
26
  requirements:
24
27
  - - "~>"
25
28
  - !ruby/object:Gem::Version
26
- version: '0.2'
29
+ version: '0.13'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 0.13.0
27
33
  - !ruby/object:Gem::Dependency
28
- name: dry-configurable
34
+ name: dry-core
29
35
  requirement: !ruby/object:Gem::Requirement
30
36
  requirements:
31
37
  - - "~>"
32
38
  - !ruby/object:Gem::Version
33
39
  version: '0.5'
34
- type: :runtime
35
- prerelease: false
36
- version_requirements: !ruby/object:Gem::Requirement
37
- requirements:
38
- - - "~>"
40
+ - - ">="
39
41
  - !ruby/object:Gem::Version
40
42
  version: '0.5'
41
- - !ruby/object:Gem::Dependency
42
- name: dry-events
43
- requirement: !ruby/object:Gem::Requirement
44
- requirements:
45
- - - "~>"
46
- - !ruby/object:Gem::Version
47
- version: '0.1'
48
43
  type: :runtime
49
44
  prerelease: false
50
45
  version_requirements: !ruby/object:Gem::Requirement
51
46
  requirements:
52
47
  - - "~>"
53
48
  - !ruby/object:Gem::Version
54
- version: '0.1'
49
+ version: '0.5'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: '0.5'
55
53
  - !ruby/object:Gem::Dependency
56
- name: dry-core
54
+ name: dry-events
57
55
  requirement: !ruby/object:Gem::Requirement
58
56
  requirements:
59
57
  - - "~>"
60
58
  - !ruby/object:Gem::Version
61
- version: '0.4'
59
+ version: '0.2'
62
60
  type: :runtime
63
61
  prerelease: false
64
62
  version_requirements: !ruby/object:Gem::Requirement
65
63
  requirements:
66
64
  - - "~>"
67
65
  - !ruby/object:Gem::Version
68
- version: '0.4'
66
+ version: '0.2'
69
67
  - !ruby/object:Gem::Dependency
70
- name: rouge
68
+ name: bundler
71
69
  requirement: !ruby/object:Gem::Requirement
72
70
  requirements:
73
- - - "~>"
74
- - !ruby/object:Gem::Version
75
- version: '2.0'
76
71
  - - ">="
77
72
  - !ruby/object:Gem::Version
78
- version: 2.2.1
73
+ version: '0'
79
74
  type: :development
80
75
  prerelease: false
81
76
  version_requirements: !ruby/object:Gem::Requirement
82
77
  requirements:
83
- - - "~>"
84
- - !ruby/object:Gem::Version
85
- version: '2.0'
86
78
  - - ">="
87
79
  - !ruby/object:Gem::Version
88
- version: 2.2.1
80
+ version: '0'
89
81
  - !ruby/object:Gem::Dependency
90
- name: bundler
82
+ name: rake
91
83
  requirement: !ruby/object:Gem::Requirement
92
84
  requirements:
93
85
  - - ">="
@@ -101,19 +93,25 @@ dependencies:
101
93
  - !ruby/object:Gem::Version
102
94
  version: '0'
103
95
  - !ruby/object:Gem::Dependency
104
- name: rake
96
+ name: rouge
105
97
  requirement: !ruby/object:Gem::Requirement
106
98
  requirements:
99
+ - - "~>"
100
+ - !ruby/object:Gem::Version
101
+ version: '2.0'
107
102
  - - ">="
108
103
  - !ruby/object:Gem::Version
109
- version: '0'
104
+ version: 2.2.1
110
105
  type: :development
111
106
  prerelease: false
112
107
  version_requirements: !ruby/object:Gem::Requirement
113
108
  requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '2.0'
114
112
  - - ">="
115
113
  - !ruby/object:Gem::Version
116
- version: '0'
114
+ version: 2.2.1
117
115
  - !ruby/object:Gem::Dependency
118
116
  name: rspec
119
117
  requirement: !ruby/object:Gem::Requirement
@@ -128,27 +126,20 @@ dependencies:
128
126
  - - ">="
129
127
  - !ruby/object:Gem::Version
130
128
  version: '0'
131
- description:
129
+ description: Monitoring and instrumentation APIs
132
130
  email:
133
131
  - piotr.solnica@gmail.com
134
132
  executables: []
135
133
  extensions: []
136
134
  extra_rdoc_files: []
137
135
  files:
138
- - ".gitignore"
139
- - ".rspec"
140
- - ".rubocop.yml"
141
- - ".rubocop_todo.yml"
142
- - ".travis.yml"
143
136
  - CHANGELOG.md
144
- - CONTRIBUTING.md
145
- - Gemfile
146
137
  - LICENSE
147
138
  - README.md
148
- - Rakefile
149
139
  - dry-monitor.gemspec
150
140
  - lib/dry-monitor.rb
151
141
  - lib/dry/monitor.rb
142
+ - lib/dry/monitor/constants.rb
152
143
  - lib/dry/monitor/logger.rb
153
144
  - lib/dry/monitor/notifications.rb
154
145
  - lib/dry/monitor/rack/logger.rb
@@ -157,17 +148,14 @@ files:
157
148
  - lib/dry/monitor/sql/colorizers/rouge.rb
158
149
  - lib/dry/monitor/sql/logger.rb
159
150
  - lib/dry/monitor/version.rb
160
- - rakelib/rubocop.rake
161
- - spec/integration/instrumentation_spec.rb
162
- - spec/integration/logger_spec.rb
163
- - spec/integration/rack_middleware_spec.rb
164
- - spec/integration/sql_logger_spec.rb
165
- - spec/spec_helper.rb
166
- - spec/test_logs/.gitkeep
167
- homepage: https://github.com/dry-rb/dry-monitor
151
+ homepage: https://dry-rb.org/gems/dry-monitor
168
152
  licenses:
169
153
  - MIT
170
- metadata: {}
154
+ metadata:
155
+ allowed_push_host: https://rubygems.org
156
+ changelog_uri: https://github.com/dry-rb/dry-monitor/blob/master/CHANGELOG.md
157
+ source_code_uri: https://github.com/dry-rb/dry-monitor
158
+ bug_tracker_uri: https://github.com/dry-rb/dry-monitor/issues
171
159
  post_install_message:
172
160
  rdoc_options: []
173
161
  require_paths:
@@ -176,21 +164,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
176
164
  requirements:
177
165
  - - ">="
178
166
  - !ruby/object:Gem::Version
179
- version: '0'
167
+ version: 2.6.0
180
168
  required_rubygems_version: !ruby/object:Gem::Requirement
181
169
  requirements:
182
170
  - - ">="
183
171
  - !ruby/object:Gem::Version
184
172
  version: '0'
185
173
  requirements: []
186
- rubygems_version: 3.0.2
174
+ rubygems_version: 3.1.6
187
175
  signing_key:
188
176
  specification_version: 4
189
177
  summary: Monitoring and instrumentation APIs
190
- test_files:
191
- - spec/integration/instrumentation_spec.rb
192
- - spec/integration/logger_spec.rb
193
- - spec/integration/rack_middleware_spec.rb
194
- - spec/integration/sql_logger_spec.rb
195
- - spec/spec_helper.rb
196
- - spec/test_logs/.gitkeep
178
+ test_files: []
data/.gitignore DELETED
@@ -1,9 +0,0 @@
1
- .DS_Store
2
- coverage
3
- /.bundle
4
- vendor/bundle
5
- bin/
6
- tmp/
7
- .idea/
8
- Gemfile.lock
9
- spec/test_logs/*.log
data/.rspec DELETED
@@ -1,3 +0,0 @@
1
- --color
2
- --require spec_helper
3
- --order random
data/.rubocop.yml DELETED
@@ -1,16 +0,0 @@
1
- # Generated by `rubocop --auto-gen-config`
2
- inherit_from: .rubocop_todo.yml
3
-
4
- Metrics/LineLength:
5
- Max: 100
6
-
7
- Style/Documentation:
8
- Enabled: false
9
-
10
- Lint/HandleExceptions:
11
- Exclude:
12
- - rakelib/*.rake
13
-
14
- Style/FileName:
15
- Exclude:
16
- - lib/dry-logic.rb