shog 0.1.1 → 0.1.2
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/docs/images/plain.png +0 -0
- data/docs/images/shogged.png +0 -0
- data/lib/shog.rb +1 -0
- data/lib/shog/extensions.rb +17 -0
- data/lib/shog/formatter.rb +4 -4
- data/lib/shog/formatters/requests.rb +3 -6
- data/lib/shog/version.rb +1 -1
- data/spec/lib/shog/formatter_spec.rb +4 -0
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e10f5ef853af5fcbf4cb08c8ad1c9ea3bd2e052b
|
4
|
+
data.tar.gz: 7959b91a38b1127f3d3334f57c9a60b02588c48a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fdfb3ad47f314de243ab410374ff173556693e7d1a1c5f393892ec54b2c5826897d61a839392ea74e4f334be4bbc25974bee7c8f58bd279f0f4da33875d2bbe9
|
7
|
+
data.tar.gz: d8f5eb102d0cc7b74b7238b092543a6c6611e80ca65a91cc262fadcc5140dce9a748955572b290af81ccf7a824628c7e8ae3e70a4fda4606c31a33e28967d824
|
data/docs/images/plain.png
CHANGED
Binary file
|
data/docs/images/shogged.png
CHANGED
Binary file
|
data/lib/shog.rb
CHANGED
@@ -0,0 +1,17 @@
|
|
1
|
+
module Shog
|
2
|
+
module Extensions
|
3
|
+
module Colored
|
4
|
+
extend self
|
5
|
+
|
6
|
+
# Removes any ASCII color encoding
|
7
|
+
def uncolorize
|
8
|
+
# http://refiddle.com/18rj
|
9
|
+
gsub /\e\[\d+(;\d+)*m/, ''
|
10
|
+
end
|
11
|
+
|
12
|
+
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
String.send :include, Shog::Extensions::Colored
|
data/lib/shog/formatter.rb
CHANGED
@@ -79,10 +79,10 @@ module Shog
|
|
79
79
|
# @param [Float] expected maximum amount of time it should have taken.
|
80
80
|
# @return [String] the formatted time.
|
81
81
|
def format_time( time, expected = 30 )
|
82
|
-
timef = time.to_f
|
82
|
+
timef = time.uncolorize.to_f
|
83
83
|
case
|
84
|
-
when timef > expected * 2 then time.to_s.red
|
85
|
-
when timef > expected then time.to_s.yellow
|
84
|
+
when timef > expected * 2 then time.to_s.uncolorize.red
|
85
|
+
when timef > expected then time.to_s.uncolorize.yellow
|
86
86
|
else time
|
87
87
|
end
|
88
88
|
end
|
@@ -161,7 +161,7 @@ module Shog
|
|
161
161
|
# Resets any previously configured formatting settings.
|
162
162
|
# @return [Formatter] self.
|
163
163
|
def reset_config!
|
164
|
-
@configuration
|
164
|
+
@configuration = {
|
165
165
|
severity_tags: {},
|
166
166
|
severities: {},
|
167
167
|
matchers: {},
|
@@ -13,13 +13,13 @@ module Shog
|
|
13
13
|
# Highlight HTTP request methods
|
14
14
|
match /Started\s+(?<method>PUT|PATCH|GET|POST|DELETE)\s+(?<path>"[^"]*")[^\d\.]+(?<ip>[\d\.]+)(?<time>.*)/ do |msg,match|
|
15
15
|
# http://refiddle.com/ge6
|
16
|
-
"#{match["method"].ljust 6} ".green.bold + " #{match["path"]} ".white.bold + " for " + "#{match["ip"]}".yellow + " #{match["time"]}".black
|
16
|
+
"#{match["method"].ljust 6} ".green.bold + " #{match["path"]} ".white.bold + " for " + "#{match["ip"]}".yellow + " #{match["time"]}".black
|
17
17
|
end
|
18
18
|
|
19
19
|
# Dim detailed info about rendering views
|
20
20
|
match /\s*Rendered\s+(?<view>[^\s]+)\swithin\s(?<layout>[^\s]+)\s\((?<time>.*)\)/ do |msg,match|
|
21
21
|
# http://refiddle.com/18qr
|
22
|
-
" Rendered #{ match["view"] } within ".black + match["layout"].black.bold + " " + format_time( match['time'].black )
|
22
|
+
" Rendered #{ match["view"].bold }".black + " within ".black + match["layout"].black.bold + " " + format_time( match['time'].black )
|
23
23
|
end
|
24
24
|
|
25
25
|
# Highlight the final rendered response
|
@@ -34,7 +34,7 @@ module Shog
|
|
34
34
|
parts << match['friendly'].yellow
|
35
35
|
parts << 'in'
|
36
36
|
parts << format_time( match['time'], 250 )
|
37
|
-
parts << match['details']
|
37
|
+
parts << match['details'].black
|
38
38
|
|
39
39
|
parts.join(" ")
|
40
40
|
end
|
@@ -48,9 +48,6 @@ module Shog
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
|
51
|
-
|
52
|
-
|
53
|
-
|
54
51
|
end
|
55
52
|
end
|
56
53
|
end
|
data/lib/shog/version.rb
CHANGED
@@ -70,6 +70,10 @@ describe Shog::Formatter do
|
|
70
70
|
expect( formatter.format_time( "50ms", 30 ) ).to eq "50ms".yellow
|
71
71
|
end
|
72
72
|
|
73
|
+
it "is yellow when above expected and has existing color" do
|
74
|
+
expect( formatter.format_time( "50ms".black, 30 ) ).to eq "50ms".yellow
|
75
|
+
end
|
76
|
+
|
73
77
|
it "is red when way above expected" do
|
74
78
|
expect( formatter.format_time( "150ms", 30 ) ).to eq "150ms".red
|
75
79
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Paul Alexander
|
@@ -103,6 +103,7 @@ files:
|
|
103
103
|
- docs/images/plain.png
|
104
104
|
- docs/images/shogged.png
|
105
105
|
- lib/shog.rb
|
106
|
+
- lib/shog/extensions.rb
|
106
107
|
- lib/shog/formatter.rb
|
107
108
|
- lib/shog/formatters.rb
|
108
109
|
- lib/shog/formatters/defaults.rb
|