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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 26b76b9492d628aa816c7a48655b9ccf60fbbb67
4
- data.tar.gz: 760570d2e3cf9e05d76ba40637bbe79d4b4438a3
3
+ metadata.gz: e10f5ef853af5fcbf4cb08c8ad1c9ea3bd2e052b
4
+ data.tar.gz: 7959b91a38b1127f3d3334f57c9a60b02588c48a
5
5
  SHA512:
6
- metadata.gz: fa2b214992b45e4a17006556678a55ec0685d941cf029015adc3259bcc0ac310d6699a3462d70039b06f8cb5dd1c0942a0b9543798864979c323f14852c26157
7
- data.tar.gz: 0548365aa47e8911eb6e5d397b55f964a6d915ff81d2fca5059ed0f80dd190380d521fce73dd3a7bbc65a733755b788e49006ee54bd1181c5091089f8d9c5033
6
+ metadata.gz: fdfb3ad47f314de243ab410374ff173556693e7d1a1c5f393892ec54b2c5826897d61a839392ea74e4f334be4bbc25974bee7c8f58bd279f0f4da33875d2bbe9
7
+ data.tar.gz: d8f5eb102d0cc7b74b7238b092543a6c6611e80ca65a91cc262fadcc5140dce9a748955572b290af81ccf7a824628c7e8ae3e70a4fda4606c31a33e28967d824
Binary file
Binary file
data/lib/shog.rb CHANGED
@@ -2,6 +2,7 @@ require 'shog/version'
2
2
  require 'shog/formatter'
3
3
  require 'shog/formatters'
4
4
  require 'shog/rails'
5
+ require 'shog/extensions'
5
6
 
6
7
  module Shog
7
8
 
@@ -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
@@ -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.bold
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
@@ -1,5 +1,5 @@
1
1
  module Shog
2
- VERSION_NUMBER = "0.1.1"
2
+ VERSION_NUMBER = "0.1.2"
3
3
  VERSION_SUFFIX = ""
4
4
  VERSION = "#{VERSION_NUMBER}#{VERSION_SUFFIX}"
5
5
  end
@@ -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.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