whoop 1.1.0 → 1.2.0

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: 81bf8fe803a7a41184c6bf4600abc8059665bbc040d621b3cc39235915d0c80a
4
- data.tar.gz: 54f408ce9613144520e6b318af06353d61e997a3891e4c315e712da1b6208159
3
+ metadata.gz: 814754659e61a2179b1a09406e77e18a475ae3a5d7ffed0da3cc53eb1f3ec59f
4
+ data.tar.gz: bb96421ebb0a670af446b4c8312f9f847722576f8c52f1f41240d04974c8569c
5
5
  SHA512:
6
- metadata.gz: b6be592483ea7056091c04733bba3d5c6642f1b28aa52ef2837d07db13c8c555157fce39effb6055c2c3473c2d536db546eebb52e001fcff81837641c02fe5fe
7
- data.tar.gz: fbad092eb0aca584c4668df1b1682d948d6b67104e14763b3f884019efdf1ba79b6ee6b2c51290defc9dbee4f4c41d01147c5f88c20c2eda27424d21e96816ae
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.1.0)
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
@@ -21,6 +22,7 @@ GEM
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)
@@ -114,6 +116,7 @@ GEM
114
116
  yard (0.9.34)
115
117
 
116
118
  PLATFORMS
119
+ arm64-darwin-22
117
120
  x86_64-linux
118
121
 
119
122
  DEPENDENCIES
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
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module Whoop
2
4
  class InstallGenerator < Rails::Generators::Base
3
5
  desc "This generator creates an initializer file for the Whoop gem at config/initializers/whoop.rb, with default settings."
@@ -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
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.1.0"
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.1.0
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-18 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
@@ -225,10 +239,10 @@ files:
225
239
  - lib/generators/whoop/install_generator.rb
226
240
  - lib/whoop.rb
227
241
  - lib/whoop/formatters/json_formatter.rb
242
+ - lib/whoop/formatters/pretty_formatter.rb
228
243
  - lib/whoop/formatters/sql_formatter.rb
229
244
  - lib/whoop/version.rb
230
245
  - sig/whoop.rbs
231
- - whoop.gemspec
232
246
  homepage: https://github.com/coderberry/whoop
233
247
  licenses:
234
248
  - MIT
@@ -236,7 +250,7 @@ metadata:
236
250
  homepage_uri: https://github.com/coderberry/whoop
237
251
  source_code_uri: https://github.com/coderberry/whoop
238
252
  changelog_uri: https://github.com/coderberry/whoop
239
- post_install_message:
253
+ post_install_message:
240
254
  rdoc_options: []
241
255
  require_paths:
242
256
  - lib
@@ -251,8 +265,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
251
265
  - !ruby/object:Gem::Version
252
266
  version: '0'
253
267
  requirements: []
254
- rubygems_version: 3.4.6
255
- signing_key:
268
+ rubygems_version: 3.4.14
269
+ signing_key:
256
270
  specification_version: 4
257
271
  summary: A simple gem to help you whoop your logs into shape.
258
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