whoop 0.1.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +0 -6
- data/Gemfile.lock +53 -7
- data/README.md +48 -4
- data/cc-test-reporter +0 -0
- data/lib/whoop/formatters/json_formatter.rb +22 -0
- data/lib/whoop/formatters/sql_formatter.rb +30 -0
- data/lib/whoop/version.rb +1 -1
- data/lib/whoop.rb +132 -2
- data/sig/whoop.rbs +107 -3
- data/whoop.gemspec +12 -5
- metadata +160 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 83de2300eaec2004c4bc867fef14a91689222018eee43b12fab6b9a29d425e5a
|
4
|
+
data.tar.gz: 0c3c9b1d21fede7bccf827a73e8c6c3d11b6ddeb6837a4444d664687c03583f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65ad2d5801a70c8d1dec7d7291bfa0c1fef3d2d181e6a1abb75ab41a8e9dd3e0b3550a2a51ddc58880c541838c2b6f603532a134bbbfe8ee633e66103aef0cbb
|
7
|
+
data.tar.gz: 3a1662b1192c5d1828ff8a7cb7bdf5914b4e4fc1313dd23ccf38e9460cd5c8e8187e1c6a3fe695c2e3552ef04b654cb3effdc28794731f12364c3c078c25772e
|
data/Gemfile
CHANGED
@@ -4,9 +4,3 @@ source "https://rubygems.org"
|
|
4
4
|
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
|
5
5
|
|
6
6
|
gemspec
|
7
|
-
|
8
|
-
gem "rspec", "~> 3.0" # minitest provides a complete suite of testing facilities supporting TDD, BDD, mocking, and benchmarking
|
9
|
-
gem "organize_gemfile" # Organize your Gemfile with annotations
|
10
|
-
gem "rake", "~> 13.0" # Rake is a Make-like program implemented in Ruby
|
11
|
-
gem "standard", "~> 1.3" # Ruby Style Guide, with linter & automatic code fixer
|
12
|
-
gem "bump", "~> 0.6" # Bump is a command line tool to help you version your Ruby projects
|
data/Gemfile.lock
CHANGED
@@ -1,23 +1,56 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
whoop (
|
4
|
+
whoop (1.0.0)
|
5
|
+
activesupport
|
6
|
+
anbt-sql-formatter
|
7
|
+
colorize
|
8
|
+
rouge
|
5
9
|
|
6
10
|
GEM
|
7
11
|
remote: https://rubygems.org/
|
8
12
|
specs:
|
13
|
+
activesupport (7.0.4)
|
14
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
15
|
+
i18n (>= 1.6, < 2)
|
16
|
+
minitest (>= 5.1)
|
17
|
+
tzinfo (~> 2.0)
|
18
|
+
anbt-sql-formatter (0.1.0)
|
9
19
|
ast (2.4.2)
|
10
20
|
bump (0.10.0)
|
21
|
+
byebug (11.1.3)
|
22
|
+
coderay (1.1.3)
|
23
|
+
colorize (0.8.1)
|
24
|
+
commander (4.6.0)
|
25
|
+
highline (~> 2.0.0)
|
26
|
+
concurrent-ruby (1.1.10)
|
11
27
|
diff-lcs (1.5.0)
|
28
|
+
highline (2.0.3)
|
29
|
+
i18n (1.12.0)
|
30
|
+
concurrent-ruby (~> 1.0)
|
12
31
|
json (2.6.2)
|
13
|
-
|
32
|
+
magic_frozen_string_literal (1.2.0)
|
33
|
+
method_source (1.0.0)
|
34
|
+
minitest (5.16.3)
|
14
35
|
parallel (1.22.1)
|
36
|
+
parlour (5.0.0)
|
37
|
+
commander (~> 4.5)
|
38
|
+
parser
|
39
|
+
rainbow (~> 3.0)
|
40
|
+
sorbet-runtime (>= 0.5)
|
15
41
|
parser (3.1.2.1)
|
16
42
|
ast (~> 2.4.1)
|
43
|
+
pry (0.14.1)
|
44
|
+
coderay (~> 1.1)
|
45
|
+
method_source (~> 1.0)
|
46
|
+
pry-byebug (3.10.1)
|
47
|
+
byebug (~> 11.0)
|
48
|
+
pry (>= 0.13, < 0.15)
|
17
49
|
rainbow (3.1.1)
|
18
50
|
rake (13.0.6)
|
19
51
|
regexp_parser (2.5.0)
|
20
52
|
rexml (3.2.5)
|
53
|
+
rouge (4.0.0)
|
21
54
|
rspec (3.11.0)
|
22
55
|
rspec-core (~> 3.11.0)
|
23
56
|
rspec-expectations (~> 3.11.0)
|
@@ -47,20 +80,33 @@ GEM
|
|
47
80
|
rubocop (>= 1.7.0, < 2.0)
|
48
81
|
rubocop-ast (>= 0.4.0)
|
49
82
|
ruby-progressbar (1.11.0)
|
83
|
+
sorbet-runtime (0.5.10455)
|
84
|
+
sord (4.0.0)
|
85
|
+
commander (~> 4.5)
|
86
|
+
parlour (~> 5.0)
|
87
|
+
sorbet-runtime
|
88
|
+
yard
|
50
89
|
standard (1.16.1)
|
51
90
|
rubocop (= 1.35.1)
|
52
91
|
rubocop-performance (= 1.14.3)
|
92
|
+
tzinfo (2.0.5)
|
93
|
+
concurrent-ruby (~> 1.0)
|
53
94
|
unicode-display_width (2.3.0)
|
95
|
+
webrick (1.7.0)
|
96
|
+
yard (0.9.28)
|
97
|
+
webrick (~> 1.7.0)
|
54
98
|
|
55
99
|
PLATFORMS
|
56
100
|
arm64-darwin-21
|
57
101
|
|
58
102
|
DEPENDENCIES
|
59
|
-
bump
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
103
|
+
bump
|
104
|
+
magic_frozen_string_literal
|
105
|
+
pry-byebug
|
106
|
+
rake
|
107
|
+
rspec
|
108
|
+
sord
|
109
|
+
standard
|
64
110
|
whoop!
|
65
111
|
|
66
112
|
BUNDLED WITH
|
data/README.md
CHANGED
@@ -1,8 +1,17 @@
|
|
1
1
|
# Whoop
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
[![Gem Version](https://badge.fury.io/rb/whoop.svg)](https://badge.fury.io/rb/whoop)
|
4
|
+
[![Maintainability](https://api.codeclimate.com/v1/badges/1ffd27fe59383a4ff52b/maintainability)](https://codeclimate.com/github/coderberry/whoop/maintainability)
|
5
|
+
[![Test Coverage](https://api.codeclimate.com/v1/badges/1ffd27fe59383a4ff52b/test_coverage)](https://codeclimate.com/github/coderberry/whoop/test_coverage)
|
6
|
+
[![Tests](https://github.com/coderberry/whoop/actions/workflows/tests.yml/badge.svg)](https://github.com/coderberry/whoop/actions/workflows/tests.yml)
|
7
|
+
[![CodeQL](https://github.com/coderberry/whoop/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/coderberry/whoop/actions/workflows/codeql-analysis.yml)
|
8
|
+
[![StandardRB](https://github.com/coderberry/whoop/actions/workflows/standardrb.yml/badge.svg)](https://github.com/coderberry/whoop/actions/workflows/standardrb.yml)
|
9
|
+
[![GEM Version](https://img.shields.io/gem/v/whoop?color=168AFE&include_prereleases&logo=ruby&logoColor=FE1616)](https://rubygems.org/gems/whoop)
|
10
|
+
[![GEM Downloads](https://img.shields.io/gem/dt/whoop?color=168AFE&logo=ruby&logoColor=FE1616)](https://rubygems.org/gems/whoop)
|
11
|
+
[![Ruby Style](https://img.shields.io/badge/style-standard-168AFE?logo=ruby&logoColor=FE1616)](https://github.com/testdouble/standard)
|
12
|
+
[![Twitter Follow](https://img.shields.io/twitter/follow/coderberry?logo=twitter&style=social)](https://twitter.com/coderberry)
|
13
|
+
|
14
|
+
Whoop is a Ruby logging library with built-in formatting and colorization.
|
6
15
|
|
7
16
|
## Installation
|
8
17
|
|
@@ -14,9 +23,38 @@ If bundler is not being used to manage dependencies, install the gem by executin
|
|
14
23
|
|
15
24
|
$ gem install whoop
|
16
25
|
|
26
|
+
## Configuration
|
27
|
+
|
28
|
+
You can configure the gem for you Rails app by adding an an initializer:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
# config/initializers/whoop.rb
|
32
|
+
Whoop.setup do |config|
|
33
|
+
config.logger = ActiveSupport::Logger.new("log/debug.log")
|
34
|
+
# config.logger = ActiveSupport::Logger.new("log/#{Rails.env}.log")
|
35
|
+
# config.logger = ActiveSupport::Logger.new($stdout)
|
36
|
+
# config.logger = nil # uses `puts`
|
37
|
+
|
38
|
+
config.level = :debug
|
39
|
+
# config.level = :info
|
40
|
+
# config.level = :warn
|
41
|
+
# config.level = :error
|
42
|
+
end
|
43
|
+
```
|
44
|
+
|
17
45
|
## Usage
|
18
46
|
|
19
|
-
|
47
|
+
The `whoop` method is accessible from any object. See specs for more examples.
|
48
|
+
|
49
|
+
```ruby
|
50
|
+
whoop "Hello, World!"
|
51
|
+
```
|
52
|
+
|
53
|
+
### Formatters
|
54
|
+
TODO
|
55
|
+
|
56
|
+
### Colors
|
57
|
+
TODO
|
20
58
|
|
21
59
|
## Development
|
22
60
|
|
@@ -35,3 +73,9 @@ The gem is available as open source under the terms of the [MIT License](https:/
|
|
35
73
|
## Code of Conduct
|
36
74
|
|
37
75
|
Everyone interacting in the Whoop project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/whoop/blob/main/CODE_OF_CONDUCT.md).
|
76
|
+
|
77
|
+
## Attribution
|
78
|
+
|
79
|
+
This project is maintained by [Eric Berry](https://linktr.ee/coderberry).
|
80
|
+
|
81
|
+
This gem is based on the [wrapped_print](https://github.com/igorkasyanchuk/wrapped_print) gem by [Igor Kasyanchuk](https://www.railsjazz.com/).
|
data/cc-test-reporter
ADDED
Binary file
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
module Whoop
|
6
|
+
module Formatters
|
7
|
+
module JsonFormatter
|
8
|
+
# Format the SQL query
|
9
|
+
# @param [String] message The SQL query
|
10
|
+
# @param [Boolean] colorize - colorize the SQL query (default: false)
|
11
|
+
# @return [String] The formatted SQL query
|
12
|
+
def self.format(message, colorize: false)
|
13
|
+
pretty_json = JSON.pretty_generate(message)
|
14
|
+
return pretty_json unless colorize
|
15
|
+
|
16
|
+
formatter = Rouge::Formatters::TerminalTruecolor.new
|
17
|
+
lexer = Rouge::Lexers::JSON.new
|
18
|
+
formatter.format(lexer.lex(pretty_json))
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "anbt-sql-formatter/formatter"
|
4
|
+
|
5
|
+
module Whoop
|
6
|
+
module Formatters
|
7
|
+
module SqlFormatter
|
8
|
+
# Format the SQL query
|
9
|
+
# @param [String] sql The SQL query
|
10
|
+
# @param [Boolean] colorize - colorize the SQL query (default: false)
|
11
|
+
# @param [Boolean] explain - also run `EXPLAIN` on the query (default: false)
|
12
|
+
# @return [String] The formatted SQL query
|
13
|
+
def self.format(sql, colorize: false, explain: false)
|
14
|
+
pretty_sql = generate_pretty_sql(sql)
|
15
|
+
return pretty_sql unless colorize
|
16
|
+
|
17
|
+
formatter = Rouge::Formatters::TerminalTruecolor.new
|
18
|
+
lexer = Rouge::Lexers::SQL.new
|
19
|
+
formatter.format(lexer.lex(pretty_sql))
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.generate_pretty_sql(sql)
|
23
|
+
rule = AnbtSql::Rule.new
|
24
|
+
rule.indent_string = " "
|
25
|
+
formatter = AnbtSql::Formatter.new(rule)
|
26
|
+
formatter.format(sql.dup)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/whoop/version.rb
CHANGED
data/lib/whoop.rb
CHANGED
@@ -1,8 +1,138 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require "active_support"
|
4
|
+
require "colorize"
|
5
|
+
require "rouge"
|
3
6
|
require_relative "whoop/version"
|
7
|
+
require_relative "whoop/formatters/json_formatter"
|
8
|
+
require_relative "whoop/formatters/sql_formatter"
|
9
|
+
|
10
|
+
# Whoop.setup do |config|
|
11
|
+
# config.logger = ActiveSupport::Logger.new("#{Rails.root}/log/debug.log")
|
12
|
+
# config.level = :debug
|
13
|
+
# end
|
4
14
|
|
5
15
|
module Whoop
|
6
|
-
|
7
|
-
|
16
|
+
mattr_accessor :logger
|
17
|
+
@@logger = ActiveSupport::Logger.new($stdout)
|
18
|
+
|
19
|
+
mattr_accessor :level
|
20
|
+
@@level = :debug
|
21
|
+
|
22
|
+
def self.setup
|
23
|
+
yield(self)
|
24
|
+
end
|
25
|
+
|
26
|
+
module Main
|
27
|
+
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
|
28
|
+
FORMATS = %i[plain json sql].freeze
|
29
|
+
PATTERN = "-"
|
30
|
+
COUNT = 80
|
31
|
+
|
32
|
+
# Log the message to the logger
|
33
|
+
# @param [String] label (optional) - the label or object to log
|
34
|
+
# @param [String] pattern - the pattern to use for the line (e.g. '-')
|
35
|
+
# @param [Integer] count - the number of times to repeat the pattern per line (e.g. 80)
|
36
|
+
# @param [Symbol] color - the color to use for the line (e.g. :red)
|
37
|
+
# @param [Symbol] format - the format to use for the message (one of :json, :sql, :plain)
|
38
|
+
# @param [Integer] caller_depth - the depth of the caller to use for the source (default: 0)
|
39
|
+
# @param [Boolean] explain - whether to explain the SQL query (default: false)
|
40
|
+
def whoop(label = nil, pattern: PATTERN, count: COUNT, color: :default, format: :plain, caller_depth: 0, explain: false)
|
41
|
+
logger_method = detect_logger_method
|
42
|
+
color_method = detect_color_method(color)
|
43
|
+
formatter_method = detect_formatter_method(format, colorize: color.present?, explain: explain)
|
44
|
+
|
45
|
+
line = pattern * count
|
46
|
+
caller_path = clean_caller_path(caller[caller_depth])
|
47
|
+
caller_path_line = ["source:".colorize(:light_black).underline, caller_path].join(" ")
|
48
|
+
timestamp_line = ["timestamp:".colorize(:light_black).underline, Time.now].join(" ")
|
49
|
+
|
50
|
+
if block_given?
|
51
|
+
result = yield
|
52
|
+
top_line =
|
53
|
+
if label.present? && label.is_a?(String)
|
54
|
+
wrapped_line(label.to_s, pattern: pattern, count: count)
|
55
|
+
else
|
56
|
+
pattern * count
|
57
|
+
end
|
58
|
+
result.tap do
|
59
|
+
logger_method.call color_method.call "\n\n#{top_line}"
|
60
|
+
logger_method.call timestamp_line
|
61
|
+
logger_method.call caller_path_line
|
62
|
+
logger_method.call ""
|
63
|
+
logger_method.call formatter_method.call(result)
|
64
|
+
logger_method.call color_method.call "#{line}\n\n"
|
65
|
+
end
|
66
|
+
else
|
67
|
+
tap do
|
68
|
+
logger_method.call color_method.call "\n\n#{line}"
|
69
|
+
logger_method.call timestamp_line
|
70
|
+
logger_method.call caller_path_line
|
71
|
+
logger_method.call ""
|
72
|
+
logger_method.call formatter_method.call(label)
|
73
|
+
logger_method.call color_method.call "#{line}\n\n"
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
private
|
79
|
+
|
80
|
+
# Remove the Rails.root from the caller path
|
81
|
+
# @param [String] caller_path - path of the the file and line number of the caller
|
82
|
+
# @return [String]
|
83
|
+
def clean_caller_path(caller_path)
|
84
|
+
return caller_path unless defined?(Rails)
|
85
|
+
|
86
|
+
caller_path.gsub(Rails.root.to_s, "")
|
87
|
+
end
|
88
|
+
|
89
|
+
# Detect the colorize method to use
|
90
|
+
# @param [Symbol] color
|
91
|
+
# @return [Method] the colorize method
|
92
|
+
def detect_color_method(color)
|
93
|
+
return ->(message) { message } unless color
|
94
|
+
|
95
|
+
color = color.to_sym
|
96
|
+
raise ArgumentError, "Invalid color: #{color}. Must be one of #{COLORS}" unless COLORS.include?(color)
|
97
|
+
|
98
|
+
->(message) { message.colorize(color) }
|
99
|
+
end
|
100
|
+
|
101
|
+
# Detect the logger method to use
|
102
|
+
# @return [Method] logger method
|
103
|
+
def detect_logger_method
|
104
|
+
if Whoop.logger.respond_to?(Whoop.level)
|
105
|
+
Whoop.logger.method(Whoop.level)
|
106
|
+
else
|
107
|
+
method(:puts)
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
# Return the format method to use
|
112
|
+
# @param [Symbol] format
|
113
|
+
# @return [Method] format method
|
114
|
+
def detect_formatter_method(format, colorize: false, explain: false)
|
115
|
+
case format.to_sym
|
116
|
+
when :json
|
117
|
+
->(message) { Whoop::Formatters::JsonFormatter.format(message, colorize: colorize) }
|
118
|
+
when :sql
|
119
|
+
->(message) { Whoop::Formatters::SqlFormatter.format(message, colorize: colorize, explain: explain) }
|
120
|
+
else
|
121
|
+
->(message) { message }
|
122
|
+
end
|
123
|
+
end
|
124
|
+
|
125
|
+
# Return the line with the label centered in it
|
126
|
+
# @param [String] label
|
127
|
+
# @param [Integer] count
|
128
|
+
# @param [String] pattern
|
129
|
+
# @return [String]
|
130
|
+
def wrapped_line(label, count: COUNT, pattern: PATTERN)
|
131
|
+
line_part_length = [((count - label.length) / 2.0).to_i, 5].max
|
132
|
+
line_part = pattern * line_part_length
|
133
|
+
[line_part, label, line_part].join(" ")
|
134
|
+
end
|
135
|
+
end
|
8
136
|
end
|
137
|
+
|
138
|
+
Object.send :include, Whoop::Main
|
data/sig/whoop.rbs
CHANGED
@@ -1,4 +1,108 @@
|
|
1
|
+
# Whoop.setup do |config|
|
2
|
+
# config.logger = ActiveSupport::Logger.new("#{Rails.root}/log/debug.log")
|
3
|
+
# config.level = :debug
|
4
|
+
# end
|
1
5
|
module Whoop
|
2
|
-
VERSION:
|
3
|
-
|
4
|
-
|
6
|
+
VERSION: untyped
|
7
|
+
|
8
|
+
# sord omit - no YARD return type given, using untyped
|
9
|
+
def self.setup: () ?{ (Whoop _self) -> void } -> untyped
|
10
|
+
|
11
|
+
module Main
|
12
|
+
COLORS: untyped
|
13
|
+
FORMATS: untyped
|
14
|
+
PATTERN: untyped
|
15
|
+
COUNT: untyped
|
16
|
+
|
17
|
+
# sord omit - no YARD return type given, using untyped
|
18
|
+
# Log the message to the logger
|
19
|
+
#
|
20
|
+
# _@param_ `label` — (optional) - the label or object to log
|
21
|
+
#
|
22
|
+
# _@param_ `pattern` — - the pattern to use for the line (e.g. '-')
|
23
|
+
#
|
24
|
+
# _@param_ `count` — - the number of times to repeat the pattern per line (e.g. 80)
|
25
|
+
#
|
26
|
+
# _@param_ `color` — - the color to use for the line (e.g. :red)
|
27
|
+
#
|
28
|
+
# _@param_ `format` — - the format to use for the message (one of :json, :sql, :plain)
|
29
|
+
#
|
30
|
+
# _@param_ `caller_depth` — - the depth of the caller to use for the source (default: 0)
|
31
|
+
#
|
32
|
+
# _@param_ `explain` — - whether to explain the SQL query (default: false)
|
33
|
+
def whoop: (
|
34
|
+
?String? label,
|
35
|
+
?pattern: String,
|
36
|
+
?count: Integer,
|
37
|
+
?color: Symbol,
|
38
|
+
?format: Symbol,
|
39
|
+
?caller_depth: Integer,
|
40
|
+
?explain: bool
|
41
|
+
) -> untyped
|
42
|
+
|
43
|
+
# Remove the Rails.root from the caller path
|
44
|
+
#
|
45
|
+
# _@param_ `caller_path` — - path of the the file and line number of the caller
|
46
|
+
def clean_caller_path: (String caller_path) -> String
|
47
|
+
|
48
|
+
# Detect the colorize method to use
|
49
|
+
#
|
50
|
+
# _@param_ `color`
|
51
|
+
#
|
52
|
+
# _@return_ — the colorize method
|
53
|
+
def detect_color_method: (Symbol color) -> Method
|
54
|
+
|
55
|
+
# Detect the logger method to use
|
56
|
+
#
|
57
|
+
# _@return_ — logger method
|
58
|
+
def detect_logger_method: () -> Method
|
59
|
+
|
60
|
+
# sord omit - no YARD type given for "colorize:", using untyped
|
61
|
+
# sord omit - no YARD type given for "explain:", using untyped
|
62
|
+
# Return the format method to use
|
63
|
+
#
|
64
|
+
# _@param_ `format`
|
65
|
+
#
|
66
|
+
# _@return_ — format method
|
67
|
+
def detect_formatter_method: (Symbol format, ?colorize: untyped, ?explain: untyped) -> Method
|
68
|
+
|
69
|
+
# Return the line with the label centered in it
|
70
|
+
#
|
71
|
+
# _@param_ `label`
|
72
|
+
#
|
73
|
+
# _@param_ `count`
|
74
|
+
#
|
75
|
+
# _@param_ `pattern`
|
76
|
+
def wrapped_line: (String label, ?count: Integer, ?pattern: String) -> String
|
77
|
+
end
|
78
|
+
|
79
|
+
module Formatters
|
80
|
+
module SqlFormatter
|
81
|
+
# Format the SQL query
|
82
|
+
#
|
83
|
+
# _@param_ `sql` — The SQL query
|
84
|
+
#
|
85
|
+
# _@param_ `colorize` — - colorize the SQL query (default: false)
|
86
|
+
#
|
87
|
+
# _@param_ `explain` — - also run `EXPLAIN` on the query (default: false)
|
88
|
+
#
|
89
|
+
# _@return_ — The formatted SQL query
|
90
|
+
def self.format: (String sql, ?colorize: bool, ?explain: bool) -> String
|
91
|
+
|
92
|
+
# sord omit - no YARD type given for "sql", using untyped
|
93
|
+
# sord omit - no YARD return type given, using untyped
|
94
|
+
def self.generate_pretty_sql: (untyped sql) -> untyped
|
95
|
+
end
|
96
|
+
|
97
|
+
module JsonFormatter
|
98
|
+
# Format the SQL query
|
99
|
+
#
|
100
|
+
# _@param_ `message` — The SQL query
|
101
|
+
#
|
102
|
+
# _@param_ `colorize` — - colorize the SQL query (default: false)
|
103
|
+
#
|
104
|
+
# _@return_ — The formatted SQL query
|
105
|
+
def self.format: (String message, ?colorize: bool) -> String
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
data/whoop.gemspec
CHANGED
@@ -31,9 +31,16 @@ Gem::Specification.new do |spec|
|
|
31
31
|
spec.executables = spec.files.grep(%r{\Aexe/}) { |f| File.basename(f) }
|
32
32
|
spec.require_paths = ["lib"]
|
33
33
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
34
|
+
spec.add_dependency "activesupport"
|
35
|
+
spec.add_dependency "anbt-sql-formatter"
|
36
|
+
spec.add_dependency "colorize"
|
37
|
+
spec.add_dependency "rouge"
|
38
|
+
|
39
|
+
spec.add_development_dependency "magic_frozen_string_literal"
|
40
|
+
spec.add_development_dependency "pry-byebug"
|
41
|
+
spec.add_development_dependency "rspec"
|
42
|
+
spec.add_development_dependency "rake"
|
43
|
+
spec.add_development_dependency "standard"
|
44
|
+
spec.add_development_dependency "bump"
|
45
|
+
spec.add_development_dependency "sord"
|
39
46
|
end
|
metadata
CHANGED
@@ -1,15 +1,169 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: whoop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eric Berry
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-09-
|
12
|
-
dependencies:
|
11
|
+
date: 2022-09-23 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: activesupport
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: anbt-sql-formatter
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: colorize
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: rouge
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: magic_frozen_string_literal
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: pry-byebug
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :development
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: rspec
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :development
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rake
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - ">="
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - ">="
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '0'
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: standard
|
127
|
+
requirement: !ruby/object:Gem::Requirement
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '0'
|
132
|
+
type: :development
|
133
|
+
prerelease: false
|
134
|
+
version_requirements: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: bump
|
141
|
+
requirement: !ruby/object:Gem::Requirement
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
version: '0'
|
146
|
+
type: :development
|
147
|
+
prerelease: false
|
148
|
+
version_requirements: !ruby/object:Gem::Requirement
|
149
|
+
requirements:
|
150
|
+
- - ">="
|
151
|
+
- !ruby/object:Gem::Version
|
152
|
+
version: '0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: sord
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - ">="
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: '0'
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - ">="
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: '0'
|
13
167
|
description: A simple gem to help you whoop your logs into shape.
|
14
168
|
email:
|
15
169
|
- eric@berry.sh
|
@@ -26,7 +180,10 @@ files:
|
|
26
180
|
- LICENSE.txt
|
27
181
|
- README.md
|
28
182
|
- Rakefile
|
183
|
+
- cc-test-reporter
|
29
184
|
- lib/whoop.rb
|
185
|
+
- lib/whoop/formatters/json_formatter.rb
|
186
|
+
- lib/whoop/formatters/sql_formatter.rb
|
30
187
|
- lib/whoop/version.rb
|
31
188
|
- sig/whoop.rbs
|
32
189
|
- whoop.gemspec
|