waithook 0.4.3 → 0.4.4
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 +4 -4
- data/Gemfile.lock +5 -3
- data/lib/waithook/version.rb +1 -1
- data/lib/waithook.rb +11 -7
- data/tests/server_test.rb +8 -6
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b1713a71f7f6f0af1e0c8a9201553bbc64100d0031b504ed124e314ca36b4d5
|
4
|
+
data.tar.gz: 8864b3ecd7c86acb2f85cd969df9571cfd22160588e41a888db22baeae720931
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1a2936f26693ddb36a68e42f49bc551d191e2f21c95264d0a5dd2038db5c19a407ce88e51f81814e27fcc8ce4129eb96e56a07bb9f7c7fec8ba083d3919f75f6
|
7
|
+
data.tar.gz: 0bbdb879ed861b5ca6f8be53c7448b2b464afc389c6ed4e7a708cd893af9763d87ae8afbc13aaf052ebc80387d1447ffe6c78bf9250406bbaeb89fe222ae6ad1
|
data/Gemfile.lock
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
waithook (0.4.
|
4
|
+
waithook (0.4.4)
|
5
5
|
websocket (~> 1.2)
|
6
6
|
|
7
7
|
GEM
|
@@ -12,8 +12,10 @@ GEM
|
|
12
12
|
ansi (1.5.0)
|
13
13
|
builder (3.3.0)
|
14
14
|
coderay (1.1.3)
|
15
|
-
excon (
|
16
|
-
|
15
|
+
excon (1.2.5)
|
16
|
+
logger
|
17
|
+
logger (1.7.0)
|
18
|
+
minitest (5.25.5)
|
17
19
|
minitest-reporters (1.7.1)
|
18
20
|
ansi
|
19
21
|
builder
|
data/lib/waithook/version.rb
CHANGED
data/lib/waithook.rb
CHANGED
@@ -153,7 +153,8 @@ class Waithook
|
|
153
153
|
webhook = Webhook.new(
|
154
154
|
data,
|
155
155
|
logger: logger,
|
156
|
-
forward_options: (options[:forward_options] || {}).merge(@options[:forward_options] || {})
|
156
|
+
forward_options: (options[:forward_options] || {}).merge(@options[:forward_options] || {}),
|
157
|
+
enable_colors: options.key?(:enable_colors) ? options.key?(:enable_colors) : true
|
157
158
|
)
|
158
159
|
if @filter && @filter.call(webhook) || !@filter
|
159
160
|
@messages << webhook
|
@@ -188,7 +189,7 @@ class Waithook
|
|
188
189
|
# Raw message from waithook server
|
189
190
|
attr_reader :message
|
190
191
|
|
191
|
-
def initialize(payload, logger: nil, forward_options: {})
|
192
|
+
def initialize(payload, logger: nil, forward_options: {}, enable_colors: true)
|
192
193
|
@message = payload
|
193
194
|
data = JSON.parse(@message)
|
194
195
|
@url = data['url']
|
@@ -197,6 +198,7 @@ class Waithook
|
|
197
198
|
@method = data['method']
|
198
199
|
@logger = logger
|
199
200
|
@forward_options = forward_options
|
201
|
+
@enable_colors = enable_colors
|
200
202
|
end
|
201
203
|
|
202
204
|
def pretty_print(pp_arg = nil, *args)
|
@@ -214,11 +216,13 @@ class Waithook
|
|
214
216
|
data_without_body = JSON.parse(@message)
|
215
217
|
data_without_body.delete('body')
|
216
218
|
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
219
|
+
if @enable_colors
|
220
|
+
begin
|
221
|
+
require 'coderay'
|
222
|
+
pretty_body = CodeRay.scan(pretty_body, :json).term
|
223
|
+
rescue => error
|
224
|
+
@logger&.debug("Error while trying to use CodeRay: #{error.message}")
|
225
|
+
end
|
222
226
|
end
|
223
227
|
return "#{JSON.pretty_generate(data_without_body)}\nBody:\n#{pretty_body}"
|
224
228
|
rescue JSON::ParserError => error
|
data/tests/server_test.rb
CHANGED
@@ -71,9 +71,10 @@ describe "Server" do
|
|
71
71
|
|
72
72
|
assert_includes(response.body, "<html lang='en'>")
|
73
73
|
assert_equal({
|
74
|
-
"
|
75
|
-
"
|
76
|
-
"Content-
|
74
|
+
"Content-Encoding" => "",
|
75
|
+
"Connection" => "close",
|
76
|
+
"Content-Length" => response.headers["Content-Length"],
|
77
|
+
"Content-Type" => "text/html"
|
77
78
|
}, response.headers)
|
78
79
|
end
|
79
80
|
|
@@ -82,9 +83,10 @@ describe "Server" do
|
|
82
83
|
|
83
84
|
assert_includes(response.body, "function")
|
84
85
|
assert_equal({
|
85
|
-
"
|
86
|
-
"
|
87
|
-
"Content-
|
86
|
+
"Content-Encoding" => "",
|
87
|
+
"Connection" => "close",
|
88
|
+
"Content-Length" => response.headers["Content-Length"],
|
89
|
+
"Content-Type" => "application/javascript; charset=utf-8"
|
88
90
|
}, response.headers)
|
89
91
|
end
|
90
92
|
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: waithook
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Pavel Evstigneev
|
8
8
|
bindir: bin
|
9
9
|
cert_chain: []
|
10
|
-
date: 2025-
|
10
|
+
date: 2025-04-05 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
12
|
- !ruby/object:Gem::Dependency
|
13
13
|
name: websocket
|