whoop 1.0.4 → 1.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a9b6642d169f36ac114748f02515b804646a7981f244475c41fa053456d93c08
4
- data.tar.gz: ca2a36f9da6922d998189ea808bd3976684e3cf2919fb7c4ed9672408591fce7
3
+ metadata.gz: 814754659e61a2179b1a09406e77e18a475ae3a5d7ffed0da3cc53eb1f3ec59f
4
+ data.tar.gz: bb96421ebb0a670af446b4c8312f9f847722576f8c52f1f41240d04974c8569c
5
5
  SHA512:
6
- metadata.gz: eee07b43704595c415ec3eb4e36cf5ea2b9215982d22f7f5f1d0e7e9565c408dbaa4e41f43385c79c8089f1740907c2c21d8a2bcd9b5d74f64f103433774446a
7
- data.tar.gz: 4865c548afe2113e7218ebde457eea291f9152c3bcecae84d684581e4ad9c397b6af965668623d4f581a571062881759d5681a6475cb570f04d9571f224b8eed
6
+ metadata.gz: a49ee4bf201f1239cb3dfbe829af37c4040a3925ada3af4312e1e18d9344803946052bfb1528eacc11580f5fc6e1fde0dfe2a343f2ccf651b47e010fec448b13
7
+ data.tar.gz: ea69570c36ff100d9a0bda28938e3f4ecc234f4a043e7c0426371c30ee7f07bfd5119a778e34bd034f902fbee833356d60bf2752d6b9aa08ee87228a48218381
data/Gemfile.lock CHANGED
@@ -1,9 +1,10 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- whoop (1.0.2)
4
+ whoop (1.2.0)
5
5
  activerecord (>= 6.1.4)
6
6
  activesupport (>= 6.1.4)
7
+ amazing_print
7
8
  anbt-sql-formatter
8
9
  colorize
9
10
  rouge
@@ -11,16 +12,17 @@ PATH
11
12
  GEM
12
13
  remote: https://rubygems.org/
13
14
  specs:
14
- activemodel (7.0.4)
15
- activesupport (= 7.0.4)
16
- activerecord (7.0.4)
17
- activemodel (= 7.0.4)
18
- activesupport (= 7.0.4)
19
- activesupport (7.0.4)
15
+ activemodel (7.0.4.3)
16
+ activesupport (= 7.0.4.3)
17
+ activerecord (7.0.4.3)
18
+ activemodel (= 7.0.4.3)
19
+ activesupport (= 7.0.4.3)
20
+ activesupport (7.0.4.3)
20
21
  concurrent-ruby (~> 1.0, >= 1.0.2)
21
22
  i18n (>= 1.6, < 2)
22
23
  minitest (>= 5.1)
23
24
  tzinfo (~> 2.0)
25
+ amazing_print (1.5.0)
24
26
  anbt-sql-formatter (0.1.0)
25
27
  ast (2.4.2)
26
28
  bump (0.10.0)
@@ -31,25 +33,26 @@ GEM
31
33
  colorize (0.8.1)
32
34
  commander (4.6.0)
33
35
  highline (~> 2.0.0)
34
- concurrent-ruby (1.1.10)
36
+ concurrent-ruby (1.2.2)
35
37
  diff-lcs (1.5.0)
36
38
  docile (1.4.0)
37
39
  highline (2.0.3)
38
40
  i18n (1.12.0)
39
41
  concurrent-ruby (~> 1.0)
40
- json (2.6.2)
42
+ json (2.6.3)
43
+ language_server-protocol (3.17.0.3)
41
44
  magic_frozen_string_literal (1.2.0)
42
45
  method_source (1.0.0)
43
- minitest (5.16.3)
46
+ minitest (5.18.0)
44
47
  parallel (1.22.1)
45
48
  parlour (5.0.0)
46
49
  commander (~> 4.5)
47
50
  parser
48
51
  rainbow (~> 3.0)
49
52
  sorbet-runtime (>= 0.5)
50
- parser (3.1.2.1)
53
+ parser (3.2.2.0)
51
54
  ast (~> 2.4.1)
52
- pry (0.14.1)
55
+ pry (0.14.2)
53
56
  coderay (~> 1.1)
54
57
  method_source (~> 1.0)
55
58
  pry-byebug (3.10.1)
@@ -57,61 +60,63 @@ GEM
57
60
  pry (>= 0.13, < 0.15)
58
61
  rainbow (3.1.1)
59
62
  rake (13.0.6)
60
- regexp_parser (2.5.0)
63
+ rbs (2.8.4)
64
+ regexp_parser (2.8.0)
61
65
  rexml (3.2.5)
62
- rouge (4.0.0)
63
- rspec (3.11.0)
64
- rspec-core (~> 3.11.0)
65
- rspec-expectations (~> 3.11.0)
66
- rspec-mocks (~> 3.11.0)
67
- rspec-core (3.11.0)
68
- rspec-support (~> 3.11.0)
69
- rspec-expectations (3.11.0)
66
+ rouge (4.1.0)
67
+ rspec (3.12.0)
68
+ rspec-core (~> 3.12.0)
69
+ rspec-expectations (~> 3.12.0)
70
+ rspec-mocks (~> 3.12.0)
71
+ rspec-core (3.12.1)
72
+ rspec-support (~> 3.12.0)
73
+ rspec-expectations (3.12.2)
70
74
  diff-lcs (>= 1.2.0, < 2.0)
71
- rspec-support (~> 3.11.0)
72
- rspec-mocks (3.11.1)
75
+ rspec-support (~> 3.12.0)
76
+ rspec-mocks (3.12.5)
73
77
  diff-lcs (>= 1.2.0, < 2.0)
74
- rspec-support (~> 3.11.0)
75
- rspec-support (3.11.0)
76
- rubocop (1.35.1)
78
+ rspec-support (~> 3.12.0)
79
+ rspec-support (3.12.0)
80
+ rubocop (1.48.1)
77
81
  json (~> 2.3)
78
82
  parallel (~> 1.10)
79
- parser (>= 3.1.2.1)
83
+ parser (>= 3.2.0.0)
80
84
  rainbow (>= 2.2.2, < 4.0)
81
85
  regexp_parser (>= 1.8, < 3.0)
82
86
  rexml (>= 3.2.5, < 4.0)
83
- rubocop-ast (>= 1.20.1, < 2.0)
87
+ rubocop-ast (>= 1.26.0, < 2.0)
84
88
  ruby-progressbar (~> 1.7)
85
- unicode-display_width (>= 1.4.0, < 3.0)
86
- rubocop-ast (1.21.0)
87
- parser (>= 3.1.1.0)
88
- rubocop-performance (1.14.3)
89
+ unicode-display_width (>= 2.4.0, < 3.0)
90
+ rubocop-ast (1.28.0)
91
+ parser (>= 3.2.1.0)
92
+ rubocop-performance (1.16.0)
89
93
  rubocop (>= 1.7.0, < 2.0)
90
94
  rubocop-ast (>= 0.4.0)
91
- ruby-progressbar (1.11.0)
92
- simplecov (0.16.1)
95
+ ruby-progressbar (1.13.0)
96
+ simplecov (0.21.2)
93
97
  docile (~> 1.1)
94
- json (>= 1.8, < 3)
95
- simplecov-html (~> 0.10.0)
96
- simplecov-html (0.10.2)
97
- sorbet-runtime (0.5.10455)
98
- sord (4.0.0)
98
+ simplecov-html (~> 0.11)
99
+ simplecov_json_formatter (~> 0.1)
100
+ simplecov-html (0.12.3)
101
+ simplecov_json_formatter (0.1.4)
102
+ sorbet-runtime (0.5.10784)
103
+ sord (5.0.0)
99
104
  commander (~> 4.5)
100
105
  parlour (~> 5.0)
106
+ rbs (~> 2.0)
101
107
  sorbet-runtime
102
108
  yard
103
- standard (1.16.1)
104
- rubocop (= 1.35.1)
105
- rubocop-performance (= 1.14.3)
106
- tzinfo (2.0.5)
109
+ standard (1.26.0)
110
+ language_server-protocol (~> 3.17.0.2)
111
+ rubocop (~> 1.48.1)
112
+ rubocop-performance (~> 1.16.0)
113
+ tzinfo (2.0.6)
107
114
  concurrent-ruby (~> 1.0)
108
- unicode-display_width (2.3.0)
109
- webrick (1.7.0)
110
- yard (0.9.28)
111
- webrick (~> 1.7.0)
115
+ unicode-display_width (2.4.2)
116
+ yard (0.9.34)
112
117
 
113
118
  PLATFORMS
114
- arm64-darwin-21
119
+ arm64-darwin-22
115
120
  x86_64-linux
116
121
 
117
122
  DEPENDENCIES
@@ -127,4 +132,4 @@ DEPENDENCIES
127
132
  whoop!
128
133
 
129
134
  BUNDLED WITH
130
- 2.3.22
135
+ 2.4.9
data/README.md CHANGED
@@ -59,7 +59,7 @@ You can pass any options into the `whoop` method to change the output.
59
59
  - `pattern` - String character to use for the line (default is `-`)
60
60
  - `count` - the number of times to repeat the pattern per line (e.g. 80)
61
61
  - `color` - the color to use for the line (e.g. :red)
62
- - `format` - the format to use for the message (one of `:json`, `:sql`, `:plain`)
62
+ - `format` - the format to use for the message (one of `:json`, `:sql`, `:plain`, `:pretty`)
63
63
  - `caller_depth` - the depth of the caller to use for the source (default: 0)
64
64
  - `explain` - whether to run `EXPLAIN` on the SQL query (default: false)
65
65
  - `context` - a hash of key/value pairs to include in the output
@@ -106,6 +106,23 @@ whoop({hello: "world"}, format: :json, color: false)
106
106
  # ┗--------------------------------------------------------------------------------
107
107
  ```
108
108
 
109
+ ```ruby
110
+ user = User.first # or some object
111
+ whoop(user, format: :pretty)
112
+
113
+ # ┏--------------------------------------------------------------------------------
114
+ # ┆ timestamp: 2022-09-26 14:28:06 -0600
115
+ # ┆ source: /spec/whoop_spec.rb:39
116
+ #
117
+ # User {
118
+ # :id => 1,
119
+ # :name => "Eric",
120
+ # :location => "Utah"
121
+ # }
122
+ #
123
+ # ┗--------------------------------------------------------------------------------
124
+ ```
125
+
109
126
  ```ruby
110
127
  whoop("This message includes context", color: false, context: {user: "Eric", ip_address: "127.0.0.1"})
111
128
 
@@ -0,0 +1,25 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Whoop
4
+ class InstallGenerator < Rails::Generators::Base
5
+ desc "This generator creates an initializer file for the Whoop gem at config/initializers/whoop.rb, with default settings."
6
+
7
+ def install
8
+ file_contents = <<~TEXT
9
+ Whoop.setup do |config|
10
+ config.logger = ActiveSupport::Logger.new("log/debug.log")
11
+ # config.logger = ActiveSupport::Logger.new("log/\#{Rails.env}.log")
12
+ # config.logger = ActiveSupport::Logger.new($stdout)
13
+ # config.logger = nil # uses `puts`
14
+
15
+ config.level = :debug # or :info, :warn, :error
16
+ # config.level = :info
17
+ # config.level = :warn
18
+ # config.level = :error
19
+ end
20
+ TEXT
21
+
22
+ create_file "config/initializers/whoop.rb", file_contents
23
+ end
24
+ end
25
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "amazing_print"
4
+
5
+ module Whoop
6
+ module Formatters
7
+ module PrettyFormatter
8
+ # Format the message using AwesomePrint
9
+ # @param [String] message The object/class/message
10
+ # @return [String] The formatted message
11
+ def self.format(message)
12
+ message.ai
13
+ end
14
+ end
15
+ end
16
+ end
@@ -92,7 +92,7 @@ module Whoop
92
92
  pretty_explain = []
93
93
  pretty_explain += lines.map { |line| " #{line}" }
94
94
  nrows = result.rows.length
95
- rows_label = nrows == 1 ? "row" : "rows"
95
+ rows_label = (nrows == 1) ? "row" : "rows"
96
96
  pretty_explain << "\n(#{nrows} #{rows_label})"
97
97
 
98
98
  pretty_explain.join("\n")
data/lib/whoop/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Whoop
4
- VERSION = "1.0.4"
4
+ VERSION = "1.2.0"
5
5
  end
data/lib/whoop.rb CHANGED
@@ -5,6 +5,7 @@ require "colorize"
5
5
  require "rouge"
6
6
  require_relative "whoop/version"
7
7
  require_relative "whoop/formatters/json_formatter"
8
+ require_relative "whoop/formatters/pretty_formatter"
8
9
  require_relative "whoop/formatters/sql_formatter"
9
10
 
10
11
  # Whoop.setup do |config|
@@ -27,7 +28,7 @@ module Whoop
27
28
 
28
29
  module Main
29
30
  COLORS = %i[black red green yellow blue magenta cyan white light_black light_red light_green light_yellow light_blue light_magenta light_cyan light_white default].freeze
30
- FORMATS = %i[plain json sql].freeze
31
+ FORMATS = %i[plain pretty json sql].freeze
31
32
  PATTERN = "-"
32
33
  COUNT = 80
33
34
  INDENT = "┆"
@@ -39,7 +40,7 @@ module Whoop
39
40
  # @param [String] pattern - the pattern to use for the line (e.g. '-')
40
41
  # @param [Integer] count - the number of times to repeat the pattern per line (e.g. 80)
41
42
  # @param [Symbol] color - the color to use for the line (e.g. :red)
42
- # @param [Symbol] format - the format to use for the message (one of :json, :sql, :plain)
43
+ # @param [Symbol] format - the format to use for the message (one of :json, :sql, :plain, :pretty (default))
43
44
  # @param [Integer] caller_depth - the depth of the caller to use for the source (default: 0)
44
45
  # @param [Boolean] explain - whether to explain the SQL query (default: false)
45
46
  # @param [Hash] context - Any additional context you'd like to include in the log
@@ -48,7 +49,7 @@ module Whoop
48
49
  pattern: PATTERN,
49
50
  count: COUNT,
50
51
  color: :default,
51
- format: :plain,
52
+ format: :pretty,
52
53
  caller_depth: 0,
53
54
  explain: false,
54
55
  context: nil
@@ -147,6 +148,8 @@ module Whoop
147
148
  ->(message) { Whoop::Formatters::JsonFormatter.format(message, colorize: colorize) }
148
149
  when :sql
149
150
  ->(message) { Whoop::Formatters::SqlFormatter.format(message, colorize: colorize, explain: explain) }
151
+ when :pretty
152
+ ->(message) { Whoop::Formatters::PrettyFormatter.format(message) }
150
153
  else
151
154
  ->(message) { message }
152
155
  end
data/sig/whoop.rbs CHANGED
@@ -29,7 +29,7 @@ module Whoop
29
29
  #
30
30
  # _@param_ `color` — - the color to use for the line (e.g. :red)
31
31
  #
32
- # _@param_ `format` — - the format to use for the message (one of :json, :sql, :plain)
32
+ # _@param_ `format` — - the format to use for the message (one of :json, :sql, :plain, :pretty (default))
33
33
  #
34
34
  # _@param_ `caller_depth` — - the depth of the caller to use for the source (default: 0)
35
35
  #
@@ -129,5 +129,19 @@ module Whoop
129
129
  # _@return_ — The formatted SQL query
130
130
  def self.format: (String message, ?colorize: bool) -> String
131
131
  end
132
+
133
+ module PrettyFormatter
134
+ # Format the message using AwesomePrint
135
+ #
136
+ # _@param_ `message` — The object/class/message
137
+ #
138
+ # _@return_ — The formatted message
139
+ def self.format: (String message) -> String
140
+ end
141
+ end
142
+
143
+ class InstallGenerator < Rails::Generators::Base
144
+ # sord omit - no YARD return type given, using untyped
145
+ def install: () -> untyped
132
146
  end
133
147
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: whoop
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Berry
8
- autorequire:
8
+ autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-04-10 00:00:00.000000000 Z
11
+ date: 2023-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -80,6 +80,20 @@ dependencies:
80
80
  - - ">="
81
81
  - !ruby/object:Gem::Version
82
82
  version: '0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: amazing_print
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ">="
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ">="
95
+ - !ruby/object:Gem::Version
96
+ version: '0'
83
97
  - !ruby/object:Gem::Dependency
84
98
  name: magic_frozen_string_literal
85
99
  requirement: !ruby/object:Gem::Requirement
@@ -222,12 +236,13 @@ files:
222
236
  - LICENSE.txt
223
237
  - README.md
224
238
  - Rakefile
239
+ - lib/generators/whoop/install_generator.rb
225
240
  - lib/whoop.rb
226
241
  - lib/whoop/formatters/json_formatter.rb
242
+ - lib/whoop/formatters/pretty_formatter.rb
227
243
  - lib/whoop/formatters/sql_formatter.rb
228
244
  - lib/whoop/version.rb
229
245
  - sig/whoop.rbs
230
- - whoop.gemspec
231
246
  homepage: https://github.com/coderberry/whoop
232
247
  licenses:
233
248
  - MIT
@@ -235,7 +250,7 @@ metadata:
235
250
  homepage_uri: https://github.com/coderberry/whoop
236
251
  source_code_uri: https://github.com/coderberry/whoop
237
252
  changelog_uri: https://github.com/coderberry/whoop
238
- post_install_message:
253
+ post_install_message:
239
254
  rdoc_options: []
240
255
  require_paths:
241
256
  - lib
@@ -250,8 +265,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
265
  - !ruby/object:Gem::Version
251
266
  version: '0'
252
267
  requirements: []
253
- rubygems_version: 3.4.6
254
- signing_key:
268
+ rubygems_version: 3.4.14
269
+ signing_key:
255
270
  specification_version: 4
256
271
  summary: A simple gem to help you whoop your logs into shape.
257
272
  test_files: []
data/whoop.gemspec DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/whoop/version"
4
-
5
- Gem::Specification.new do |spec|
6
- spec.name = "whoop"
7
- spec.version = Whoop::VERSION
8
- spec.authors = ["Eric Berry"]
9
- spec.email = ["eric@berry.sh"]
10
-
11
- spec.summary = "A simple gem to help you whoop your logs into shape."
12
- spec.description = spec.summary
13
- spec.homepage = "https://github.com/coderberry/whoop"
14
- spec.license = "MIT"
15
- spec.required_ruby_version = ">= 2.6.0"
16
-
17
- spec.metadata["homepage_uri"] = spec.homepage
18
- spec.metadata["source_code_uri"] = spec.homepage
19
- spec.metadata["changelog_uri"] = spec.homepage
20
-
21
- # Specify which files should be added to the gem when it is released.
22
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
23
- spec.files = Dir.chdir(__dir__) do
24
- `git ls-files -z`.split("\x0").reject do |f|
25
- (f == __FILE__) || f.match(%r{\A(?:(?:bin|test|spec|features)/|\.(?:git|travis|circleci)|appveyor)})
26
- end
27
- end
28
- spec.bindir = "exe"
29
- spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
30
- spec.require_paths = ["lib"]
31
-
32
- spec.add_dependency "activerecord", ">= 6.1.4"
33
- spec.add_dependency "activesupport", ">= 6.1.4"
34
- spec.add_dependency "anbt-sql-formatter"
35
- spec.add_dependency "colorize"
36
- spec.add_dependency "rouge"
37
-
38
- spec.add_development_dependency "magic_frozen_string_literal"
39
- spec.add_development_dependency "pry-byebug"
40
- spec.add_development_dependency "rspec"
41
- spec.add_development_dependency "rake"
42
- spec.add_development_dependency "standard"
43
- spec.add_development_dependency "bump"
44
- spec.add_development_dependency "sord"
45
- spec.add_development_dependency "simplecov"
46
- spec.add_development_dependency "codecov"
47
- end